code: def HROI_from_watershed(domain, data, threshold=NINF):
      """Instantiate an HierarchicalROI as the watershed of a certain dataset
  
      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.
  
      Returns
      -------
      nroi : ``HierarchichalROI`` instance
          The HierachicalROI instance with a ``seed`` feature.
      """
      if threshold > data.max():
          # return an empty HROI structure
          label = -np.ones(data.shape)
          parents = np.array([])
          return HierarchicalROI(domain, label, parents)
  
      df = field_from_coo_matrix_and_data(domain.topology, data)
      idx, label = df.custom_watershed(0, threshold)
      parents = np.arange(idx.size).astype(int)
      nroi = HierarchicalROI(domain, label, parents)
  
      nroi.set_roi_feature("seed", idx)
      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 3 for calling a global function with example usage: HROI_from_watershed(domain, data, threshold) and returns: nroi, HierarchicalROI