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: Compute a ROI representative of a given feature.
  
  Parameters
  ----------
  fid: str,
    Feature id
  method: str,
    Method used to compute a representative.
    Chosen among 'mean' (default), 'max', 'median', 'min',
    'weighted mean'.
  id: any hashable type
    Id of the ROI from which we want to extract a representative feature.
    Can be None (default) if we want to get all ROIs's representatives.
  ignore_children: bool,
    Specify if the volume of the node should include
    (ignore_children = False) or not the one of its children
    (ignore_children = True).
  assess_quality: bool
    If True, a new roi feature is created, which represent the quality
    of the feature representative (the number of non-nan value for the
    feature over the ROI size).
    Default is False.
docstr_tok: ["Compute","a","ROI","representative","of","a","given","feature",".","Parameters","--","--","--","--","--","fid",":","str",",","Feature","id","method",":","str",",","Method","used","to","compute","a","representative",".","Chosen","among","'mean","'","(","default",")",",","'max","'",",","'median","'",",","'min","'",",","'weighted","mean","'",".","id",":","any","hashable","type","Id","of","the","ROI","from","which","we","want","to","extract","a","representative","feature",".","Can","be","None","(","default",")","if","we","want","to","get","all","ROIs","'s","representatives",".","ignore_children",":","bool",",","Specify","if","the","volume","of","the","node","should","include","(","ignore_children","=","False",")","or","not","the","one","of","its","children","(","ignore_children","=","True",")",".","assess_quality",":","bool","If","True",",","a","new","roi","feature","is","created",",","which","represent","the","quality","of","the","feature","representative","(","the","number","of","non-nan","value","for","the","feature","over","the","ROI","size",")",".","Default","is","False","."]
code: def representative_feature(
      self,
      fid,
      method="mean",
      id=None,
      ignore_children=True,
      assess_quality=True,
  ):
      """Compute a ROI representative of a given feature.
  
      Parameters
      ----------
      fid: str,
        Feature id
      method: str,
        Method used to compute a representative.
        Chosen among 'mean' (default), 'max', 'median', 'min',
        'weighted mean'.
      id: any hashable type
        Id of the ROI from which we want to extract a representative feature.
        Can be None (default) if we want to get all ROIs's representatives.
      ignore_children: bool,
        Specify if the volume of the node should include
        (ignore_children = False) or not the one of its children
        (ignore_children = True).
      assess_quality: bool
        If True, a new roi feature is created, which represent the quality
        of the feature representative (the number of non-nan value for the
        feature over the ROI size).
        Default is False.
  
      """
      rf = []
      eps = 1.0e-15
      feature_quality = np.zeros(self.k)
      for i, k in enumerate(self.get_id()):
          f = self.get_feature(fid, k)
          p_pos = self.select_id(k)
          if not ignore_children:
              # also include the children features
              desc = np.nonzero(self.parents == p_pos)[0]
              if p_pos in desc:
                  desc = desc[desc != p_pos]
              for c in desc:
                  f = np.concatenate(
                      (f, self.get_feature(fid, self.get_id()[c]))
                  )
          # NaN-resistant representative
          if f.ndim == 2:
              nan = np.isnan(f.sum(1))
          else:
              nan = np.isnan(f)
          # feature quality
          feature_quality[i] = (~nan).sum() / float(nan.size)
          # compute representative
          if method == "mean":
              rf.append(np.mean(f[~nan], 0))
          if method == "weighted mean":
              lvk = self.get_local_volume(k)
              if not ignore_children:
                  # append weights for children's voxels
                  for c in desc:
                      lvk = np.concatenate(
                          (
                              lvk,
                              self.get_local_volume(
                                  fid, self.select_id(c)
                              ),
                          )
                      )
              tmp = np.dot(
                  lvk[~nan], f[~nan].reshape((-1, 1))
              ) / np.maximum(eps, np.sum(lvk[~nan]))
              rf.append(tmp)
          if method == "min":
              rf.append(np.min(f[~nan]))
          if method == "max":
              rf.append(np.max(f[~nan]))
          if method == "median":
              rf.append(np.median(f[~nan], 0))
      if id is not None:
          summary_feature = rf[self.select_id(id)]
      else:
          summary_feature = rf
  
      if assess_quality:
          self.set_roi_feature(f"{fid}_quality", feature_quality)
      return np.array(summary_feature)
  
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 13 for calling the HierarchicalROI obj's underlying member method code with example usage: obj.representative_feature(fid, method, id, ignore_children, assess_quality) and returns: np