From bd9d406edbdad3f86bb1dee1c977144f7ed625dc Mon Sep 17 00:00:00 2001 From: Martin Norgaard Date: Fri, 8 Sep 2023 09:59:52 +0200 Subject: [PATCH 1/7] GTMPVC: add extra outputs to outputspec and GTMPVC class --- nipype/interfaces/freesurfer/petsurfer.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/freesurfer/petsurfer.py b/nipype/interfaces/freesurfer/petsurfer.py index 7536fac1a2..754ed48f7a 100644 --- a/nipype/interfaces/freesurfer/petsurfer.py +++ b/nipype/interfaces/freesurfer/petsurfer.py @@ -458,7 +458,21 @@ class GTMPVCOutputSpec(TraitedSpec): yhat_with_noise = File( desc="4D PET file with full FOV of signal estimate (yhat) with noise after PVC (smoothed with PSF)", ) - + eres = File( + desc="4D PET file of residual error after PVC (smoothed with PSF)", + ) + tissue_fraction = File( + desc="4D PET file of tissue fraction before PVC", + ) + tissue_fraction_psf = File( + desc="4D PET file of tissue fraction after PVC (smoothed with PSF)", + ) + seg = File( + desc="Segmentation file of regions used for PVC", + ) + seg_ctab = File( + desc="Color table file for segmentation file", + ) class GTMPVC(FSCommand): """create an anatomical segmentation for the geometric transfer matrix (GTM). @@ -536,6 +550,11 @@ def _list_outputs(self): outputs["gtm_stats"] = os.path.join(pvcdir, "gtm.stats.dat") outputs["reg_pet2anat"] = os.path.join(pvcdir, "aux", "bbpet2anat.lta") outputs["reg_anat2pet"] = os.path.join(pvcdir, "aux", "anat2bbpet.lta") + outputs["eres"] = os.path.join(pvcdir, "eres.nii.gz") + outputs["tissue_fraction"] = os.path.join(pvcdir, "aux", "tissue.fraction.nii.gz") + outputs["tissue_fraction_psf"] = os.path.join(pvcdir, "aux", "tissue.fraction.psf.nii.gz") + outputs["seg"] = os.path.join(pvcdir, "aux", "seg.nii.gz") + outputs["seg_ctab"] = os.path.join(pvcdir, "aux", "seg.ctab") # Assign the conditional outputs if self.inputs.save_input: From ad5e55922c9aeec77dc9b2ce46dcd7b039bd24a6 Mon Sep 17 00:00:00 2001 From: Martin Norgaard Date: Fri, 8 Sep 2023 10:02:07 +0200 Subject: [PATCH 2/7] FIX: update description of GTMPVC interface --- nipype/interfaces/freesurfer/petsurfer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/freesurfer/petsurfer.py b/nipype/interfaces/freesurfer/petsurfer.py index 754ed48f7a..5dac87c17d 100644 --- a/nipype/interfaces/freesurfer/petsurfer.py +++ b/nipype/interfaces/freesurfer/petsurfer.py @@ -475,7 +475,7 @@ class GTMPVCOutputSpec(TraitedSpec): ) class GTMPVC(FSCommand): - """create an anatomical segmentation for the geometric transfer matrix (GTM). + """Perform Partial Volume Correction (PVC) to PET Data. Examples -------- From f66b50ff84fb993b47b6493af83ecae4980dc9b6 Mon Sep 17 00:00:00 2001 From: Martin Norgaard Date: Fri, 8 Sep 2023 10:03:22 +0200 Subject: [PATCH 3/7] ENH: update naming of MRTM interface to MRTM1 (more clear definition) --- nipype/interfaces/freesurfer/petsurfer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nipype/interfaces/freesurfer/petsurfer.py b/nipype/interfaces/freesurfer/petsurfer.py index 5dac87c17d..2ae699d4b5 100644 --- a/nipype/interfaces/freesurfer/petsurfer.py +++ b/nipype/interfaces/freesurfer/petsurfer.py @@ -581,7 +581,7 @@ def _list_outputs(self): return outputs -class MRTMInputSpec(GLMFitInputSpec): +class MRTM1InputSpec(GLMFitInputSpec): mrtm1 = traits.Tuple( File(exists=True), File(exists=True), @@ -591,12 +591,12 @@ class MRTMInputSpec(GLMFitInputSpec): ) -class MRTM(GLMFit): +class MRTM1(GLMFit): """Perform MRTM1 kinetic modeling. Examples -------- - >>> mrtm = MRTM() + >>> mrtm = MRTM1() >>> mrtm.inputs.in_file = 'tac.nii' >>> mrtm.inputs.mrtm1 = ('ref_tac.dat', 'timing.dat') >>> mrtm.inputs.glm_dir = 'mrtm' @@ -604,7 +604,7 @@ class MRTM(GLMFit): 'mri_glmfit --glmdir mrtm --y tac.nii --mrtm1 ref_tac.dat timing.dat' """ - input_spec = MRTMInputSpec + input_spec = MRTM1InputSpec class MRTM2InputSpec(GLMFitInputSpec): From 4df6a4b17cc2c3c9156eb5d350bf379298e5c733 Mon Sep 17 00:00:00 2001 From: Martin Norgaard Date: Fri, 8 Sep 2023 10:05:02 +0200 Subject: [PATCH 4/7] ENH: update LoganRef interface to Logan (reference modeling is not used, so unclear definition) --- nipype/interfaces/freesurfer/petsurfer.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nipype/interfaces/freesurfer/petsurfer.py b/nipype/interfaces/freesurfer/petsurfer.py index 2ae699d4b5..45dbdbdce1 100644 --- a/nipype/interfaces/freesurfer/petsurfer.py +++ b/nipype/interfaces/freesurfer/petsurfer.py @@ -633,7 +633,7 @@ class MRTM2(GLMFit): input_spec = MRTM2InputSpec -class LoganRefInputSpec(GLMFitInputSpec): +class LoganInputSpec(GLMFitInputSpec): logan = traits.Tuple( File(exists=True), File(exists=True), @@ -644,11 +644,11 @@ class LoganRefInputSpec(GLMFitInputSpec): ) -class LoganRef(GLMFit): - """Perform Logan reference kinetic modeling. +class Logan(GLMFit): + """Perform Logan kinetic modeling. Examples -------- - >>> logan = LoganRef() + >>> logan = Logan() >>> logan.inputs.in_file = 'tac.nii' >>> logan.inputs.logan = ('ref_tac.dat', 'timing.dat', 2600) >>> logan.inputs.glm_dir = 'logan' @@ -656,4 +656,4 @@ class LoganRef(GLMFit): 'mri_glmfit --glmdir logan --y tac.nii --logan ref_tac.dat timing.dat 2600' """ - input_spec = LoganRefInputSpec + input_spec = LoganInputSpec From 15eb049841fabb0a05321a0ff27eb932db003ffe Mon Sep 17 00:00:00 2001 From: Martin Norgaard Date: Fri, 8 Sep 2023 10:09:37 +0200 Subject: [PATCH 5/7] ENH: add BP clipping arguments to mri_glmfit --- nipype/interfaces/freesurfer/model.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nipype/interfaces/freesurfer/model.py b/nipype/interfaces/freesurfer/model.py index 1ca0603144..8a5fc8715c 100644 --- a/nipype/interfaces/freesurfer/model.py +++ b/nipype/interfaces/freesurfer/model.py @@ -420,6 +420,14 @@ class GLMFitInputSpec(FSTraitedSpec): argstr="--logan %s %s %f", desc="RefTac TimeSec tstar : perform Logan kinetic modeling", ) + bp_clip_neg = traits.Bool( + argstr="--bp-clip-neg", + desc="set negative BP voxels to zero", + ) + bp_clip_max = traits.Float( + argstr="--bp-clip-max %f", + desc="set BP voxels above max to max", + ) force_perm = traits.Bool( argstr="--perm-force", desc="force perumtation test, even when design matrix is not orthog", From 0df01a757dbd7af25ab05aad5d14ff8c236683c9 Mon Sep 17 00:00:00 2001 From: Anthony Galassi <28850131+bendhouseart@users.noreply.github.com> Date: Tue, 19 Mar 2024 18:41:10 -0400 Subject: [PATCH 6/7] formatted with black --- nipype/interfaces/freesurfer/model.py | 2 +- nipype/interfaces/freesurfer/petsurfer.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/nipype/interfaces/freesurfer/model.py b/nipype/interfaces/freesurfer/model.py index 8a5fc8715c..a7e7e28868 100644 --- a/nipype/interfaces/freesurfer/model.py +++ b/nipype/interfaces/freesurfer/model.py @@ -421,7 +421,7 @@ class GLMFitInputSpec(FSTraitedSpec): desc="RefTac TimeSec tstar : perform Logan kinetic modeling", ) bp_clip_neg = traits.Bool( - argstr="--bp-clip-neg", + argstr="--bp-clip-neg", desc="set negative BP voxels to zero", ) bp_clip_max = traits.Float( diff --git a/nipype/interfaces/freesurfer/petsurfer.py b/nipype/interfaces/freesurfer/petsurfer.py index 45dbdbdce1..b6634a58c5 100644 --- a/nipype/interfaces/freesurfer/petsurfer.py +++ b/nipype/interfaces/freesurfer/petsurfer.py @@ -460,7 +460,7 @@ class GTMPVCOutputSpec(TraitedSpec): ) eres = File( desc="4D PET file of residual error after PVC (smoothed with PSF)", - ) + ) tissue_fraction = File( desc="4D PET file of tissue fraction before PVC", ) @@ -474,6 +474,7 @@ class GTMPVCOutputSpec(TraitedSpec): desc="Color table file for segmentation file", ) + class GTMPVC(FSCommand): """Perform Partial Volume Correction (PVC) to PET Data. @@ -551,8 +552,12 @@ def _list_outputs(self): outputs["reg_pet2anat"] = os.path.join(pvcdir, "aux", "bbpet2anat.lta") outputs["reg_anat2pet"] = os.path.join(pvcdir, "aux", "anat2bbpet.lta") outputs["eres"] = os.path.join(pvcdir, "eres.nii.gz") - outputs["tissue_fraction"] = os.path.join(pvcdir, "aux", "tissue.fraction.nii.gz") - outputs["tissue_fraction_psf"] = os.path.join(pvcdir, "aux", "tissue.fraction.psf.nii.gz") + outputs["tissue_fraction"] = os.path.join( + pvcdir, "aux", "tissue.fraction.nii.gz" + ) + outputs["tissue_fraction_psf"] = os.path.join( + pvcdir, "aux", "tissue.fraction.psf.nii.gz" + ) outputs["seg"] = os.path.join(pvcdir, "aux", "seg.nii.gz") outputs["seg_ctab"] = os.path.join(pvcdir, "aux", "seg.ctab") From 75f0ba0b4ed33c25189eabd7dc77ec4997563847 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 20 Mar 2024 16:03:16 -0400 Subject: [PATCH 7/7] TEST: Update tests --- .../freesurfer/tests/test_auto_GLMFit.py | 6 ++++++ .../freesurfer/tests/test_auto_GTMPVC.py | 15 +++++++++++++++ ...{test_auto_LoganRef.py => test_auto_Logan.py} | 16 +++++++++++----- .../{test_auto_MRTM.py => test_auto_MRTM1.py} | 16 +++++++++++----- .../freesurfer/tests/test_auto_MRTM2.py | 6 ++++++ .../freesurfer/tests/test_auto_OneSampleTTest.py | 6 ++++++ 6 files changed, 55 insertions(+), 10 deletions(-) rename nipype/interfaces/freesurfer/tests/{test_auto_LoganRef.py => test_auto_Logan.py} (95%) rename nipype/interfaces/freesurfer/tests/{test_auto_MRTM.py => test_auto_MRTM1.py} (95%) diff --git a/nipype/interfaces/freesurfer/tests/test_auto_GLMFit.py b/nipype/interfaces/freesurfer/tests/test_auto_GLMFit.py index a950caa7af..4d62a03be6 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_GLMFit.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_GLMFit.py @@ -13,6 +13,12 @@ def test_GLMFit_inputs(): args=dict( argstr="%s", ), + bp_clip_max=dict( + argstr="--bp-clip-max %f", + ), + bp_clip_neg=dict( + argstr="--bp-clip-neg", + ), calc_AR1=dict( argstr="--tar1", ), diff --git a/nipype/interfaces/freesurfer/tests/test_auto_GTMPVC.py b/nipype/interfaces/freesurfer/tests/test_auto_GTMPVC.py index 7f7af1cdb4..99c0002be4 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_GTMPVC.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_GTMPVC.py @@ -207,6 +207,9 @@ def test_GTMPVC_inputs(): def test_GTMPVC_outputs(): output_map = dict( + eres=dict( + extensions=None, + ), gtm_file=dict( extensions=None, ), @@ -256,6 +259,18 @@ def test_GTMPVC_outputs(): reg_rbvpet2anat=dict( extensions=None, ), + seg=dict( + extensions=None, + ), + seg_ctab=dict( + extensions=None, + ), + tissue_fraction=dict( + extensions=None, + ), + tissue_fraction_psf=dict( + extensions=None, + ), yhat=dict( extensions=None, ), diff --git a/nipype/interfaces/freesurfer/tests/test_auto_LoganRef.py b/nipype/interfaces/freesurfer/tests/test_auto_Logan.py similarity index 95% rename from nipype/interfaces/freesurfer/tests/test_auto_LoganRef.py rename to nipype/interfaces/freesurfer/tests/test_auto_Logan.py index c66f460533..34c6dfa6c7 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_LoganRef.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_Logan.py @@ -1,8 +1,8 @@ # AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT -from ..petsurfer import LoganRef +from ..petsurfer import Logan -def test_LoganRef_inputs(): +def test_Logan_inputs(): input_map = dict( allow_ill_cond=dict( argstr="--illcond", @@ -13,6 +13,12 @@ def test_LoganRef_inputs(): args=dict( argstr="%s", ), + bp_clip_max=dict( + argstr="--bp-clip-max %f", + ), + bp_clip_neg=dict( + argstr="--bp-clip-neg", + ), calc_AR1=dict( argstr="--tar1", ), @@ -214,14 +220,14 @@ def test_LoganRef_inputs(): xor=("weight_file", "weight_inv", "weight_sqrt"), ), ) - inputs = LoganRef.input_spec() + inputs = Logan.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_LoganRef_outputs(): +def test_Logan_outputs(): output_map = dict( beta_file=dict( extensions=None, @@ -271,7 +277,7 @@ def test_LoganRef_outputs(): extensions=None, ), ) - outputs = LoganRef.output_spec() + outputs = Logan.output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MRTM.py b/nipype/interfaces/freesurfer/tests/test_auto_MRTM1.py similarity index 95% rename from nipype/interfaces/freesurfer/tests/test_auto_MRTM.py rename to nipype/interfaces/freesurfer/tests/test_auto_MRTM1.py index 18e1dd6961..1637214b9e 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MRTM.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MRTM1.py @@ -1,8 +1,8 @@ # AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT -from ..petsurfer import MRTM +from ..petsurfer import MRTM1 -def test_MRTM_inputs(): +def test_MRTM1_inputs(): input_map = dict( allow_ill_cond=dict( argstr="--illcond", @@ -13,6 +13,12 @@ def test_MRTM_inputs(): args=dict( argstr="%s", ), + bp_clip_max=dict( + argstr="--bp-clip-max %f", + ), + bp_clip_neg=dict( + argstr="--bp-clip-neg", + ), calc_AR1=dict( argstr="--tar1", ), @@ -214,14 +220,14 @@ def test_MRTM_inputs(): xor=("weight_file", "weight_inv", "weight_sqrt"), ), ) - inputs = MRTM.input_spec() + inputs = MRTM1.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_MRTM_outputs(): +def test_MRTM1_outputs(): output_map = dict( beta_file=dict( extensions=None, @@ -271,7 +277,7 @@ def test_MRTM_outputs(): extensions=None, ), ) - outputs = MRTM.output_spec() + outputs = MRTM1.output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MRTM2.py b/nipype/interfaces/freesurfer/tests/test_auto_MRTM2.py index 71b200a600..dea4ca3a92 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MRTM2.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MRTM2.py @@ -13,6 +13,12 @@ def test_MRTM2_inputs(): args=dict( argstr="%s", ), + bp_clip_max=dict( + argstr="--bp-clip-max %f", + ), + bp_clip_neg=dict( + argstr="--bp-clip-neg", + ), calc_AR1=dict( argstr="--tar1", ), diff --git a/nipype/interfaces/freesurfer/tests/test_auto_OneSampleTTest.py b/nipype/interfaces/freesurfer/tests/test_auto_OneSampleTTest.py index eb199ddc50..51b2f2cd0b 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_OneSampleTTest.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_OneSampleTTest.py @@ -13,6 +13,12 @@ def test_OneSampleTTest_inputs(): args=dict( argstr="%s", ), + bp_clip_max=dict( + argstr="--bp-clip-max %f", + ), + bp_clip_neg=dict( + argstr="--bp-clip-neg", + ), calc_AR1=dict( argstr="--tar1", ),