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: Returns an instance of self that has been further masked
          
code: def mask(self, bmask):
      """Returns an instance of self that has been further masked"""
      if bmask.size != self.size:
          raise ValueError("Invalid mask size")
  
      svol = self.local_volume[bmask]
      stopo = reduce_coo_matrix(self.topology, bmask)
      sijk = self.ijk[bmask]
      DD = NDGridDomain(
          self.dim,
          sijk,
          self.shape,
          self.affine,
          svol,
          stopo,
          self.referential,
      )
  
      for fid in list(self.features.keys()):
          f = self.features.pop(fid)
          DD.set_feature(fid, f[bmask])
      return DD
  
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 2 for calling the NDGridDomain obj's underlying member method code with example usage: obj.mask(bmask) and returns: DD