code: def build_landmarks(
      domain,
      coords,
      subjects,
      labels,
      confidence=None,
      prevalence_pval=0.95,
      prevalence_threshold=0,
      sigma=1.0,
  ):
      """
      Given a list of hierarchical ROIs, and an associated labelling, this
      creates an Amer structure wuch groups ROIs with the same label.
  
      Parameters
      ----------
      domain: discrete_domain.DiscreteDomain instance,
              description of the spatial context of the landmarks
      coords: array of shape(n, 3)
              Sets of coordinates for the different objects
      subjects: array of shape (n), dtype = np.int_
                indicators of the dataset the objects come from
      labels: array of shape (n), dtype = np.int_
              index of the landmark the object is associated with
      confidence: array of shape (n),
                  measure of the significance of the regions
      prevalence_pval: float, optional
      prevalence_threshold: float, optional,
                     (c) A label should be present in prevalence_threshold
                     subjects with a probability>prevalence_pval
                     in order to be valid
      sigma: float optional,
            regularizing constant that defines a prior on the region extent
  
      Returns
      -------
      LR : None or structural_bfls.LR instance
           describing a cross-subject set of ROIs. If inference yields a null
           result, LR is set to None
      newlabel: array of shape (n)
                a relabelling of the individual ROIs, similar to u,
                that discards labels that do not fulfill the condition (c)
      """
      if confidence is None:
          confidence = np.ones(labels.size)
      intrasubj = np.concatenate(
          [
              np.arange(np.sum(subjects == s))
              for s in np.unique(subjects)
          ]
      )
  
      coordinates = []
      subjs = []
      pps = []
      n_labels = int(labels.max() + 1)
      valid = np.zeros(n_labels).astype(np.int_)
  
      # do some computation to find which regions are worth reporting
      for i in np.unique(labels[labels > -1]):
          mean_c, var_c = 0.0, 0.0
          subjects_i = subjects[labels == i]
          for subject_i in np.unique(subjects_i):
              confidence_i = 1 - np.prod(
                  1
                  - confidence[(labels == i) * (subjects == subject_i)]
              )
              mean_c += confidence_i
              var_c += confidence_i * (1 - confidence_i)
  
          # If noise is too low the variance is 0: ill-defined:
          var_c = max(var_c, 1e-14)
  
          # if above threshold, get some information to create the landmarks
          if (
              stats.norm.sf(
                  prevalence_threshold, mean_c, np.sqrt(var_c)
              )
              > prevalence_pval
          ):
              coord = np.vstack(
                  [
                      coords[subjects == s][k]
                      for (k, s) in zip(
                          intrasubj[labels == i], subjects[labels == i]
                      )
                  ]
              )
              valid[i] = 1
              coordinates.append(coord)
              subjs.append(subjects_i)
              pps.append(confidence[labels == i])
  
      # relabel the ROIs
      maplabel = -np.ones(n_labels).astype(np.int_)
      maplabel[valid > 0] = np.cumsum(valid[valid > 0]) - 1
  
      # create the landmark regions structure
      LR = LandmarkRegions(
          domain,
          np.sum(valid),
          indiv_coord=coordinates,
          subjects=subjs,
          confidence=pps,
      )
      return LR, maplabel
  
file_path: nipy/nipy/labs/spatial_models/structural_bfls.py
imports: import numpy
  from scipy import stats
label_desc: Use image node_id 2 for calling a global function with example usage: build_landmarks(domain, coords, subjects, labels, confidence, prevalence_pval, prevalence_threshold, sigma) and returns: LR,  maplabel