docstr: DiffeomorphicMap
  
  Implements a diffeomorphic transformation on the physical space. The
  deformation fields encoding the direct and inverse transformations
  share the same domain discretization (both the discretization grid
  shape and voxel-to-space matrix). The input coordinates (physical
  coordinates) are first aligned using prealign, and then displaced
  using the corresponding vector field interpolated at the aligned
  coordinates.
  
  Parameters
  ----------
  dim : int, 2 or 3
      the transformation's dimension
  disp_shape : array, shape (dim,)
      the number of slices (if 3D), rows and columns of the deformation
      field's discretization
  disp_grid2world : the voxel-to-space transform between the def. fields
      grid and space
  domain_shape : array, shape (dim,)
      the number of slices (if 3D), rows and columns of the default
      discretization of this map's domain
  domain_grid2world : array, shape (dim+1, dim+1)
      the default voxel-to-space transformation between this map's
      discretization and physical space
  codomain_shape : array, shape (dim,)
      the number of slices (if 3D), rows and columns of the images that
      are 'normally' warped using this transformation in the forward
      direction (this will provide default transformation parameters to
      warp images under this transformation). By default, we assume that
      the inverse transformation is 'normally' used to warp images with
      the same discretization and voxel-to-space transformation as the
      deformation field grid.
  codomain_grid2world : array, shape (dim+1, dim+1)
      the voxel-to-space transformation of images that are 'normally'
      warped using this transformation (in the forward direction).
  prealign : array, shape (dim+1, dim+1)
      the linear transformation to be applied to align input images to
      the reference space before warping under the deformation field.
code: def __init__(
      self,
      dim,
      disp_shape,
      disp_grid2world=None,
      domain_shape=None,
      domain_grid2world=None,
      codomain_shape=None,
      codomain_grid2world=None,
      prealign=None,
  ):
      """DiffeomorphicMap
  
      Implements a diffeomorphic transformation on the physical space. The
      deformation fields encoding the direct and inverse transformations
      share the same domain discretization (both the discretization grid
      shape and voxel-to-space matrix). The input coordinates (physical
      coordinates) are first aligned using prealign, and then displaced
      using the corresponding vector field interpolated at the aligned
      coordinates.
  
      Parameters
      ----------
      dim : int, 2 or 3
          the transformation's dimension
      disp_shape : array, shape (dim,)
          the number of slices (if 3D), rows and columns of the deformation
          field's discretization
      disp_grid2world : the voxel-to-space transform between the def. fields
          grid and space
      domain_shape : array, shape (dim,)
          the number of slices (if 3D), rows and columns of the default
          discretization of this map's domain
      domain_grid2world : array, shape (dim+1, dim+1)
          the default voxel-to-space transformation between this map's
          discretization and physical space
      codomain_shape : array, shape (dim,)
          the number of slices (if 3D), rows and columns of the images that
          are 'normally' warped using this transformation in the forward
          direction (this will provide default transformation parameters to
          warp images under this transformation). By default, we assume that
          the inverse transformation is 'normally' used to warp images with
          the same discretization and voxel-to-space transformation as the
          deformation field grid.
      codomain_grid2world : array, shape (dim+1, dim+1)
          the voxel-to-space transformation of images that are 'normally'
          warped using this transformation (in the forward direction).
      prealign : array, shape (dim+1, dim+1)
          the linear transformation to be applied to align input images to
          the reference space before warping under the deformation field.
  
      """
  
      self.dim = dim
  
      if disp_shape is None:
          raise ValueError("Invalid displacement field discretization")
  
      self.disp_shape = np.asarray(disp_shape, dtype=np.int32)
  
      # If the discretization affine is None, we assume it's the identity
      self.disp_grid2world = disp_grid2world
      if self.disp_grid2world is None:
          self.disp_world2grid = None
      else:
          self.disp_world2grid = npl.inv(self.disp_grid2world)
  
      # If domain_shape isn't provided, we use the map's discretization shape
      if domain_shape is None:
          self.domain_shape = self.disp_shape
      else:
          self.domain_shape = np.asarray(domain_shape, dtype=np.int32)
      self.domain_grid2world = domain_grid2world
      if domain_grid2world is None:
          self.domain_world2grid = None
      else:
          self.domain_world2grid = npl.inv(domain_grid2world)
  
      # If codomain shape was not provided, we assume it is an endomorphism:
      # use the same domain_shape and codomain_grid2world as the field domain
      if codomain_shape is None:
          self.codomain_shape = self.domain_shape
      else:
          self.codomain_shape = np.asarray(
              codomain_shape, dtype=np.int32
          )
      self.codomain_grid2world = codomain_grid2world
      if codomain_grid2world is None:
          self.codomain_world2grid = None
      else:
          self.codomain_world2grid = npl.inv(codomain_grid2world)
  
      self.prealign = prealign
      if prealign is None:
          self.prealign_inv = None
      else:
          self.prealign_inv = npl.inv(prealign)
  
      self.is_inverse = False
      self.forward = None
      self.backward = None
  
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 1 to create a new DiffeomorphicMap object  with example: obj = DiffeomorphicMap(dim, disp_shape, disp_grid2world, domain_shape, domain_grid2world, codomain_shape, codomain_grid2world, prealign)