docstr: Return the resampled run number r as a 4d nipy-like
  image. Returns all runs as a list of images if r is None.
docstr_tok: ["Return","the","resampled","run","number","r","as","a","4d","nipy-like","image",".","Returns","all","runs","as","a","list","of","images","if","r","is","None","."]
code: def resample(self, r=None, align_runs=True):
      """
      Return the resampled run number r as a 4d nipy-like
      image. Returns all runs as a list of images if r is None.
      """
      if align_runs:
          transforms = self._transforms
      else:
          transforms = self._within_run_transforms
      runs = range(len(self._runs))
      if r is None:
          data = [
              resample4d(
                  self._runs[r],
                  transforms=transforms[r],
                  time_interp=self._time_interp,
              )
              for r in runs
          ]
          return [
              make_xyz_image(data[r], self._runs[r].affine, "scanner")
              for r in runs
          ]
      else:
          data = resample4d(
              self._runs[r],
              transforms=transforms[r],
              time_interp=self._time_interp,
          )
          return make_xyz_image(data, self._runs[r].affine, "scanner")
  
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 4 for calling the Realign4d obj's underlying member method code with example usage: obj.resample(r, align_runs) and returns: unknown, make_xyz_image