From 0fa255e1cd2d1f25f750036b3581bfc527540e9f Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Sun, 12 Sep 2021 19:40:08 +0200 Subject: [PATCH 01/20] CAT12SANLMDenoising_1st_commit --- nipype/interfaces/cat12/__init__.py | 5 +- nipype/interfaces/cat12/preprocess.py | 136 ++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/cat12/__init__.py b/nipype/interfaces/cat12/__init__.py index 99498dc922..3d83da434d 100644 --- a/nipype/interfaces/cat12/__init__.py +++ b/nipype/interfaces/cat12/__init__.py @@ -1,4 +1,7 @@ -from .preprocess import CAT12Segment +from .preprocess import ( + CAT12Segment, + CAT12SANLMDenoising +) from .surface import ( ExtractAdditionalSurfaceParameters, ExtractROIBasedSurfaceMeasures, diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 5a73f42443..9d164ff1a6 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -593,6 +593,142 @@ def _list_outputs(self): return outputs +class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): + + in_files = InputMultiPath( + ImageFileSPM(exists=True), + field="data", + desc="Images for filtering.", + mandatory=True, + copyfile=False, + ) + + spm_type = traits.Enum( + 16, + 0, + 2, + 512, + field='spm_type', + usedefault=True, + desc='Data type of the output images. 0 = same, 2 = uint8, 512 = uint16, 16 = single (32 bit)' + + ) + + intlim = traits.Int( + field='intlim', + default_value=100, + usedefault=True, + ) + + filename_prefix = traits.Str( + field='prefix', + default_value='sanlm_', + usedefault=True, + desc='Filename prefix. Specify the string to be prepended to the filenames of the filtered image file(s). Default prefix is "samlm_".', + ) + + filename_suffix= traits.Str( + field='suffix', + default_value='', + usedefault=True, + desc='Filename suffix. Specify the string to be appended to the filenames of the filtered image file(s). Default suffix is "".' + ) + + addnoise = traits.Float(default_value=0.5, + usedefault=True, + field='addnoise', + desc='Strength of additional noise in noise-free regions. Add minimal amount of noise in regions without any noise to avoid image segmentation problems. This parameter defines the strength of additional noise as percentage of the average signal intensity.') + + rician = traits.Enum( + 0, + 1, + field='rician', + usedefault=True, + desc='''Rician noise + MRIs can have Gaussian or Rician distributed noise with uniform or nonuniform variance across the image. If SNR is high enough + (>3) noise can be well approximated by Gaussian noise in the foreground. However, for SENSE reconstruction or DTI data a Rician + distribution is expected. Please note that the Rician noise estimation is sensitive for large signals in the neighbourhood and can lead to + artefacts, e.g. cortex can be affected by very high values in the scalp or in blood vessels.''') + + replaceNANandINF = traits.Enum( + 1, + 0, + field='replaceNANandINF', + usedefault=True, + desc='Replace NAN by 0, -INF by the minimum and INF by the maximum of the image.' + ) + + NCstr = traits.Enum( + '-Inf', + 2, + 4, + field='nlmfilter.optimized.NCstr', + usedefault=True, + desc='''Strength of Noise Corrections + Strength of the (sub-resolution) spatial adaptive non local means (SANLM) noise correction. Please note that the filter strength is + automatically estimated. Change this parameter only for specific conditions. The "light" option applies half of the filter strength of the + adaptive "medium" cases, whereas the "strong" option uses the full filter strength, force sub-resolution filtering and applies an + additional iteration. Sub-resolution filtering is only used in case of high image resolution below 0.8 mm or in case of the "strong" + option. light = 2, medium = -Inf, strong = 4''' + ) + + +class CAT12SANLMDenoisingOutputSpec(TraitedSpec): + + out_file = File(desc='out file') + + +class CAT12SANLMDenoising(SPMCommand): + """ + Spatially adaptive non-local means (SANLM) denoising filter + + This function applies an spatial adaptive (sub-resolution) non-local means denoising filter + to the data. This filter will remove noise while preserving edges. The filter strength is + automatically estimated based on the standard deviation of the noise. + + This filter is internally used in the segmentation procedure anyway. Thus, it is not + necessary (and not recommended) to apply the filter before segmentation. + + + Example: + ======= + from nipype.interfaces import cat12 + c = cat12.CAT12SANLMDenoising() + c.inputs.in_files='sub-test_FLAIR.nii' + c.run() + """ + + input_spec = CAT12SANLMDenoisingInputSpec + output_spec = CAT12SANLMDenoisingOutputSpec + + def __init__(self, **inputs): + _local_version = SPMCommand().version + if _local_version and "12." in _local_version: + self._jobtype = "tools" + self._jobname = "cat.tools.sanlm" + + SPMCommand.__init__(self, **inputs) + + def _format_arg(self, opt, spec, val): + """Convert input to appropriate format for spm""" + if opt == "in_files": + if isinstance(val, list): + return scans_for_fnames(val) + else: + return scans_for_fname(val) + + return super(CAT12SANLMDenoising, self)._format_arg(opt, spec, val) + + def _list_outputs(self): + outputs = self._outputs().get() + pth, base, ext = split_filename(self.inputs.in_files[0]) + outputs['out_file'] = os.path.join(os.getcwd(), self.inputs.filename_prefix + + base + + self.inputs.filename_suffix + + ext) + return outputs + + class Cell2Str(Cell): def __str__(self): """Convert input to appropriate format for cat12""" From 76491e75de20be90985ec0b4fd760f482052c532 Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Sun, 12 Sep 2021 20:25:46 +0200 Subject: [PATCH 02/20] example --- nipype/interfaces/cat12/preprocess.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 9d164ff1a6..62fe60d8fe 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -690,12 +690,12 @@ class CAT12SANLMDenoising(SPMCommand): necessary (and not recommended) to apply the filter before segmentation. - Example: - ======= - from nipype.interfaces import cat12 - c = cat12.CAT12SANLMDenoising() - c.inputs.in_files='sub-test_FLAIR.nii' - c.run() + Examples + -------- + >>> from nipype.interfaces import cat12 + >>> c = cat12.CAT12SANLMDenoising() + >>> c.inputs.in_files='sub-test_FLAIR.nii' + >>> c.run() """ input_spec = CAT12SANLMDenoisingInputSpec From c6900411ec08344f5f17f8cba5ab99448dbf0a41 Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Tue, 5 Oct 2021 20:55:57 +0200 Subject: [PATCH 03/20] Updated .zenodo.json --- .zenodo.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.zenodo.json b/.zenodo.json index 83764c5417..e88f5e55ee 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -835,6 +835,11 @@ "affiliation": "MIT, HMS", "name": "Ghosh, Satrajit", "orcid": "0000-0002-5312-6729" + }, + { + "affiliation": "Charite Universitatsmedizin Berlin, Germany", + "name": "Dell\'Orco, Andrea", + "orcid": "0000-0002-3964-8360" } ], "keywords": [ From 15469d5948ff827ec2b5c27732e472a1dad113f9 Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Tue, 5 Oct 2021 21:00:26 +0200 Subject: [PATCH 04/20] Updated .zenodo.json --- .zenodo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zenodo.json b/.zenodo.json index e88f5e55ee..0b2d0f65fb 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -837,7 +837,7 @@ "orcid": "0000-0002-5312-6729" }, { - "affiliation": "Charite Universitatsmedizin Berlin, Germany", + "affiliation": "Charitè Universitätsmedizin Berlin, Germany", "name": "Dell\'Orco, Andrea", "orcid": "0000-0002-3964-8360" } From 57160c9dd93c46939f4a138db00b47793cafcea8 Mon Sep 17 00:00:00 2001 From: orco Date: Tue, 5 Oct 2021 21:13:46 +0200 Subject: [PATCH 05/20] Update nipype/interfaces/cat12/preprocess.py default suffix removed Co-authored-by: Chris Markiewicz --- nipype/interfaces/cat12/preprocess.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 62fe60d8fe..e963a3fa0d 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -624,14 +624,14 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): field='prefix', default_value='sanlm_', usedefault=True, - desc='Filename prefix. Specify the string to be prepended to the filenames of the filtered image file(s). Default prefix is "samlm_".', + desc='Filename prefix. Specify the string to be prepended to the filenames of the filtered image file(s).', ) filename_suffix= traits.Str( field='suffix', default_value='', usedefault=True, - desc='Filename suffix. Specify the string to be appended to the filenames of the filtered image file(s). Default suffix is "".' + desc='Filename suffix. Specify the string to be appended to the filenames of the filtered image file(s).' ) addnoise = traits.Float(default_value=0.5, From 94f6bf98801f4d2759118c29973f44d79198c1b8 Mon Sep 17 00:00:00 2001 From: orco Date: Tue, 5 Oct 2021 21:34:22 +0200 Subject: [PATCH 06/20] Update nipype/interfaces/cat12/preprocess.py Co-authored-by: Chris Markiewicz --- nipype/interfaces/cat12/preprocess.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index e963a3fa0d..4ff3f6e539 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -650,9 +650,8 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): distribution is expected. Please note that the Rician noise estimation is sensitive for large signals in the neighbourhood and can lead to artefacts, e.g. cortex can be affected by very high values in the scalp or in blood vessels.''') - replaceNANandINF = traits.Enum( - 1, - 0, + replaceNANandINF = traits.Bool( + True field='replaceNANandINF', usedefault=True, desc='Replace NAN by 0, -INF by the minimum and INF by the maximum of the image.' From 5766e9d6d17dac95675583a2b05537b28fa18529 Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Tue, 5 Oct 2021 21:39:24 +0200 Subject: [PATCH 07/20] rician as bool --- nipype/interfaces/cat12/preprocess.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 4ff3f6e539..44b0ae2f64 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -627,7 +627,7 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): desc='Filename prefix. Specify the string to be prepended to the filenames of the filtered image file(s).', ) - filename_suffix= traits.Str( + filename_suffix = traits.Str( field='suffix', default_value='', usedefault=True, @@ -639,9 +639,8 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): field='addnoise', desc='Strength of additional noise in noise-free regions. Add minimal amount of noise in regions without any noise to avoid image segmentation problems. This parameter defines the strength of additional noise as percentage of the average signal intensity.') - rician = traits.Enum( - 0, - 1, + rician = traits.Bool( + True, field='rician', usedefault=True, desc='''Rician noise @@ -651,7 +650,7 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): artefacts, e.g. cortex can be affected by very high values in the scalp or in blood vessels.''') replaceNANandINF = traits.Bool( - True + True, field='replaceNANandINF', usedefault=True, desc='Replace NAN by 0, -INF by the minimum and INF by the maximum of the image.' From 0b730027752516e2d8c3a3563d6460cf29f1e9b2 Mon Sep 17 00:00:00 2001 From: orco Date: Tue, 5 Oct 2021 21:39:52 +0200 Subject: [PATCH 08/20] Update nipype/interfaces/cat12/preprocess.py example filename Co-authored-by: Chris Markiewicz --- nipype/interfaces/cat12/preprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 4ff3f6e539..842bc98b11 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -693,7 +693,7 @@ class CAT12SANLMDenoising(SPMCommand): -------- >>> from nipype.interfaces import cat12 >>> c = cat12.CAT12SANLMDenoising() - >>> c.inputs.in_files='sub-test_FLAIR.nii' + >>> c.inputs.in_files='anatomical.nii' >>> c.run() """ From d737a2087f42110fee164b0e0a4e4ae514ec6f7c Mon Sep 17 00:00:00 2001 From: orco Date: Tue, 5 Oct 2021 21:41:03 +0200 Subject: [PATCH 09/20] Update nipype/interfaces/cat12/preprocess.py use fname_presuffix for output file Co-authored-by: Chris Markiewicz --- nipype/interfaces/cat12/preprocess.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 842bc98b11..a6c43d67b4 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -720,11 +720,10 @@ def _format_arg(self, opt, spec, val): def _list_outputs(self): outputs = self._outputs().get() - pth, base, ext = split_filename(self.inputs.in_files[0]) - outputs['out_file'] = os.path.join(os.getcwd(), self.inputs.filename_prefix + - base + - self.inputs.filename_suffix + - ext) + outputs['out_file'] = fname_presuffix(self.inputs.in_files[0], + newpath=os.getcwd(), + prefix=self.inputs.filename_prefix, + suffix=self.inputs.filename_suffix) return outputs From 1dedc71e6ec057f30c0ff7a0152cb8802a115b86 Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Tue, 5 Oct 2021 21:53:42 +0200 Subject: [PATCH 10/20] style --- nipype/interfaces/cat12/preprocess.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 7de78f40f7..39627692cd 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -634,10 +634,11 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): desc='Filename suffix. Specify the string to be appended to the filenames of the filtered image file(s).' ) - addnoise = traits.Float(default_value=0.5, - usedefault=True, - field='addnoise', - desc='Strength of additional noise in noise-free regions. Add minimal amount of noise in regions without any noise to avoid image segmentation problems. This parameter defines the strength of additional noise as percentage of the average signal intensity.') + addnoise = traits.Float( + default_value=0.5, + usedefault=True, + field='addnoise', + desc='Strength of additional noise in noise-free regions. Add minimal amount of noise in regions without any noise to avoid image segmentation problems. This parameter defines the strength of additional noise as percentage of the average signal intensity.') rician = traits.Bool( True, @@ -649,14 +650,14 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): distribution is expected. Please note that the Rician noise estimation is sensitive for large signals in the neighbourhood and can lead to artefacts, e.g. cortex can be affected by very high values in the scalp or in blood vessels.''') - replaceNANandINF = traits.Bool( + replace_nan_and_inf = traits.Bool( True, field='replaceNANandINF', usedefault=True, desc='Replace NAN by 0, -INF by the minimum and INF by the maximum of the image.' ) - NCstr = traits.Enum( + noisecorr_strength = traits.Enum( '-Inf', 2, 4, From aecdacde0775b8baa7bbff87d8ac42616f51050c Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Tue, 5 Oct 2021 21:53:56 +0200 Subject: [PATCH 11/20] non documented variable --- nipype/interfaces/cat12/preprocess.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 39627692cd..fd7f1f165e 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -614,12 +614,6 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): ) - intlim = traits.Int( - field='intlim', - default_value=100, - usedefault=True, - ) - filename_prefix = traits.Str( field='prefix', default_value='sanlm_', From 6d7ba1d5e746abaad053d9b4eae47a9e7264332e Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Tue, 5 Oct 2021 22:24:21 +0200 Subject: [PATCH 12/20] run_black --- nipype/interfaces/cat12/preprocess.py | 83 +++++++++++++++++---------- 1 file changed, 52 insertions(+), 31 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index fd7f1f165e..482ad3c852 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -608,67 +608,79 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): 0, 2, 512, - field='spm_type', + field="spm_type", usedefault=True, - desc='Data type of the output images. 0 = same, 2 = uint8, 512 = uint16, 16 = single (32 bit)' + desc="Data type of the output images. 0 = same, 2 = uint8, 512 = uint16, 16 = single (32 bit)", + ) + intlim = traits.Int( + field="intlim", + default_value=100, + usedefault=True, + desc="intensity limitation (default = 100)", ) filename_prefix = traits.Str( - field='prefix', - default_value='sanlm_', + field="prefix", + default_value="sanlm_", usedefault=True, - desc='Filename prefix. Specify the string to be prepended to the filenames of the filtered image file(s).', + desc="Filename prefix. Specify the string to be prepended to the filenames of the filtered image file(s).", ) filename_suffix = traits.Str( - field='suffix', - default_value='', + field="suffix", + default_value="", usedefault=True, - desc='Filename suffix. Specify the string to be appended to the filenames of the filtered image file(s).' + desc="Filename suffix. Specify the string to be appended to the filenames of the filtered image file(s).", ) addnoise = traits.Float( default_value=0.5, usedefault=True, - field='addnoise', - desc='Strength of additional noise in noise-free regions. Add minimal amount of noise in regions without any noise to avoid image segmentation problems. This parameter defines the strength of additional noise as percentage of the average signal intensity.') + field="addnoise", + desc="""Strength of additional noise in noise-free regions. + Add minimal amount of noise in regions without any noise to avoid image segmentation problems. + This parameter defines the strength of additional noise as percentage of the average signal intensity.""", + ) rician = traits.Bool( True, - field='rician', + field="rician", usedefault=True, - desc='''Rician noise - MRIs can have Gaussian or Rician distributed noise with uniform or nonuniform variance across the image. If SNR is high enough - (>3) noise can be well approximated by Gaussian noise in the foreground. However, for SENSE reconstruction or DTI data a Rician - distribution is expected. Please note that the Rician noise estimation is sensitive for large signals in the neighbourhood and can lead to - artefacts, e.g. cortex can be affected by very high values in the scalp or in blood vessels.''') + desc="""Rician noise + MRIs can have Gaussian or Rician distributed noise with uniform or nonuniform variance across the image. + If SNR is high enough (>3) noise can be well approximated by Gaussian noise in the foreground. However, for + SENSE reconstruction or DTI data a Rician distribution is expected. Please note that the Rician noise estimation + is sensitive for large signals in the neighbourhood and can lead to artefacts, e.g. cortex can be affected by + very high values in the scalp or in blood vessels.""", + ) replace_nan_and_inf = traits.Bool( True, - field='replaceNANandINF', + field="replaceNANandINF", usedefault=True, - desc='Replace NAN by 0, -INF by the minimum and INF by the maximum of the image.' + desc="Replace NAN by 0, -INF by the minimum and INF by the maximum of the image.", ) noisecorr_strength = traits.Enum( - '-Inf', + "-Inf", 2, 4, - field='nlmfilter.optimized.NCstr', + field="nlmfilter.optimized.NCstr", usedefault=True, - desc='''Strength of Noise Corrections - Strength of the (sub-resolution) spatial adaptive non local means (SANLM) noise correction. Please note that the filter strength is - automatically estimated. Change this parameter only for specific conditions. The "light" option applies half of the filter strength of the - adaptive "medium" cases, whereas the "strong" option uses the full filter strength, force sub-resolution filtering and applies an - additional iteration. Sub-resolution filtering is only used in case of high image resolution below 0.8 mm or in case of the "strong" - option. light = 2, medium = -Inf, strong = 4''' + desc="""Strength of Noise Corrections + Strength of the (sub-resolution) spatial adaptive non local means (SANLM) noise correction. Please note + that the filter strength is automatically estimated. Change this parameter only for specific conditions. The + "light" option applies half of the filter strength of the adaptive "medium" cases, whereas the "strong" + option uses the full filter strength, force sub-resolution filtering and applies an additional iteration. + Sub-resolution filtering is only used in case of high image resolution below 0.8 mm or in case of the + "strong" option. light = 2, medium = -Inf, strong = 4""", ) class CAT12SANLMDenoisingOutputSpec(TraitedSpec): - out_file = File(desc='out file') + out_file = File(desc="out file") class CAT12SANLMDenoising(SPMCommand): @@ -682,6 +694,13 @@ class CAT12SANLMDenoising(SPMCommand): This filter is internally used in the segmentation procedure anyway. Thus, it is not necessary (and not recommended) to apply the filter before segmentation. + ______________________________________________________________________ + Christian Gaser, Robert Dahnke + Structural Brain Mapping Group (http://www.neuro.uni-jena.de) + Departments of Neurology and Psychiatry + Jena University Hospital + ______________________________________________________________________ + Examples -------- @@ -714,10 +733,12 @@ def _format_arg(self, opt, spec, val): def _list_outputs(self): outputs = self._outputs().get() - outputs['out_file'] = fname_presuffix(self.inputs.in_files[0], - newpath=os.getcwd(), - prefix=self.inputs.filename_prefix, - suffix=self.inputs.filename_suffix) + outputs["out_file"] = fname_presuffix( + self.inputs.in_files[0], + newpath=os.getcwd(), + prefix=self.inputs.filename_prefix, + suffix=self.inputs.filename_suffix, + ) return outputs From 58974f66f515f135d033dce5a99020a5221964d9 Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Tue, 5 Oct 2021 22:44:49 +0200 Subject: [PATCH 13/20] fix --- nipype/interfaces/cat12/preprocess.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 482ad3c852..34cbe91491 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -638,8 +638,8 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): default_value=0.5, usedefault=True, field="addnoise", - desc="""Strength of additional noise in noise-free regions. - Add minimal amount of noise in regions without any noise to avoid image segmentation problems. + desc="""Strength of additional noise in noise-free regions. + Add minimal amount of noise in regions without any noise to avoid image segmentation problems. This parameter defines the strength of additional noise as percentage of the average signal intensity.""", ) @@ -648,10 +648,10 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): field="rician", usedefault=True, desc="""Rician noise - MRIs can have Gaussian or Rician distributed noise with uniform or nonuniform variance across the image. - If SNR is high enough (>3) noise can be well approximated by Gaussian noise in the foreground. However, for - SENSE reconstruction or DTI data a Rician distribution is expected. Please note that the Rician noise estimation - is sensitive for large signals in the neighbourhood and can lead to artefacts, e.g. cortex can be affected by + MRIs can have Gaussian or Rician distributed noise with uniform or nonuniform variance across the image. + If SNR is high enough (>3) noise can be well approximated by Gaussian noise in the foreground. However, for + SENSE reconstruction or DTI data a Rician distribution is expected. Please note that the Rician noise estimation + is sensitive for large signals in the neighbourhood and can lead to artefacts, e.g. cortex can be affected by very high values in the scalp or in blood vessels.""", ) @@ -669,11 +669,11 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): field="nlmfilter.optimized.NCstr", usedefault=True, desc="""Strength of Noise Corrections - Strength of the (sub-resolution) spatial adaptive non local means (SANLM) noise correction. Please note - that the filter strength is automatically estimated. Change this parameter only for specific conditions. The - "light" option applies half of the filter strength of the adaptive "medium" cases, whereas the "strong" + Strength of the (sub-resolution) spatial adaptive non local means (SANLM) noise correction. Please note + that the filter strength is automatically estimated. Change this parameter only for specific conditions. The + "light" option applies half of the filter strength of the adaptive "medium" cases, whereas the "strong" option uses the full filter strength, force sub-resolution filtering and applies an additional iteration. - Sub-resolution filtering is only used in case of high image resolution below 0.8 mm or in case of the + Sub-resolution filtering is only used in case of high image resolution below 0.8 mm or in case of the "strong" option. light = 2, medium = -Inf, strong = 4""", ) From 70f193f9c7a83ddc1c3cac42a482feff515ad1aa Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Tue, 5 Oct 2021 23:00:46 +0200 Subject: [PATCH 14/20] black __init__.py --- nipype/interfaces/cat12/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nipype/interfaces/cat12/__init__.py b/nipype/interfaces/cat12/__init__.py index 3d83da434d..40059b23e1 100644 --- a/nipype/interfaces/cat12/__init__.py +++ b/nipype/interfaces/cat12/__init__.py @@ -1,7 +1,4 @@ -from .preprocess import ( - CAT12Segment, - CAT12SANLMDenoising -) +from .preprocess import CAT12Segment, CAT12SANLMDenoising from .surface import ( ExtractAdditionalSurfaceParameters, ExtractROIBasedSurfaceMeasures, From 3e3ba8733d615cff0256532df85f48b766b988ad Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Tue, 5 Oct 2021 23:14:09 +0200 Subject: [PATCH 15/20] example_skip --- nipype/interfaces/cat12/preprocess.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 34cbe91491..33ec9ff205 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -693,7 +693,6 @@ class CAT12SANLMDenoising(SPMCommand): This filter is internally used in the segmentation procedure anyway. Thus, it is not necessary (and not recommended) to apply the filter before segmentation. - ______________________________________________________________________ Christian Gaser, Robert Dahnke Structural Brain Mapping Group (http://www.neuro.uni-jena.de) @@ -701,13 +700,12 @@ class CAT12SANLMDenoising(SPMCommand): Jena University Hospital ______________________________________________________________________ - Examples -------- >>> from nipype.interfaces import cat12 >>> c = cat12.CAT12SANLMDenoising() - >>> c.inputs.in_files='anatomical.nii' - >>> c.run() + >>> c.inputs.in_files = 'anatomical.nii' + >>> c.run() # doctest: +SKIP """ input_spec = CAT12SANLMDenoisingInputSpec From 329e9be229f8ef98bb245ca646927b647b7a1f95 Mon Sep 17 00:00:00 2001 From: orco Date: Sun, 17 Oct 2021 20:47:22 +0200 Subject: [PATCH 16/20] Update nipype/interfaces/cat12/preprocess.py Co-authored-by: Chris Markiewicz --- nipype/interfaces/cat12/preprocess.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 33ec9ff205..998202019a 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -604,13 +604,13 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): ) spm_type = traits.Enum( - 16, - 0, - 2, - 512, + "float32", + "uint16", + "uint8" + "same", field="spm_type", usedefault=True, - desc="Data type of the output images. 0 = same, 2 = uint8, 512 = uint16, 16 = single (32 bit)", + desc="Data type of the output images. 'same' matches the input image type.", ) intlim = traits.Int( From 1809526eac171a89588485a711b49d83d8e18347 Mon Sep 17 00:00:00 2001 From: orco Date: Sun, 17 Oct 2021 20:47:32 +0200 Subject: [PATCH 17/20] Update nipype/interfaces/cat12/preprocess.py Co-authored-by: Chris Markiewicz --- nipype/interfaces/cat12/preprocess.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 998202019a..09ad16b6d9 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -726,7 +726,9 @@ def _format_arg(self, opt, spec, val): return scans_for_fnames(val) else: return scans_for_fname(val) - + if opt == "spm_type": + type_map = {"same": 0, "uint8": 2, "uint16": 512, "float32": 16} + val = type_map[val] return super(CAT12SANLMDenoising, self)._format_arg(opt, spec, val) def _list_outputs(self): From c27823960108245887d9fec7a61654bf16d182cf Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Sun, 17 Oct 2021 20:48:39 +0200 Subject: [PATCH 18/20] make_specs --- .../tests/test_auto_CAT12SANLMDenoising.py | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 nipype/interfaces/cat12/tests/test_auto_CAT12SANLMDenoising.py diff --git a/nipype/interfaces/cat12/tests/test_auto_CAT12SANLMDenoising.py b/nipype/interfaces/cat12/tests/test_auto_CAT12SANLMDenoising.py new file mode 100644 index 0000000000..43c0d5e4ea --- /dev/null +++ b/nipype/interfaces/cat12/tests/test_auto_CAT12SANLMDenoising.py @@ -0,0 +1,72 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ..preprocess import CAT12SANLMDenoising + + +def test_CAT12SANLMDenoising_inputs(): + input_map = dict( + addnoise=dict( + field="addnoise", + usedefault=True, + ), + filename_prefix=dict( + field="prefix", + usedefault=True, + ), + filename_suffix=dict( + field="suffix", + usedefault=True, + ), + in_files=dict( + copyfile=False, + field="data", + mandatory=True, + ), + intlim=dict( + field="intlim", + usedefault=True, + ), + matlab_cmd=dict(), + mfile=dict( + usedefault=True, + ), + noisecorr_strength=dict( + field="nlmfilter.optimized.NCstr", + usedefault=True, + ), + paths=dict(), + replace_nan_and_inf=dict( + field="replaceNANandINF", + usedefault=True, + ), + rician=dict( + field="rician", + usedefault=True, + ), + spm_type=dict( + field="spm_type", + usedefault=True, + ), + use_mcr=dict(), + use_v8struct=dict( + min_ver="8", + usedefault=True, + ), + ) + inputs = CAT12SANLMDenoising.input_spec() + + for key, metadata in list(input_map.items()): + for metakey, value in list(metadata.items()): + assert getattr(inputs.traits()[key], metakey) == value + + +def test_CAT12SANLMDenoising_outputs(): + output_map = dict( + out_file=dict( + extensions=None, + ), + ) + outputs = CAT12SANLMDenoising.output_spec() + + for key, metadata in list(output_map.items()): + for metakey, value in list(metadata.items()): + assert getattr(outputs.traits()[key], metakey) == value From cdb064d6caa90d00537520c97679bde6fc2c2646 Mon Sep 17 00:00:00 2001 From: 0rC0 Date: Mon, 18 Oct 2021 19:51:43 +0200 Subject: [PATCH 19/20] black --- nipype/interfaces/cat12/preprocess.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index 09ad16b6d9..b6b6943fef 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -606,8 +606,7 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): spm_type = traits.Enum( "float32", "uint16", - "uint8" - "same", + "uint8" "same", field="spm_type", usedefault=True, desc="Data type of the output images. 'same' matches the input image type.", From 2dfea7acc5283a0821a97a5eaed22babd6da0e30 Mon Sep 17 00:00:00 2001 From: orco Date: Mon, 18 Oct 2021 20:06:10 +0200 Subject: [PATCH 20/20] Update nipype/interfaces/cat12/preprocess.py Co-authored-by: Chris Markiewicz --- nipype/interfaces/cat12/preprocess.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/cat12/preprocess.py b/nipype/interfaces/cat12/preprocess.py index b6b6943fef..69fe16b752 100644 --- a/nipype/interfaces/cat12/preprocess.py +++ b/nipype/interfaces/cat12/preprocess.py @@ -606,7 +606,8 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec): spm_type = traits.Enum( "float32", "uint16", - "uint8" "same", + "uint8", + "same", field="spm_type", usedefault=True, desc="Data type of the output images. 'same' matches the input image type.",