code: def HROI_as_discrete_domain_blobs(
      domain, data, threshold=NINF, smin=0, criterion="size"
  ):
      """Instantiate an HierarchicalROI as the blob decomposition
      of data in a certain domain.
  
      Parameters
      ----------
      domain : discrete_domain.StructuredDomain instance,
        Definition of the spatial context.
      data : array of shape (domain.size)
        The corresponding data field.
      threshold : float, optional
        Thresholding level.
      criterion : string, optional
        To be chosen among 'size' or 'volume'.
      smin: float, optional
        A threshold on the criterion.
  
      Returns
      -------
      nroi: HierachicalROI instance with a `signal` feature.
  
      """
      if threshold > data.max():
          # return an empty HROI structure
          label = -np.ones(data.shape)
          parents = np.array([])
          return HierarchicalROI(domain, label, parents)
  
      # check size
      df = field_from_coo_matrix_and_data(domain.topology, data)
      idx, parents, label = df.threshold_bifurcations(th=threshold)
      nroi = HierarchicalROI(domain, label, parents)
      # create a signal feature
      data = np.ravel(data)
      signal = [
          data[nroi.select_id(id, roi=False)] for id in nroi.get_id()
      ]
      nroi.set_feature("signal", signal)
      # agglomerate regions in order to compact the structure if necessary
      nroi = hroi_agglomeration(nroi, criterion=criterion, smin=smin)
      return nroi
  
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 2 for calling a global function with example usage: HROI_as_discrete_domain_blobs(domain, data, threshold, smin, criterion) and returns: nroi, HierarchicalROI