Skip to content
Prev Previous commit
Next Next commit
FIX #3653: added option for using compressed files as inputs in CAT12…
… interface
  • Loading branch information
Oweda authored and effigies committed Oct 6, 2024
commit 035bf8d0979aa4af2ac96cd9a3088abe0f4d117c
8 changes: 6 additions & 2 deletions nipype/interfaces/cat12/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
isdefined,
File,
Str,
ImageFile,
)
from nipype.interfaces.cat12.base import Cell

Expand All @@ -24,7 +25,7 @@

class CAT12SegmentInputSpec(SPMCommandInputSpec):
in_files = InputMultiPath(
ImageFileSPM(exists=True),
ImageFile(exists=True),
field="data",
desc="file to segment",
mandatory=True,
Expand Down Expand Up @@ -560,6 +561,8 @@ def _format_arg(self, opt, spec, val):
"""Convert input to appropriate format for spm"""
if opt == "in_files":
if isinstance(val, list):
if '.nii.gz' in val[0]:
return scans_for_fnames(val, keep4d=True)
return scans_for_fnames(val)
else:
return scans_for_fname(val)
Expand All @@ -572,7 +575,8 @@ def _list_outputs(self):
outputs = self._outputs().get()
f = self.inputs.in_files[0]
pth, base, ext = split_filename(f)

if '.nii.gz' in f:
f = f[:-3]
outputs["mri_images"] = [
str(mri) for mri in Path(pth).glob("mri/*") if mri.is_file()
]
Expand Down