class_docstr: Particular instance of StructuredDomain, that receives
  3 additional variables:
  affine: array of shape (dim+1, dim+1),
          affine transform that maps points to a coordinate system
  shape: dim-tuple,
         shape of the domain
  ijk: array of shape(size, dim), int
       grid coordinates of the points
  
  This is to allow easy conversion to images when dim==3,
  and for compatibility with previous classes
class_docstr_tok: ["Particular","instance","of","StructuredDomain",",","that","receives","3","additional","variables",":","affine",":","array","of","shape","(","dim+1",",","dim+1",")",",","affine","transform","that","maps","points","to","a","coordinate","system","shape",":","dim-tuple",",","shape","of","the","domain","ijk",":","array","of","shape","(","size",",","dim",")",",","int","grid","coordinates","of","the","points","This","is","to","allow","easy","conversion","to","images","when","dim==3",",","and","for","compatibility","with","previous","classes"]
docstr: Initialize ndgrid domain instance
  
  Parameters
  ----------
  dim: int,
       the (physical) dimension of the domain
  ijk: array of shape(size, dim), int
       grid coordinates of the points
  shape: dim-tuple,
     shape of the domain
  affine: array of shape (dim+1, dim+1),
      affine transform that maps points to a coordinate system
  local_volume: array of shape(size),
                yields the volume associated with each site
  topology: sparse binary coo_matrix of shape (size, size),
            that yields the neighboring locations in the domain
  referential: string, optional,
               identifier of the referential of the coordinates system
  
  Notes
  -----
  FIXME: local_volume might be computed on-the-fly as |det(affine)|
code: def __init__(
      self,
      dim,
      ijk,
      shape,
      affine,
      local_volume,
      topology,
      referential="",
  ):
      """Initialize ndgrid domain instance
  
      Parameters
      ----------
      dim: int,
           the (physical) dimension of the domain
      ijk: array of shape(size, dim), int
           grid coordinates of the points
      shape: dim-tuple,
         shape of the domain
      affine: array of shape (dim+1, dim+1),
          affine transform that maps points to a coordinate system
      local_volume: array of shape(size),
                    yields the volume associated with each site
      topology: sparse binary coo_matrix of shape (size, size),
                that yields the neighboring locations in the domain
      referential: string, optional,
                   identifier of the referential of the coordinates system
  
      Notes
      -----
      FIXME: local_volume might be computed on-the-fly as |det(affine)|
      """
      # shape
      if len(shape) != dim:
          raise ValueError("Incompatible shape and dim")
      self.shape = shape
  
      # affine
      if affine.shape != (dim + 1, dim + 1):
          raise ValueError("Incompatible dim and affine")
      self.affine = affine
  
      # ijk
      if (np.size(ijk) == ijk.shape[0]) & (np.size(ijk) > 0):
          ijk = np.reshape(ijk, (ijk.size, 1))
          if (ijk.max(0) + 1 > shape).any():
              raise ValueError(
                  "Provided indices do not fit within shape"
              )
      self.ijk = ijk
  
      # coord
      coord = idx_affine_coord(ijk, affine)
  
      StructuredDomain.__init__(
          self, dim, coord, local_volume, topology
      )
  
imports: import numpy
  import scipy.sparse
  from nibabel import Nifti1Image, load, save
  from nipy.algorithms.graph import WeightedGraph, wgraph_from_3d_grid, wgraph_from_coo_matrix
  from nipy.io.nibcompat import get_affine, get_header
label_desc: Use image node_id 1 to create a new NDGridDomain object from inherited base classes: StructuredDomain with example: obj = NDGridDomain(dim, ijk, shape, affine, local_volume, topology, referential)