code: def _pca_classifier(L, nvoxels):
      """Classifies which PCA eigenvalues are related to noise and estimates the
      noise variance
  
      Parameters
      ----------
      L : array (n,)
          Array containing the PCA eigenvalues in ascending order.
      nvoxels : int
          Number of voxels used to compute L
  
      Returns
      -------
      var : float
          Estimation of the noise variance
      ncomps : int
          Number of eigenvalues related to noise
  
      Notes
      -----
      This is based on the algorithm described in [1]_.
  
      References
      ----------
      .. [1] Veraart J, Novikov DS, Christiaens D, Ades-aron B, Sijbers,
             Fieremans E, 2016. Denoising of Diffusion MRI using random matrix
             theory. Neuroimage 142:394-406.
             doi: 10.1016/j.neuroimage.2016.08.016
      """
  
      # if num_samples - 1 (to correct for mean subtraction) is less than number
      # of features, discard the zero eigenvalues
      if L.size > nvoxels - 1:
          L = L[-(nvoxels - 1) :]
  
      # Note that the condition expressed in the while-loop is expressed in terms
      # of the variance of equation (12), not equation (11) as in [1]_. Also,
      # this code implements ascending eigenvalues, unlike [1]_.
      var = np.mean(L)
      c = L.size - 1
      r = L[c] - L[0] - 4 * np.sqrt((c + 1.0) / nvoxels) * var
      while r > 0:
          var = np.mean(L[:c])
          c = c - 1
          r = L[c] - L[0] - 4 * np.sqrt((c + 1.0) / nvoxels) * var
      ncomps = c + 1
  
      return var, ncomps
  
file_path: dipy/dipy/denoise/localpca.py
imports: import copy
  from packaging.version import Version
  from warnings import warn
  import numpy
  import scipy
  from scipy.linalg import eigh
  from dipy.denoise.pca_noise_estimate import pca_noise_estimate
label_desc: Use image node_id 2 for calling a global function with example usage: _pca_classifier(L, nvoxels) and returns: var,  ncomps