code: def test_phantom(rng):
      # generate a gradient table for phantom data
      directions8 = generate_bvecs(8)
      directions30 = generate_bvecs(20)
      directions60 = generate_bvecs(30)
      # Create full dataset parameters
      # (6 b-values = 0, 8 directions for b-value 300, 30 directions for b-value
      # 1000 and 60 directions for b-value 2000)
      bvals = np.hstack(
          (
              np.zeros(6),
              300 * np.ones(8),
              1000 * np.ones(20),
              2000 * np.ones(30),
          )
      )
      bvecs = np.vstack(
          (np.zeros((6, 3)), directions8, directions30, directions60)
      )
      gtab = gradient_table(bvals, bvecs)
  
      dwi, sigma = rfiw_phantom(gtab, snr=10, rng=rng)
      dwi_den1 = p2s.patch2self(
          dwi, model="ridge", bvals=bvals, alpha=1.0
      )
  
      assert_less(np.max(dwi_den1) / sigma, np.max(dwi) / sigma)
      dwi_den2 = p2s.patch2self(
          dwi, model="ridge", bvals=bvals, alpha=0.7
      )
  
      assert_less(np.max(dwi_den2) / sigma, np.max(dwi) / sigma)
      assert_array_almost_equal(dwi_den1, dwi_den2, decimal=0)
  
      assert_raises(
          ValueError, p2s.patch2self, dwi, model="empty", bvals=bvals
      )
  
      # Try this with a sigma volume, instead of a scalar
      dwi_den = p2s.patch2self(dwi, bvals=bvals, model="ols")
  
      assert_less(np.max(dwi_den) / sigma, np.max(dwi) / sigma)
  
file_path: dipy/dipy/denoise/tests/test_patch2self.py
imports: import warnings
  import numpy
  from dipy.denoise import patch2self
  from dipy.testing import assert_greater, assert_less, assert_greater_equal, assert_less_equal
  from numpy.testing import assert_array_almost_equal, assert_raises, assert_equal
  import pytest
  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
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 4 for calling a global function with example usage: test_phantom(rng) without return types