docstr: Generic initialization method.
docstr_tok: ["Generic","initialization","method","."]
code: def _init(self, images, tr, slice_times, slice_info, affine_class):
      """
      Generic initialization method.
      """
      if slice_times is None:
          tr = 1.0
          slice_times = 0.0
          time_interp = False
      else:
          time_interp = True
      if not isinstance(images, (list, tuple, np.ndarray)):
          images = [images]
      if tr is None:
          raise ValueError("Repetition time cannot be None.")
      if tr == 0:
          raise ValueError("Repetition time cannot be zero.")
      self.affine_class = affine_class
      self.slice_times = slice_times
      self.tr = tr
      self._runs = []
      # Note that, the affine of each run may be different. This is
      # the case, for instance, if the subject exits the scanner
      # in between sessions.
      for im in images:
          xyz_img = as_xyz_image(im)
          self._runs.append(
              Image4d(
                  xyz_img.get_fdata,
                  xyz_affine(xyz_img),
                  tr,
                  slice_times=slice_times,
                  slice_info=slice_info,
              )
          )
      self._transforms = [None for run in self._runs]
      self._within_run_transforms = [None for run in self._runs]
      self._mean_transforms = [None for run in self._runs]
      self._time_interp = time_interp
  
imports: import os
  import warnings
  import numpy
  from nibabel import io_orientation
  from nibabel.affines import apply_affine
  from ...core.image.image_spaces import as_xyz_image, make_xyz_image, xyz_affine
  from ...io.nibcompat import get_header
  from ..slicetiming import timefuncs
  from ._registration import _cspline_sample3d, _cspline_sample4d, _cspline_transform
  from .affine import Affine, Rigid
  from .optimizer import configure_optimizer, use_derivatives
  from .type_check import check_type, check_type_and_shape
label_desc: Use image node_id 2 for calling the Realign4d obj's underlying member method code with example usage: obj._init(images, tr, slice_times, slice_info, affine_class) without return types