docstr: Warps an image in the backward direction
  
  Deforms the input image under this diffeomorphic map in the backward
  direction. Since the mapping is defined in the physical space, the user
  must specify the sampling grid shape and its space-to-voxel mapping.
  By default, the transformation will use the discretization information
  given at initialization.
  
  Parameters
  ----------
  image : array, shape (s, r, c) if dim = 3 or (r, c) if dim = 2
      the image to be warped under this transformation in the backward
      direction
  interpolation : string, either 'linear' or 'nearest'
      the type of interpolation to be used for warping, either 'linear'
      (for k-linear interpolation) or 'nearest' for nearest neighbor
  image_world2grid : array, shape (dim+1, dim+1)
      the transformation bringing world (space) coordinates to voxel
      coordinates of the image given as input
  out_shape : array, shape (dim,)
      the number of slices, rows and columns of the desired warped image
  out_grid2world : the transformation bringing voxel coordinates of the
      warped image to physical space
  
  Returns
  -------
  warped : array, shape = out_shape or self.domain_shape if None
      the warped image under this transformation in the backward
      direction
  
  Notes
  -----
  A diffeomorphic map must be thought as a mapping between points
  in space. Warping an image J towards an image I means transforming
  each voxel with (discrete) coordinates i in I to (floating-point) voxel
  coordinates j in J. The transformation we consider 'backward' is
  precisely mapping coordinates i from the reference grid to coordinates
  j from the input image (that's why it's "backward"), which has the
  effect of warping the input image (moving) "towards" the reference.
  More precisely, the warped image is produced by the following
  interpolation:
  
  warped[i]=image[W * Pinv * backward[Dinv * S * i] + W * Pinv * S * i )]
  
  where i denotes the coordinates of a voxel in the input grid, W is
  the world-to-grid transformation of the image given as input, Dinv
  is the world-to-grid transformation of the deformation field
  discretization, Pinv is the pre-aligning matrix's inverse (transforming
  reference points to input points), S is the grid-to-space
  transformation of the sampling grid (see comment below) and backward is
  the backward deformation field.
  
  If we want to warp an image, we also must specify on what grid we
  want to sample the resulting warped image (the images are considered as
  points in space and its representation on a grid depends on its
  grid-to-space transform telling us for each grid voxel what point in
  space we need to bring via interpolation). So, S is the matrix that
  converts the sampling grid (whose shape is given as parameter
  'out_shape' ) to space coordinates.
code: def _warp_backward(
      self,
      image,
      interpolation="linear",
      image_world2grid=None,
      out_shape=None,
      out_grid2world=None,
  ):
      """Warps an image in the backward direction
  
      Deforms the input image under this diffeomorphic map in the backward
      direction. Since the mapping is defined in the physical space, the user
      must specify the sampling grid shape and its space-to-voxel mapping.
      By default, the transformation will use the discretization information
      given at initialization.
  
      Parameters
      ----------
      image : array, shape (s, r, c) if dim = 3 or (r, c) if dim = 2
          the image to be warped under this transformation in the backward
          direction
      interpolation : string, either 'linear' or 'nearest'
          the type of interpolation to be used for warping, either 'linear'
          (for k-linear interpolation) or 'nearest' for nearest neighbor
      image_world2grid : array, shape (dim+1, dim+1)
          the transformation bringing world (space) coordinates to voxel
          coordinates of the image given as input
      out_shape : array, shape (dim,)
          the number of slices, rows and columns of the desired warped image
      out_grid2world : the transformation bringing voxel coordinates of the
          warped image to physical space
  
      Returns
      -------
      warped : array, shape = out_shape or self.domain_shape if None
          the warped image under this transformation in the backward
          direction
  
      Notes
      -----
      A diffeomorphic map must be thought as a mapping between points
      in space. Warping an image J towards an image I means transforming
      each voxel with (discrete) coordinates i in I to (floating-point) voxel
      coordinates j in J. The transformation we consider 'backward' is
      precisely mapping coordinates i from the reference grid to coordinates
      j from the input image (that's why it's "backward"), which has the
      effect of warping the input image (moving) "towards" the reference.
      More precisely, the warped image is produced by the following
      interpolation:
  
      warped[i]=image[W * Pinv * backward[Dinv * S * i] + W * Pinv * S * i )]
  
      where i denotes the coordinates of a voxel in the input grid, W is
      the world-to-grid transformation of the image given as input, Dinv
      is the world-to-grid transformation of the deformation field
      discretization, Pinv is the pre-aligning matrix's inverse (transforming
      reference points to input points), S is the grid-to-space
      transformation of the sampling grid (see comment below) and backward is
      the backward deformation field.
  
      If we want to warp an image, we also must specify on what grid we
      want to sample the resulting warped image (the images are considered as
      points in space and its representation on a grid depends on its
      grid-to-space transform telling us for each grid voxel what point in
      space we need to bring via interpolation). So, S is the matrix that
      converts the sampling grid (whose shape is given as parameter
      'out_shape' ) to space coordinates.
  
      """
      # if no world-to-image transform is provided, we use the domain info
      if image_world2grid is None:
          image_world2grid = self.domain_world2grid
  
      # if no sampling info is provided, we use the codomain info
      if out_shape is None:
          if self.codomain_shape is None:
              msg = "Unknown sampling info. Provide a valid out_shape."
              raise ValueError(msg)
          out_shape = self.codomain_shape
      if out_grid2world is None:
          out_grid2world = self.codomain_grid2world
  
      W = self.interpret_matrix(image_world2grid)
      Dinv = self.disp_world2grid
      Pinv = self.prealign_inv
      S = self.interpret_matrix(out_grid2world)
  
      # this is the matrix which we need to multiply the voxel coordinates
      # to interpolate on the backward displacement field ("in"side the
      # 'backward' brackets in the expression above)
      affine_idx_in = mult_aff(Dinv, S)
  
      # this is the matrix which we need to multiply the voxel coordinates
      # to add to the displacement ("out"side the 'backward' brackets in the
      # expression above)
      affine_idx_out = mult_aff(W, mult_aff(Pinv, S))
  
      # this is the matrix which we need to multiply the displacement vector
      # prior to adding to the transformed input point
      affine_disp = mult_aff(W, Pinv)
  
      if interpolation == "nearest":
          if (
              image.dtype is np.dtype("float64")
              and floating is np.float32
          ):
              image = image.astype(floating)
          elif image.dtype is np.dtype("int64"):
              image = image.astype(np.int32)
      else:
          image = np.asarray(image, dtype=floating)
  
      warp_f = self._get_warping_function(interpolation)
  
      warped = warp_f(
          image,
          self.backward,
          affine_idx_in,
          affine_idx_out,
          affine_disp,
          out_shape,
      )
  
      return warped
  
imports: import logging
  import abc
  import numpy
  import numpy.linalg
  import nibabel
  from nibabel.streamlines import ArraySequence
  from dipy.align import vector_fields
  from dipy.align import floating
  from dipy.align import VerbosityLevels
  from dipy.align import Bunch
  from dipy.align.scalespace import ScaleSpace
label_desc: Use image node_id 10 for calling the DiffeomorphicMap obj's underlying member method code with example usage: obj._warp_backward(image, interpolation, image_world2grid, out_shape, out_grid2world) and returns: warped