Skip to content

Commit

Permalink
FIX nipy#3653: added option for using compressed files as inputs in C…
Browse files Browse the repository at this point in the history
…AT12 interface
  • Loading branch information
Oweda committed Jun 24, 2024
1 parent 8c2a4ba commit d91f6d2
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 @@ -8,6 +8,7 @@
isdefined,
File,
Str,
ImageFile,
)
from nipype.interfaces.cat12.base import Cell

Expand All @@ -23,7 +24,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 @@ -559,6 +560,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 @@ -571,7 +574,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 d91f6d2

Please sign in to comment.