code: def resample_img2img(
      source, target, order=3, mode="constant", cval=0.0
  ):
      """Resample `source` image to space of `target` image
  
      This wraps the resample function to resample one image onto another.
      The output of the function will give an image with shape of the
      target and data from the source.
  
      Parameters
      ----------
      source : ``Image``
         Image instance that is to be resampled
      target : ``Image``
         Image instance to which source is resampled. The output image will
         have the same shape as the target, and the same coordmap.
      order : ``int``, optional
         What order of interpolation to use in ``scipy.ndimage``.
      mode : str, optional
          Points outside the boundaries of the input are filled according to the
          given mode ('constant', 'nearest', 'reflect' or 'wrap'). Default is
          'constant'.
      cval : scalar, optional
          Value used for points outside the boundaries of the input if
          mode='constant'. Default is 0.0.
  
      Returns
      -------
      output : ``Image``
         Image with interpolated data and output.coordmap == target.coordmap
  
      Examples
      --------
      >>> from nipy.testing import funcfile, anatfile
      >>> from nipy.io.api import load_image
      >>> aimg_source = load_image(anatfile)
      >>> aimg_target = aimg_source
      >>> # in this case, we resample aimg to itself
      >>> resimg = resample_img2img(aimg_source, aimg_target)
      """
      sip, sop = source.coordmap.ndims
      tip, top = target.coordmap.ndims
      # print sip, sop, tip, top
      if sop != top:
          raise ValueError(
              "source coordmap output dimension not equal "
              "to target coordmap output dimension"
          )
      mapping = np.eye(sop + 1)  # this would usually be 3+1
      resimg = resample(
          source,
          target.coordmap,
          mapping,
          target.shape,
          order=order,
          mode=mode,
          cval=cval,
      )
      return resimg
  
file_path: nipy/nipy/algorithms/resample.py
imports: import copy
  import numpy
  from nibabel.affines import from_matvec, to_matvec
  from scipy.ndimage import affine_transform
  from ..core.api import AffineTransform, ArrayCoordMap, CoordinateMap, Image, compose
  from .interpolation import ImageInterpolator
label_desc: Use image node_id 1 for calling a global function with example usage: resample_img2img(source, target, order, mode, cval) and returns: resimg