|
11 | 11 | from .base import MRTrix3BaseInputSpec, MRTrix3Base |
12 | 12 |
|
13 | 13 |
|
| 14 | +class DWIDenoiseInputSpec(MRTrix3BaseInputSpec): |
| 15 | + in_file = File( |
| 16 | + exists=True, |
| 17 | + argstr='%s', |
| 18 | + position=-2, |
| 19 | + mandatory=True, |
| 20 | + desc='input DWI image') |
| 21 | + mask = File( |
| 22 | + exists=True, |
| 23 | + argstr='-mask %s', |
| 24 | + position=1, |
| 25 | + mandatory=False, |
| 26 | + desc='mask image') |
| 27 | + extent = traits.Tuple((traits.Int, traits.Int, traits.Int), |
| 28 | + argstr='-extent %d,%d,%d', |
| 29 | + mandatory=False, |
| 30 | + desc='set the window size of the denoising filter. (default = 5,5,5)') |
| 31 | + noise = File( |
| 32 | + argstr='-noise %s', |
| 33 | + mandatory=False, |
| 34 | + desc='noise map') |
| 35 | + out_file = File('dwi_denoised.mif', |
| 36 | + exists=False, |
| 37 | + usedefault=True, |
| 38 | + argstr="%s", |
| 39 | + position=-1, |
| 40 | + desc="the output denoised DWI image") |
| 41 | + |
| 42 | +class DWIDenoiseOutputSpec(TraitedSpec): |
| 43 | + out_file = File(desc="the output denoised DWI image", exists=True) |
| 44 | + |
| 45 | +class DWIDenoise(MRTrix3Base): |
| 46 | + """ |
| 47 | + Denoise DWI data and estimate the noise level based on the optimal |
| 48 | + threshold for PCA. |
| 49 | +
|
| 50 | + DWI data denoising and noise map estimation by exploiting data redundancy |
| 51 | + in the PCA domain using the prior knowledge that the eigenspectrum of |
| 52 | + random covariance matrices is described by the universal Marchenko Pastur |
| 53 | + distribution. |
| 54 | +
|
| 55 | + Important note: image denoising must be performed as the first step of the |
| 56 | + image processing pipeline. The routine will fail if interpolation or |
| 57 | + smoothing has been applied to the data prior to denoising. |
| 58 | +
|
| 59 | + Note that this function does not correct for non-Gaussian noise biases. |
| 60 | +
|
| 61 | + For more information, see |
| 62 | + <https://mrtrix.readthedocs.io/en/latest/reference/commands/dwidenoise.html> |
| 63 | +
|
| 64 | + Example |
| 65 | + ------- |
| 66 | +
|
| 67 | + >>> import nipype.interfaces.mrtrix3 as mrt |
| 68 | + >>> denoise = mrt.DWIDenoise() |
| 69 | + >>> denoise.inputs.in_file = 'dwi.mif' |
| 70 | + >>> denoise.inputs.mask = 'mask.mif' |
| 71 | + >>> denoise.cmdline # doctest: +ELLIPSIS |
| 72 | + 'dwidenoise -mask mask.mif dwi.mif dwi_denoised.mif' |
| 73 | + >>> denoise.run() # doctest: +SKIP |
| 74 | + """ |
| 75 | + |
| 76 | + _cmd = 'dwidenoise' |
| 77 | + input_spec = DWIDenoiseInputSpec |
| 78 | + output_spec = DWIDenoiseOutputSpec |
| 79 | + |
| 80 | + def _list_outputs(self): |
| 81 | + outputs = self.output_spec().get() |
| 82 | + outputs['out_file'] = op.abspath(self.inputs.out_file) |
| 83 | + return outputs |
| 84 | + |
| 85 | + |
14 | 86 | class ResponseSDInputSpec(MRTrix3BaseInputSpec): |
15 | 87 | algorithm = traits.Enum( |
16 | 88 | 'msmt_5tt', |
|
0 commit comments