class_docstr: Class that handles hierarchical ROIs
  
  Parameters
  ----------
  k : int
    Number of ROI in the SubDomains object
  label : array of shape (domain.size), dtype=np.int_
    An array use to define which voxel belongs to which ROI.
    The label values greater than -1 correspond to subregions
    labelling. The labels are recomputed so as to be consecutive
    integers.
    The labels should not be accessed outside this class. One has to
    use the API mapping methods instead.
  features : dict {str: list of object, length=self.k}
    Describe the voxels features, grouped by ROI
  roi_features : dict {str: array-like, shape=(self.k, roi_feature_dim)
    Describe the ROI features. A special feature, `id`, is read-only and
    is used to give an unique identifier for region, which is persistent
    through the MROI objects manipulations. On should access the different
    ROI's features using ids.
  parents : np.ndarray, shape(self.k)
    self.parents[i] is the index of the parent of the i-th ROI.
  
  TODO: have the parents as a list of id rather than a list of indices.
class_docstr_tok: ["Class","that","handles","hierarchical","ROIs","Parameters","--","--","--","--","--","k",":","int","Number","of","ROI","in","the","SubDomains","object","label",":","array","of","shape","(","domain.size",")",",","dtype=np.int_","An","array","use","to","define","which","voxel","belongs","to","which","ROI",".","The","label","values","greater","than","-1","correspond","to","subregions","labelling",".","The","labels","are","recomputed","so","as","to","be","consecutive","integers",".","The","labels","should","not","be","accessed","outside","this","class",".","One","has","to","use","the","API","mapping","methods","instead",".","features",":","dict","{","str",":","list","of","object",",","length=self.k","}","Describe","the","voxels","features",",","grouped","by","ROI","roi_features",":","dict","{","str",":","array-like",",","shape=","(","self.k",",","roi_feature_dim",")","Describe","the","ROI","features",".","A","special","feature",",","`","id","`",",","is","read-only","and","is","used","to","give","an","unique","identifier","for","region",",","which","is","persistent","through","the","MROI","objects","manipulations",".","On","should","access","the","different","ROI","'s","features","using","ids",".","parents",":","np.ndarray",",","shape","(","self.k",")","self.parents","[","i","]","is","the","index","of","the","parent","of","the","i-th","ROI",".","TODO",":","have","the","parents","as","a","list","of","id","rather","than","a","list","of","indices","."]
docstr: Returns an instance of HROI with only the subset of chosen ROIs.
  
  The hierarchy is set accordingly.
  
  Parameters
  ----------
  id_list: list of id (any hashable type)
    The id of the ROI to be kept in the structure.
docstr_tok: ["Returns","an","instance","of","HROI","with","only","the","subset","of","chosen","ROIs",".","The","hierarchy","is","set","accordingly",".","Parameters","--","--","--","--","--","id_list",":","list","of","id","(","any","hashable","type",")","The","id","of","the","ROI","to","be","kept","in","the","structure","."]
code: def select_roi(self, id_list):
      """Returns an instance of HROI with only the subset of chosen ROIs.
  
      The hierarchy is set accordingly.
  
      Parameters
      ----------
      id_list: list of id (any hashable type)
        The id of the ROI to be kept in the structure.
  
      """
      valid = np.asarray([int(i in id_list) for i in self.get_id()])
      if np.size(id_list) == 0:
          # handle the case of an empty selection
          new_parents = np.array([])
          self = HierarchicalROI(
              self.domain, -np.ones(self.label.size), np.array([])
          )
      else:
          # get new parents
          new_parents = (
              Forest(self.k, self.parents)
              .subforest(valid.astype(np.bool_))
              .parents.astype(np.int_)
          )
      SubDomains.select_roi(self, id_list)
      self.parents = new_parents
      self.recompute_labels()
  
imports: import numpy
  from nipy.algorithms.graph.field import field_from_coo_matrix_and_data
  from nipy.algorithms.graph.forest import Forest
  from nipy.algorithms.graph.graph import WeightedGraph
  from .mroi import SubDomains
label_desc: Use image node_id 4 for calling the HierarchicalROI obj's underlying member method code with example usage: obj.select_roi(id_list) without return types