class_docstr: Simple class to construct AffineTransform instances with slice notation
  like np.ogrid/np.mgrid.
  
  >>> c = CoordinateSystem('xy', 'input')
  >>> g = Grid(c)
  >>> points = g[-1:1:21j,-2:4:31j]
  >>> points.coordmap.affine
  array([[ 0.1,  0. , -1. ],
         [ 0. ,  0.2, -2. ],
         [ 0. ,  0. ,  1. ]])
  
  >>> print(points.coordmap.function_domain)
  CoordinateSystem(coord_names=('i0', 'i1'), name='product', coord_dtype=float64)
  >>> print(points.coordmap.function_range)
  CoordinateSystem(coord_names=('x', 'y'), name='input', coord_dtype=float64)
  
  >>> points.shape
  (21, 31)
  >>> print(points.transposed_values.shape)
  (2, 21, 31)
  >>> print(points.values.shape)
  (651, 2)
docstr: Create an AffineTransform coordinate map with into self.coords with
  slices created as in np.mgrid/np.ogrid.
docstr_tok: ["Create","an","AffineTransform","coordinate","map","with","into","self.coords","with","slices","created","as","in","np.mgrid\/np.ogrid","."]
code: def __getitem__(self, index):
      """
      Create an AffineTransform coordinate map with into self.coords with
      slices created as in np.mgrid/np.ogrid.
      """
      dtype = self.coordmap.function_domain.coord_dtype
      results = [a.ravel().astype(dtype) for a in np.ogrid[index]]
      if len(results) != len(self.coordmap.function_domain.coord_names):
          raise ValueError(
              "the number of slice objects must match "
              "the number of input dimensions"
          )
      cmaps = []
      for i, result in enumerate(results):
          if result.shape[0] > 1:
              step = result[1] - result[0]
          else:
              step = 0
          start = result[0]
          cmaps.append(
              AffineTransform(
                  CoordinateSystem(["i%d" % i], coord_dtype=dtype),
                  CoordinateSystem(
                      [self.coordmap.function_domain.coord_names[i]],
                      coord_dtype=dtype,
                  ),
                  np.array([[step, start], [0, 1]], dtype=dtype),
              )
          )
  
      shape = [result.shape[0] for result in results]
      cmap = cmap_product(*cmaps)
  
      # Identify the origin in the range of cmap
      # with the origin in the domain of self.coordmap
  
      cmap = shifted_range_origin(
          cmap,
          np.zeros(cmap.ndims[1]),
          self.coordmap.function_domain.name,
      )
  
      return ArrayCoordMap(compose(self.coordmap, cmap), tuple(shape))
  
file_path: nipy/nipy/core/reference/array_coords.py
imports: import numpy
  from .coordinate_map import AffineTransform, CoordinateMap, compose, shifted_range_origin
  from .coordinate_map import product
  from .coordinate_system import CoordinateSystem
label_desc: Use image node_id 2 for calling the Grid obj's underlying member method code with example usage: obj.__getitem__(index) and returns: ArrayCoordMap