code: def _stat_to_proba(
      test, learn=None, method="prior", alpha=0.01, verbose=0
  ):
      """Convert a set of statistics to posterior probabilities of  being
      generated under H0
  
      Parameters
      ----------
      test: array of shape(n_samples),
             data that is assessed
      learn: array of shape(n_samples), optional,
             data to learn a mixture model
             defaults to learn
      method: {'gauss_mixture', 'emp_null', 'gam_gauss', 'prior'}, optional,
             'gauss_mixture' A Gaussian Mixture Model is used
             'emp_null' a null mode is fitted to test
             'gam_gauss' a Gamma-Gaussian mixture is used
             'prior' a hard-coded function is used
      alpha: float in the [0,1] range, optional,
             parameter that yields the prior probability that a region is active
             should be chosen close to 0
      verbose: int, optional,
               verbosity mode
  
      Returns
      -------
      posterior_null: array of shape(n_samples)
                      an estimation of the probability that the observation
                      is generated under the null
      """
      if method == "gauss_mixture":
          prior_strength = 100
          fixed_scale = True
          posterior_probas = three_classes_GMM_fit(
              learn, test, alpha, prior_strength, verbose, fixed_scale
          )
          posterior_null = posterior_probas[:, 1]
      elif method == "emp_null":
          enn = NormalEmpiricalNull(learn)
          enn.learn()
          posterior_null = np.reshape(enn.fdr(test), np.size(test))
      elif method == "gam_gauss":
          posterior_probas = gamma_gaussian_fit(learn, test, verbose)
          posterior_null = posterior_probas[:, 1]
      elif method == "prior":
          y0 = st.norm.pdf(test)
          shape_, scale_ = 3.0, 2.0
          y1 = st.gamma.pdf(test, shape_, scale=scale_)
          posterior_null = np.ravel(
              (1 - alpha) * y0 / (alpha * y1 + (1 - alpha) * y0)
          )
      else:
          raise ValueError("Unknown method")
      return posterior_null
  
file_path: nipy/nipy/labs/spatial_models/bayesian_structural_analysis.py
imports: import numpy
  import scipy.stats
  from nipy.algorithms.graph import wgraph_from_coo_matrix
  from ...algorithms.statistics.empirical_pvalue import NormalEmpiricalNull, gamma_gaussian_fit, three_classes_GMM_fit
  from .hroi import HROI_as_discrete_domain_blobs
  from .structural_bfls import build_landmarks
label_desc: Use image node_id 1 for calling a global function with example usage: _stat_to_proba(test, learn, method, alpha, verbose) and returns: posterior_null