docstr: Workflow wrapping the nlmeans denoising method.
  
  It applies nlmeans denoise on each file found by 'globing'
  ``input_files`` and saves the results in a directory specified by
  ``out_dir``.
  
  Parameters
  ----------
  input_files : string
      Path to the input volumes. This path may contain wildcards to
      process multiple inputs at once.
  sigma : float, optional
      Sigma parameter to pass to the nlmeans algorithm.
  patch_radius : int, optional
      patch size is ``2 x patch_radius + 1``.
  block_radius : int, optional
      block size is ``2 x block_radius + 1``.
  rician : bool, optional
      If True the noise is estimated as Rician, otherwise Gaussian noise
      is assumed.
  out_dir : string, optional
      Output directory. (default current directory)
  out_denoised : string, optional
      Name of the resulting denoised volume.
  
  References
  ----------
  .. [Descoteaux08] Descoteaux, Maxime and Wiest-Daesslé, Nicolas and
  Prima, Sylvain and Barillot, Christian and Deriche, Rachid.
  Impact of Rician Adapted Non-Local Means Filtering on
  HARDI, MICCAI 2008
docstr_tok: ["Workflow","wrapping","the","nlmeans","denoising","method",".","It","applies","nlmeans","denoise","on","each","file","found","by","'globing'","``","input_files","``","and","saves","the","results","in","a","directory","specified","by","``","out_dir","``",".","Parameters","--","--","--","--","--","input_files",":","string","Path","to","the","input","volumes",".","This","path","may","contain","wildcards","to","process","multiple","inputs","at","once",".","sigma",":","float",",","optional","Sigma","parameter","to","pass","to","the","nlmeans","algorithm",".","patch_radius",":","int",",","optional","patch","size","is","``","2","x","patch_radius","+","1","``",".","block_radius",":","int",",","optional","block","size","is","``","2","x","block_radius","+","1","``",".","rician",":","bool",",","optional","If","True","the","noise","is","estimated","as","Rician",",","otherwise","Gaussian","noise","is","assumed",".","out_dir",":","string",",","optional","Output","directory",".","(","default","current","directory",")","out_denoised",":","string",",","optional","Name","of","the","resulting","denoised","volume",".","References","--","--","--","--","--","..","[","Descoteaux08","]","Descoteaux",",","Maxime","and","Wiest-Daessl\u00e9",",","Nicolas","and","Prima",",","Sylvain","and","Barillot",",","Christian","and","Deriche",",","Rachid",".","Impact","of","Rician","Adapted","Non-Local","Means","Filtering","on","HARDI",",","MICCAI","2008"]
code: def run(
      self,
      input_files,
      sigma=0,
      patch_radius=1,
      block_radius=5,
      rician=True,
      out_dir="",
      out_denoised="dwi_nlmeans.nii.gz",
  ):
      """Workflow wrapping the nlmeans denoising method.
  
      It applies nlmeans denoise on each file found by 'globing'
      ``input_files`` and saves the results in a directory specified by
      ``out_dir``.
  
      Parameters
      ----------
      input_files : string
          Path to the input volumes. This path may contain wildcards to
          process multiple inputs at once.
      sigma : float, optional
          Sigma parameter to pass to the nlmeans algorithm.
      patch_radius : int, optional
          patch size is ``2 x patch_radius + 1``.
      block_radius : int, optional
          block size is ``2 x block_radius + 1``.
      rician : bool, optional
          If True the noise is estimated as Rician, otherwise Gaussian noise
          is assumed.
      out_dir : string, optional
          Output directory. (default current directory)
      out_denoised : string, optional
          Name of the resulting denoised volume.
  
      References
      ----------
      .. [Descoteaux08] Descoteaux, Maxime and Wiest-Daesslé, Nicolas and
      Prima, Sylvain and Barillot, Christian and Deriche, Rachid.
      Impact of Rician Adapted Non-Local Means Filtering on
      HARDI, MICCAI 2008
  
      """
      io_it = self.get_io_iterator()
      for fpath, odenoised in io_it:
          if self._skip:
              shutil.copy(fpath, odenoised)
              logging.warning("Denoising skipped for now.")
          else:
              logging.info("Denoising %s", fpath)
              data, affine, image = load_nifti(fpath, return_img=True)
  
              if sigma == 0:
                  logging.info("Estimating sigma")
                  sigma = estimate_sigma(data)
                  logging.debug("Found sigma {0}".format(sigma))
  
              denoised_data = nlmeans(
                  data,
                  sigma=sigma,
                  patch_radius=patch_radius,
                  block_radius=block_radius,
                  rician=rician,
              )
              save_nifti(odenoised, denoised_data, affine, image.header)
  
              logging.info("Denoised volume saved as %s", odenoised)
  
imports: import logging
  import shutil
  import numpy
  from dipy.core.gradients import gradient_table
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.io.image import load_nifti, save_nifti
  from dipy.denoise.patch2self import patch2self
  from dipy.denoise.nlmeans import nlmeans
  from dipy.denoise.localpca import localpca, mppca
  from dipy.denoise.gibbs import gibbs_removal
  from dipy.denoise.noise_estimate import estimate_sigma
  from dipy.denoise.pca_noise_estimate import pca_noise_estimate
  from dipy.workflows.workflow import Workflow
  from dipy.utils.deprecator import deprecated_params
label_desc: Use image node_id 2 for calling the NLMeansFlow obj's underlying member method code with example usage: obj.run(input_files, sigma, patch_radius, block_radius, rician, out_dir, out_denoised) without return types