code: def test_mppca_flow(rng):
      with TemporaryDirectory() as out_dir:
          S0 = 100 + 2 * rng.standard_normal((22, 23, 30, 20))
          data_path = os.path.join(out_dir, "random_noise.nii.gz")
          save_nifti(data_path, S0, np.eye(4))
  
          mppca_flow = MPPCAFlow()
          mppca_flow.run(data_path, out_dir=out_dir)
          assert_true(
              os.path.isfile(
                  mppca_flow.last_generated_outputs["out_denoised"]
              )
          )
          assert_false(
              os.path.isfile(
                  mppca_flow.last_generated_outputs["out_sigma"]
              )
          )
  
          mppca_flow._force_overwrite = True
          mppca_flow.run(
              data_path,
              return_sigma=True,
              pca_method="svd",
              out_dir=out_dir,
          )
          assert_true(
              os.path.isfile(
                  mppca_flow.last_generated_outputs["out_denoised"]
              )
          )
          assert_true(
              os.path.isfile(
                  mppca_flow.last_generated_outputs["out_sigma"]
              )
          )
  
          denoised_path = mppca_flow.last_generated_outputs[
              "out_denoised"
          ]
          denoised_data = load_nifti_data(denoised_path)
          assert_greater(denoised_data.min(), S0.min())
          assert_less(denoised_data.max(), S0.max())
          npt.assert_equal(np.round(denoised_data.mean()), 100)
  
file_path: dipy/dipy/workflows/tests/test_denoise.py
imports: import os
  from tempfile import TemporaryDirectory
  import pytest
  import numpy
  import numpy.testing
  from dipy.utils.optpkg import optional_package
  from dipy.data import get_fnames
  from dipy.io.image import save_nifti, load_nifti, load_nifti_data
  from dipy.testing import assert_true, assert_false, assert_greater, assert_less
  from dipy.testing.decorators import set_random_number_generator
  from dipy.workflows.denoise import NLMeansFlow, LPCAFlow, MPPCAFlow, GibbsRingingFlow, Patch2SelfFlow
label_desc: Use image node_id 4 for calling a global function with example usage: test_mppca_flow(rng) without return types