Skip to content

Commit 4e6817f

Browse files
stymychrisgorgo
authored andcommitted
fixed AutoTcorrelate and _list_outputs
1 parent 8d4c637 commit 4e6817f

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

nipype/interfaces/afni/base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,20 @@ def _overload_extension(self, value):
218218
path, base, _ = split_filename(value)
219219
return os.path.join(path, base + Info.outputtype_to_ext(self.inputs.outputtype))
220220

221+
def _list_outputs(self):
222+
metadata = dict(name_source=lambda t: t is not None)
223+
out_names = self.inputs.traits(**metadata).keys()
224+
if out_names:
225+
outputs = self.output_spec().get()
226+
for name in out_names:
227+
out = self._gen_filename(name)
228+
if out.startswith("/"):
229+
outputs[name]
230+
else:
231+
path,_,_ = split_filename(getattr(self.inputs,self.inputs.trait(name).name_source))
232+
outputs[name] = os.path.join(path, self._gen_filename(name))
233+
return outputs
234+
221235

222236
class AFNIPrefixOutputSpec(TraitedSpec):
223237
out_file = File(desc='output file',

nipype/interfaces/afni/preprocess.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,16 @@ class AutoTcorrelateInputSpec(AFNIPrefixInputSpec):
316316
mandatory=True,
317317
exists=True)
318318

319-
out_file = File("%s_similarity_matrix", desc='output image file name',
319+
polort = traits.Int(desc='Remove polynomical trend of order m or -1 for no detrending',
320+
argstr="-polort %d")
321+
eta2 = traits.Bool(desc='eta^2 similarity',
322+
argstr="-eta2")
323+
mask = File(exists=True, desc="mask of voxels",
324+
argstr="-mask %s")
325+
mask_only_targets = traits.Bool(desc="use mask only on targets voxels",
326+
argstr="-mask_only_targets")
327+
328+
out_file = File("%s_similarity_matrix.1D", desc='output image file name',
320329
argstr='-prefix %s', name_source="in_file", usedefault=True)
321330

322331
class AutoTcorrelateOutputSpec(TraitedSpec):
@@ -331,14 +340,23 @@ class AutoTcorrelate(AFNIPrefixCommand):
331340
>>> from nipype.interfaces import afni as afni
332341
>>> corr = afni.AutoTcorrelate()
333342
>>> corr.inputs.in_file = 'functional.nii'
334-
>>> corr.inputs.outputtype = "NIFTI"
343+
>>> corr.inputs.polort = -1
344+
>>> corr.inputs.eta2 = True
345+
>>> corr.inputs.mask = 'mask.nii'
346+
>>> corr.inputs.mask_only_targets = True
335347
>>> corr.cmdline
336-
'3dAutoTcorrelation -prefix functional_similarity_matrix.nii functional.nii'
348+
'3dAutoTcorrelation -prefix functional_similarity_matrix.1D functional.nii'
337349
>>> res = corr.run() # doctest: +SKIP
338350
"""
339351
input_spec = AutoTcorrelateInputSpec
340352
output_spec = AutoTcorrelateOutputSpec
341-
_cmd = '3dAutoTcorrelation'
353+
_cmd = '3dAutoTcorrelate'
354+
355+
def _overload_extension(self, value):
356+
path, base, ext = split_filename(value)
357+
if ext.lower() not in [".1d", ".nii.gz", ".nii"]:
358+
ext = ext + ".1D"
359+
return os.path.join(path, base + ext)
342360

343361

344362
class TStatInputSpec(AFNIPrefixInputSpec):

nipype/interfaces/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ def _format_arg(self, name, trait_spec, value):
11951195
else:
11961196
return argstr % sep.join(str(elt) for elt in value)
11971197
elif trait_spec.name_source:
1198-
return self._gen_filename(name)
1198+
return argstr % self._gen_filename(name)
11991199
else:
12001200
# Append options using format string.
12011201
return argstr % value
@@ -1214,9 +1214,9 @@ def _gen_filename(self, name):
12141214
raise NotImplementedError
12151215

12161216
if trait_spec.keep_extension:
1217-
return argstr % retval
1217+
return retval
12181218
else:
1219-
return argstr % self._overload_extension(retval)
1219+
return self._overload_extension(retval)
12201220

12211221
def _overload_extension(self, value):
12221222
return value
@@ -1227,7 +1227,7 @@ def _list_outputs(self):
12271227
if out_names:
12281228
outputs = self.output_spec().get()
12291229
for name in out_names:
1230-
outputs[name] = os.path.abspath(self._gen_out_fname(name))
1230+
outputs[name] = os.path.abspath(self._gen_filename(name))
12311231
return outputs
12321232

12331233
def _parse_inputs(self, skip=None):

0 commit comments

Comments
 (0)