class_docstr: Class to create coordinate maps of different dimensions
      
class_docstr_tok: ["Class","to","create","coordinate","maps","of","different","dimensions"]
docstr: Create affine coordinate map
  
  Parameters
  ----------
  affine : (M, N) array-like
      Array expressing the affine transformation
  append_zooms : scalar or sequence length E
      If scalar, converted to sequence length E==1. Append E entries to
      the diagonal of `affine` (see examples)
  append_offsets : scalar or sequence length F
      If scalar, converted to sequence length F==1. If F==0, and E!=0, use
      sequence of zeros length E.  Append E entries to the translations
      (final column) of `affine` (see examples).
  
  Returns
  -------
  affmap : ``AffineTransform`` coordinate map
  
  Examples
  --------
  >>> from nipy.core.reference.coordinate_system import CoordSysMaker
  >>> dmaker = CoordSysMaker('ijkl', 'generic-array')
  >>> rmaker = CoordSysMaker('xyzt', 'generic-scanner')
  >>> cm_maker = CoordMapMaker(dmaker, rmaker)
  >>> cm_maker.make_affine(np.diag([2,3,4,1]))
  AffineTransform(
     function_domain=CoordinateSystem(coord_names=('i', 'j', 'k'), name='generic-array', coord_dtype=float64),
     function_range=CoordinateSystem(coord_names=('x', 'y', 'z'), name='generic-scanner', coord_dtype=float64),
     affine=array([[ 2.,  0.,  0.,  0.],
                   [ 0.,  3.,  0.,  0.],
                   [ 0.,  0.,  4.,  0.],
                   [ 0.,  0.,  0.,  1.]])
  )
  
  We can add extra orthogonal dimensions, by specifying the diagonal
  elements:
  
  >>> cm_maker.make_affine(np.diag([2,3,4,1]), 6)
  AffineTransform(
     function_domain=CoordinateSystem(coord_names=('i', 'j', 'k', 'l'), name='generic-array', coord_dtype=float64),
     function_range=CoordinateSystem(coord_names=('x', 'y', 'z', 't'), name='generic-scanner', coord_dtype=float64),
     affine=array([[ 2.,  0.,  0.,  0.,  0.],
                   [ 0.,  3.,  0.,  0.,  0.],
                   [ 0.,  0.,  4.,  0.,  0.],
                   [ 0.,  0.,  0.,  6.,  0.],
                   [ 0.,  0.,  0.,  0.,  1.]])
  )
  
  Or the diagonal elements and the offset elements:
  
  >>> cm_maker.make_affine(np.diag([2,3,4,1]), [6], [9])
  AffineTransform(
     function_domain=CoordinateSystem(coord_names=('i', 'j', 'k', 'l'), name='generic-array', coord_dtype=float64),
     function_range=CoordinateSystem(coord_names=('x', 'y', 'z', 't'), name='generic-scanner', coord_dtype=float64),
     affine=array([[ 2.,  0.,  0.,  0.,  0.],
                   [ 0.,  3.,  0.,  0.,  0.],
                   [ 0.,  0.,  4.,  0.,  0.],
                   [ 0.,  0.,  0.,  6.,  9.],
                   [ 0.,  0.,  0.,  0.,  1.]])
  )
docstr_tok: ["Create","affine","coordinate","map","Parameters","--","--","--","--","--","affine",":","(","M",",","N",")","array-like","Array","expressing","the","affine","transformation","append_zooms",":","scalar","or","sequence","length","E","If","scalar",",","converted","to","sequence","length","E==1",".","Append","E","entries","to","the","diagonal","of","`","affine","`","(","see","examples",")","append_offsets",":","scalar","or","sequence","length","F","If","scalar",",","converted","to","sequence","length","F==1",".","If","F==0",",","and","E","!","=0",",","use","sequence","of","zeros","length","E.","Append","E","entries","to","the","translations","(","final","column",")","of","`","affine","`","(","see","examples",")",".","Returns","--","--","--","-","affmap",":","``","AffineTransform","``","coordinate","map","Examples","--","--","--","--",">",">",">","from","nipy.core.reference.coordinate_system","import","CoordSysMaker",">",">",">","dmaker","=","CoordSysMaker","(","'ijkl","'",",","'generic-array","'",")",">",">",">","rmaker","=","CoordSysMaker","(","'xyzt","'",",","'generic-scanner","'",")",">",">",">","cm_maker","=","CoordMapMaker","(","dmaker",",","rmaker",")",">",">",">","cm_maker.make_affine","(","np.diag","(","[","2,3,4,1","]",")",")","AffineTransform","(","function_domain=CoordinateSystem","(","coord_names=","(","'","i","'",",","'","j","'",",","'","k","'",")",",","name='generic-array","'",",","coord_dtype=float64",")",",","function_range=CoordinateSystem","(","coord_names=","(","'","x","'",",","'","y","'",",","'","z","'",")",",","name='generic-scanner","'",",","coord_dtype=float64",")",",","affine=array","(","[","[","2.",",","0.",",","0.",",","0",".","]",",","[","0.",",","3.",",","0.",",","0",".","]",",","[","0.",",","0.",",","4.",",","0",".","]",",","[","0.",",","0.",",","0.",",","1",".","]","]",")",")","We","can","add","extra","orthogonal","dimensions",",","by","specifying","the","diagonal","elements",":",">",">",">","cm_maker.make_affine","(","np.diag","(","[","2,3,4,1","]",")",",","6",")","AffineTransform","(","function_domain=CoordinateSystem","(","coord_names=","(","'","i","'",",","'","j","'",",","'","k","'",",","'","l","'",")",",","name='generic-array","'",",","coord_dtype=float64",")",",","function_range=CoordinateSystem","(","coord_names=","(","'","x","'",",","'","y","'",",","'","z","'",",","'t","'",")",",","name='generic-scanner","'",",","coord_dtype=float64",")",",","affine=array","(","[","[","2.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","3.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","4.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","6.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","1",".","]","]",")",")","Or","the","diagonal","elements","and","the","offset","elements",":",">",">",">","cm_maker.make_affine","(","np.diag","(","[","2,3,4,1","]",")",",","[","6","]",",","[","9","]",")","AffineTransform","(","function_domain=CoordinateSystem","(","coord_names=","(","'","i","'",",","'","j","'",",","'","k","'",",","'","l","'",")",",","name='generic-array","'",",","coord_dtype=float64",")",",","function_range=CoordinateSystem","(","coord_names=","(","'","x","'",",","'","y","'",",","'","z","'",",","'t","'",")",",","name='generic-scanner","'",",","coord_dtype=float64",")",",","affine=array","(","[","[","2.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","3.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","4.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","6.",",","9",".","]",",","[","0.",",","0.",",","0.",",","0.",",","1",".","]","]",")",")"]
code: def make_affine(self, affine, append_zooms=(), append_offsets=()):
      """Create affine coordinate map
  
      Parameters
      ----------
      affine : (M, N) array-like
          Array expressing the affine transformation
      append_zooms : scalar or sequence length E
          If scalar, converted to sequence length E==1. Append E entries to
          the diagonal of `affine` (see examples)
      append_offsets : scalar or sequence length F
          If scalar, converted to sequence length F==1. If F==0, and E!=0, use
          sequence of zeros length E.  Append E entries to the translations
          (final column) of `affine` (see examples).
  
      Returns
      -------
      affmap : ``AffineTransform`` coordinate map
  
      Examples
      --------
      >>> from nipy.core.reference.coordinate_system import CoordSysMaker
      >>> dmaker = CoordSysMaker('ijkl', 'generic-array')
      >>> rmaker = CoordSysMaker('xyzt', 'generic-scanner')
      >>> cm_maker = CoordMapMaker(dmaker, rmaker)
      >>> cm_maker.make_affine(np.diag([2,3,4,1]))
      AffineTransform(
         function_domain=CoordinateSystem(coord_names=('i', 'j', 'k'), name='generic-array', coord_dtype=float64),
         function_range=CoordinateSystem(coord_names=('x', 'y', 'z'), name='generic-scanner', coord_dtype=float64),
         affine=array([[ 2.,  0.,  0.,  0.],
                       [ 0.,  3.,  0.,  0.],
                       [ 0.,  0.,  4.,  0.],
                       [ 0.,  0.,  0.,  1.]])
      )
  
      We can add extra orthogonal dimensions, by specifying the diagonal
      elements:
  
      >>> cm_maker.make_affine(np.diag([2,3,4,1]), 6)
      AffineTransform(
         function_domain=CoordinateSystem(coord_names=('i', 'j', 'k', 'l'), name='generic-array', coord_dtype=float64),
         function_range=CoordinateSystem(coord_names=('x', 'y', 'z', 't'), name='generic-scanner', coord_dtype=float64),
         affine=array([[ 2.,  0.,  0.,  0.,  0.],
                       [ 0.,  3.,  0.,  0.,  0.],
                       [ 0.,  0.,  4.,  0.,  0.],
                       [ 0.,  0.,  0.,  6.,  0.],
                       [ 0.,  0.,  0.,  0.,  1.]])
      )
  
      Or the diagonal elements and the offset elements:
  
      >>> cm_maker.make_affine(np.diag([2,3,4,1]), [6], [9])
      AffineTransform(
         function_domain=CoordinateSystem(coord_names=('i', 'j', 'k', 'l'), name='generic-array', coord_dtype=float64),
         function_range=CoordinateSystem(coord_names=('x', 'y', 'z', 't'), name='generic-scanner', coord_dtype=float64),
         affine=array([[ 2.,  0.,  0.,  0.,  0.],
                       [ 0.,  3.,  0.,  0.,  0.],
                       [ 0.,  0.,  4.,  0.,  0.],
                       [ 0.,  0.,  0.,  6.,  9.],
                       [ 0.,  0.,  0.,  0.,  1.]])
      )
      """
      affine = np.asarray(affine)
      append_zooms = np.atleast_1d(append_zooms)
      append_offsets = np.atleast_1d(append_offsets)
      extra_N = len(append_zooms)
      if len(append_offsets) == 0:
          append_offsets = np.zeros(extra_N, dtype=append_zooms.dtype)
      elif len(append_offsets) != extra_N:
          raise CoordMapMakerError(
              "Need same number of offsets as zooms"
          )
      o_n_domain = affine.shape[1] - 1
      o_n_range = affine.shape[0] - 1
      domain = self.domain_maker(o_n_domain + extra_N)
      range = self.range_maker(o_n_range + extra_N)
      if extra_N == 0:
          return self.affine_maker(domain, range, affine)
      # Combine original and added affine using product
      cmap0 = self.affine_maker(
          CS(domain.coord_names[:o_n_domain]),
          CS(range.coord_names[:o_n_range]),
          affine,
      )
      affine1 = from_matvec(np.diag(append_zooms), append_offsets)
      cmap1 = self.affine_maker(
          CS(domain.coord_names[o_n_domain:]),
          CS(range.coord_names[o_n_range:]),
          affine1,
      )
      cmap = product(cmap0, cmap1)
      # Return with original coordinate system names
      return self.affine_maker(domain, range, cmap.affine)
  
imports: import warnings
  import numpy
  import numpy.linalg
  from nibabel import io_orientation
  from nibabel.affines import from_matvec, to_matvec
  from .coordinate_system import CoordinateSystem, is_coordsys, safe_dtype
  from .coordinate_system import product
label_desc: Use image node_id 2 for calling the CoordMapMaker obj's underlying member method code with example usage: obj.make_affine(affine, append_zooms, append_offsets) and returns: self, self