code: def test_pca_classifier(rng):
      # Produce small phantom with well aligned single voxels and ground truth
      # snr = 50, i.e signal std = 0.02 (Gaussian noise)
      std_gt = 0.02
      S0 = 1.0
      ndir = gtab.bvals.size
      signal_test = np.zeros((5, 5, 5, ndir))
      mevals = np.array(
          [[0.99e-3, 0.0, 0.0], [2.26e-3, 0.87e-3, 0.87e-3]]
      )
      sig, direction = multi_tensor(
          gtab,
          mevals,
          S0=S0,
          angles=[(0, 0, 1), (0, 0, 1)],
          fractions=(50, 50),
          snr=None,
      )
      signal_test[..., :] = sig
      noise = std_gt * rng.standard_normal((5, 5, 5, ndir))
      dwi_test = signal_test + noise
  
      # Compute eigenvalues
      X = dwi_test.reshape(125, ndir)
      M = np.mean(X, axis=0)
      X = X - M
      [L, W] = np.linalg.eigh(np.dot(X.T, X) / 125)
  
      # Find number of noise related eigenvalues
      var, c = _pca_classifier(L, 125)
      std = np.sqrt(var)
  
      # Expected number of signal components is 0 because the phantom only has
      # one voxel type and that information is captured by the mean of X.
      # Therefore, expected noise components should be equal to size of L.
      # To allow some margin of error let's assess if c is higher than
      # L.size - 3.
      assert_(c > L.size - 3)
  
      # Let's check if noise std estimate as an error less than 5%
      std_error = abs(std - std_gt) / std_gt * 100
      assert_(std_error < 5)
  
imports: import warnings
  import numpy
  import scipy.special
  from numpy.testing import assert_, assert_equal, assert_raises, assert_array_almost_equal, assert_warns
  from dipy.denoise.localpca import dimensionality_problem_message, create_patch_radius_arr, compute_patch_size, compute_num_samples, compute_suggested_patch_radius, localpca, mppca, genpca, _pca_classifier
  from dipy.sims.voxel import multi_tensor
  from dipy.core.gradients import gradient_table, generate_bvecs
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 15 for calling a global function with example usage: test_pca_classifier(rng) without return types