class_docstr: Simultaneous motion and slice timing correction algorithm
  
  If slice_times is not specified, this algorithm performs spatial motion
  correction
  
  This interface wraps nipy's SpaceTimeRealign algorithm [Roche2011]_ or simply the
  SpatialRealign algorithm when timing info is not provided.
  
  Examples
  --------
  >>> from nipype.interfaces.nipy import SpaceTimeRealigner
  >>> #Run spatial realignment only
  >>> realigner = SpaceTimeRealigner()
  >>> realigner.inputs.in_file = ['functional.nii']
  >>> res = realigner.run() # doctest: +SKIP
  
  >>> realigner = SpaceTimeRealigner()
  >>> realigner.inputs.in_file = ['functional.nii']
  >>> realigner.inputs.tr = 2
  >>> realigner.inputs.slice_times = list(range(0, 3, 67))
  >>> realigner.inputs.slice_info = 2
  >>> res = realigner.run() # doctest: +SKIP
  
  
  References
  ----------
  .. [Roche2011] Roche A. A four-dimensional registration algorithm with        application to joint correction of motion and slice timing        in fMRI. IEEE Trans Med Imaging. 2011 Aug;30(8):1546-54. DOI_.
  
  .. _DOI: https://doi.org/10.1109/TMI.2011.2131152
code: def _run_interface(self, runtime):
      from nipy import save_image, load_image
  
      all_ims = [load_image(fname) for fname in self.inputs.in_file]
  
      if not isdefined(self.inputs.slice_times):
          from nipy.algorithms.registration.groupwise_registration import (
              SpaceRealign,
          )
  
          R = SpaceRealign(all_ims)
      else:
          from nipy.algorithms.registration import SpaceTimeRealign
  
          R = SpaceTimeRealign(
              all_ims,
              tr=self.inputs.tr,
              slice_times=self.inputs.slice_times,
              slice_info=self.inputs.slice_info,
          )
  
      R.estimate(refscan=None)
  
      corr_run = R.resample()
      self._out_file_path = []
      self._par_file_path = []
  
      for j, corr in enumerate(corr_run):
          self._out_file_path.append(
              os.path.abspath(
                  "corr_%s.nii.gz"
                  % (split_filename(self.inputs.in_file[j])[1])
              )
          )
          save_image(corr, self._out_file_path[j])
  
          self._par_file_path.append(
              os.path.abspath(
                  "%s.par" % (os.path.split(self.inputs.in_file[j])[1])
              )
          )
          mfile = open(self._par_file_path[j], "w")
          motion = R._transforms[j]
          # nipy does not encode euler angles. return in original form of
          # translation followed by rotation vector see:
          # http://en.wikipedia.org/wiki/Rodrigues'_rotation_formula
          for i, mo in enumerate(motion):
              params = [
                  "%.10f" % item
                  for item in np.hstack((mo.translation, mo.rotation))
              ]
              string = " ".join(params) + "\n"
              mfile.write(string)
          mfile.close()
  
      return runtime
  
imports: import os
  import nibabel
  import numpy
  from ...utils.filemanip import split_filename, fname_presuffix
  from .base import NipyBaseInterface, have_nipy
  from ..base import TraitedSpec, traits, BaseInterfaceInputSpec, isdefined, File, InputMultiPath, OutputMultiPath
label_desc: Use image node_id 1 for calling the SpaceTimeRealigner obj's underlying member method code with example usage: obj._run_interface(runtime) and returns: runtime