Skip to content

Commit

Permalink
FIX #3653: added option for using compressed files as inputs in CAT12…
Browse files Browse the repository at this point in the history
… interface
  • Loading branch information
Oweda authored and effigies committed Oct 6, 2024
1 parent 511ea71 commit 035bf8d
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 035bf8d

Please sign in to comment.