Skip to content

Commit

Permalink
FIX Issue nipy#3654: added missing input traits for templates, correc…
Browse files Browse the repository at this point in the history
…ted if statements for when no surface or ROI estimations are desired
  • Loading branch information
Oweda committed Jun 14, 2024
1 parent 3f9a039 commit 839931f
Showing 1 changed file with 62 additions and 30 deletions.
92 changes: 62 additions & 30 deletions nipype/interfaces/cat12/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,46 +225,86 @@ class CAT12SegmentInputSpec(SPMCommandInputSpec):
" are not available as batch dependencies objects. "
)
surface_and_thickness_estimation = traits.Int(
1, field="surface", desc=_help_surf, usedefault=True
1, field="output.surface", desc=_help_surf, usedefault=True
)
surface_measures = traits.Int(
1,
field="output.surf_measures",
usedefault=True,
# usedefault=True,
desc="Extract surface measures",
# requires=["neuromorphometrics", "lpba40", "cobra", "hammers", "thalamus", "thalamic_nuclei", "suit", "ibsr"],
# xor=["noROI"],
)

# Templates
neuromorphometrics = traits.Bool(
True,
field="output.ROImenu.atlases.neuromorphometrics",
usedefault=True,
# usedefault=True,
desc="Extract brain measures for Neuromorphometrics template",
xor=["noROI"],
)
lpba40 = traits.Bool(
True,
field="output.ROImenu.atlases.lpba40",
usedefault=True,
# usedefault=True,
desc="Extract brain measures for LPBA40 template",
xor=["noROI"],
)
cobra = traits.Bool(
True,
field="output.ROImenu.atlases.hammers",
usedefault=True,
# usedefault=True,
desc="Extract brain measures for COBRA template",
xor=["noROI"],
)
hammers = traits.Bool(
True,
False,
field="output.ROImenu.atlases.cobra",
usedefault=True,
# usedefault=True,
desc="Extract brain measures for Hammers template",
xor=["noROI"],
)
thalamus = traits.Bool(
True,
field="output.ROImenu.atlases.thalamus",
# usedefault=True,
desc="Extract brain measures for Thalamus template",
xor=["noROI"],
)
thalamic_nuclei = traits.Bool(
True,
field="output.ROImenu.atlases.thalamaic_nuclei",
# usedefault=True,
desc="Extract brain measures for Thalamic Nuclei template",
xor=["noROI"],
)
suit = traits.Bool(
True,
field="output.ROImenu.atlases.suit",
# usedefault=True,
desc="Extract brain measures for Suit template",
xor=["noROI"],
)
ibsr = traits.Bool(
False,
field="output.ROImenu.atlases.ibsr",
# usedefault=True,
desc="Extract brain measures for IBSR template",
xor=["noROI"],
)
own_atlas = InputMultiPath(
ImageFileSPM(exists=True),
field="output.ROImenu.atlases.ownatlas",
desc="Extract brain measures for a given template",
mandatory=False,
copyfile=False,
xor=["noROI"],
)
noROI = traits.Bool(
field="output.ROImenu.noROI",
desc="Select if no ROI analysis needed",
xor=["neuromorphometrics", "lpba40", "cobra", "hammers", "thalamus", "thalamic_nuclei", "suit", "ibsr"],
)

# Grey matter
Expand Down Expand Up @@ -524,13 +564,6 @@ def _format_arg(self, opt, spec, val):
return scans_for_fname(val)
elif opt in ["tpm", "shooting_tpm"]:
return Cell2Str(val)

if opt == "surface_measures":
if not self.inputs.surface_measures:
self.inputs.neuromorphometrics = False
self.inputs.lpba40 = False
self.inputs.cobra = False
self.inputs.hammers = False

return super()._format_arg(opt, spec, val)

Expand Down Expand Up @@ -560,22 +593,22 @@ def _list_outputs(self):

if self.inputs.save_bias_corrected:
outputs["bias_corrected_image"] = fname_presuffix(
f, prefix=os.path.join("mri", "wmi")
f, prefix=os.path.join("mri", "wm")
)

outputs["surface_files"] = [
str(surf) for surf in Path(pth).glob("surf/*") if surf.is_file()
]

for hemisphere in ["rh", "lh"]:
for suffix in ["central", "sphere"]:
outfield = f"{hemisphere}_{suffix}_surface"
outputs[outfield] = fname_presuffix(
f,
prefix=os.path.join("surf", f"{hemisphere}.{suffix}."),
suffix=".gii",
use_ext=False,
)
if self.inputs.surface_and_thickness_estimation:
outputs["surface_files"] = [
str(surf) for surf in Path(pth).glob("surf/*") if surf.is_file()
]
for hemisphere in ["rh", "lh"]:
for suffix in ["central", "sphere"]:
outfield = f"{hemisphere}_{suffix}_surface"
outputs[outfield] = fname_presuffix(
f,
prefix=os.path.join("surf", f"{hemisphere}.{suffix}."),
suffix=".gii",
use_ext=False,
)

outputs["report_files"] = outputs["report_files"] = [
str(report) for report in Path(pth).glob("report/*") if report.is_file()
Expand All @@ -589,11 +622,10 @@ def _list_outputs(self):
str(label) for label in Path(pth).glob("label/*") if label.is_file()
]

if self.inputs.surface_measures:
if self.inputs.noROI:
outputs["label_rois"] = fname_presuffix(
f, prefix=os.path.join("label", "catROIs_"), suffix=".xml", use_ext=False
)
else:
outputs["label_roi"] = fname_presuffix(
f, prefix=os.path.join("label", "catROI_"), suffix=".xml", use_ext=False
)
Expand Down

0 comments on commit 839931f

Please sign in to comment.