code: def moment_matching(dat, mu, sigma, glob_mu, glob_sigma):
      """
      Moment matching strategy for parameter initialization to feed a
      segmentation algorithm.
  
      Parameters
      ----------
      data: array
        Image data.
  
      mu : array
        Template class-specific intensity means
  
      sigma : array
        Template class-specific intensity variances
  
      glob_mu : float
        Template global intensity mean
  
      glob_sigma : float
        Template global intensity variance
  
      Returns
      -------
      dat_mu: array
        Guess of class-specific intensity means
  
      dat_sigma: array
        Guess of class-specific intensity variances
      """
      dat_glob_mu = float(np.mean(dat))
      dat_glob_sigma = float(np.var(dat))
      a = np.sqrt(dat_glob_sigma / glob_sigma)
      b = dat_glob_mu - a * glob_mu
      dat_mu = a * mu + b
      dat_sigma = (a**2) * sigma
      return dat_mu, dat_sigma
  
file_path: nipy/nipy/algorithms/segmentation/segmentation.py
imports: import numpy
  from ._segmentation import _interaction_energy, _ve_step
label_desc: Use image node_id 2 for calling a global function with example usage: moment_matching(dat, mu, sigma, glob_mu, glob_sigma) and returns: dat_mu,  dat_sigma