docstr: Spatiotemporal realignment class for series of 3D images.
  
  The algorithm performs simultaneous motion and slice timing
  correction for fMRI series or other data where slices are not
  acquired simultaneously.
  
  Parameters
  ----------
  images : image or list of images
    Single or multiple input 4d images representing one or
    several sessions.
  
  tr : float
    Inter-scan repetition time, i.e. the time elapsed between
    two consecutive scans. The unit in which `tr` is given is
    arbitrary although it needs to be consistent with the
    `slice_times` argument.
  
  slice_times : None or array-like
    If None, slices are assumed to be acquired simultaneously
    hence no slice timing correction is performed. If
    array-like, then the slice acquisition times.
  
  slice_info : None or tuple, optional
    None, or a tuple with slice axis as the first element and
    direction as the second, for instance (2, 1).  If None, then
    guess the slice axis, and direction, as the closest to the z
    axis, as estimated from the affine.
docstr_tok: ["Spatiotemporal","realignment","class","for","series","of","3D","images",".","The","algorithm","performs","simultaneous","motion","and","slice","timing","correction","for","fMRI","series","or","other","data","where","slices","are","not","acquired","simultaneously",".","Parameters","--","--","--","--","--","images",":","image","or","list","of","images","Single","or","multiple","input","4d","images","representing","one","or","several","sessions",".","tr",":","float","Inter-scan","repetition","time",",","i.e",".","the","time","elapsed","between","two","consecutive","scans",".","The","unit","in","which","`","tr","`","is","given","is","arbitrary","although","it","needs","to","be","consistent","with","the","`","slice_times","`","argument",".","slice_times",":","None","or","array-like","If","None",",","slices","are","assumed","to","be","acquired","simultaneously","hence","no","slice","timing","correction","is","performed",".","If","array-like",",","then","the","slice","acquisition","times",".","slice_info",":","None","or","tuple",",","optional","None",",","or","a","tuple","with","slice","axis","as","the","first","element","and","direction","as","the","second",",","for","instance","(","2",",","1",")",".","If","None",",","then","guess","the","slice","axis",",","and","direction",",","as","the","closest","to","the","z","axis",",","as","estimated","from","the","affine","."]
code: def __init__(
      self,
      images,
      tr,
      slice_times=None,
      slice_info=None,
      affine_class=Rigid,
  ):
      """
      Spatiotemporal realignment class for series of 3D images.
  
      The algorithm performs simultaneous motion and slice timing
      correction for fMRI series or other data where slices are not
      acquired simultaneously.
  
      Parameters
      ----------
      images : image or list of images
        Single or multiple input 4d images representing one or
        several sessions.
  
      tr : float
        Inter-scan repetition time, i.e. the time elapsed between
        two consecutive scans. The unit in which `tr` is given is
        arbitrary although it needs to be consistent with the
        `slice_times` argument.
  
      slice_times : None or array-like
        If None, slices are assumed to be acquired simultaneously
        hence no slice timing correction is performed. If
        array-like, then the slice acquisition times.
  
      slice_info : None or tuple, optional
        None, or a tuple with slice axis as the first element and
        direction as the second, for instance (2, 1).  If None, then
        guess the slice axis, and direction, as the closest to the z
        axis, as estimated from the affine.
      """
      self._init(images, tr, slice_times, slice_info, affine_class)
  
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 1 to create a new Realign4d object  with example: obj = Realign4d(images, tr, slice_times, slice_info, affine_class)