Skip to content

Commit 043370b

Browse files
committed
Bugfixes, don't overlad extensions by default.
1 parent 4e6817f commit 043370b

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

nipype/interfaces/afni/base.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,7 @@ def _list_outputs(self):
225225
outputs = self.output_spec().get()
226226
for name in out_names:
227227
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))
228+
outputs[name] = os.path.abspath(out)
233229
return outputs
234230

235231

nipype/interfaces/afni/preprocess.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,13 @@ class AutoTcorrelate(AFNIPrefixCommand):
340340
>>> from nipype.interfaces import afni as afni
341341
>>> corr = afni.AutoTcorrelate()
342342
>>> corr.inputs.in_file = 'functional.nii'
343+
>>> corr.inputs.out_file = 'my_similarity_matrix.1D'
343344
>>> corr.inputs.polort = -1
344345
>>> corr.inputs.eta2 = True
345346
>>> corr.inputs.mask = 'mask.nii'
346347
>>> corr.inputs.mask_only_targets = True
347-
>>> corr.cmdline
348-
'3dAutoTcorrelation -prefix functional_similarity_matrix.1D functional.nii'
348+
>>> corr.cmdline # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
349+
'3dAutoTcorrelate -eta2 -mask mask.nii -mask_only_targets -prefix ...my_similarity_matrix.1D -polort -1 functional.nii'
349350
>>> res = corr.run() # doctest: +SKIP
350351
"""
351352
input_spec = AutoTcorrelateInputSpec
@@ -358,6 +359,8 @@ def _overload_extension(self, value):
358359
ext = ext + ".1D"
359360
return os.path.join(path, base + ext)
360361

362+
def _gen_filename(self, name):
363+
return os.path.abspath(super(AutoTcorrelate, self)._gen_filename(name))
361364

362365
class TStatInputSpec(AFNIPrefixInputSpec):
363366
in_file = File(desc='input file to 3dTstat',
@@ -861,8 +864,8 @@ class MaskaveInputSpec(AFNIPrefixInputSpec):
861864
position=-2,
862865
mandatory=True,
863866
exists=True)
864-
out_file = File("%s_maskave", desc='output image file name',
865-
argstr='-prefix %s', name_source="in_file", usedefault=True)
867+
out_file = File("%s_maskave.1D", desc='output image file name',
868+
argstr="> %s", name_source="in_file", usedefault=True, position=-1)
866869
mask = File(desc='matrix to align input file',
867870
argstr='-mask %s',
868871
position=1,
@@ -892,7 +895,8 @@ class Maskave(AFNIPrefixCommand):
892895
>>> maskave.inputs.in_file = 'functional.nii'
893896
>>> maskave.inputs.mask= 'seed_mask.nii'
894897
>>> maskave.inputs.quiet= True
895-
>>> maskave.inputs.out_file= 'maskave.1D'
898+
>>> maskave.cmdline
899+
'3dmaskave -mask seed_mask.nii -quiet functional.nii > functional_maskave.1D'
896900
>>> res = maskave.run() # doctest: +SKIP
897901
898902
"""
@@ -987,7 +991,7 @@ class FimInputSpec(AFNIPrefixInputSpec):
987991
mandatory=True,
988992
exists=True)
989993
out_file = File("%s_fim", desc='output image file name',
990-
argstr='-prefix %s', name_source="in_file", usedefault=True)
994+
argstr='-bucket %s', name_source="in_file", usedefault=True)
991995
ideal_file = File(desc='ideal time series file name',
992996
argstr='-ideal_file %s',
993997
position=2,
@@ -1283,7 +1287,7 @@ class Calc(AFNIPrefixCommand):
12831287
>>> calc.inputs.out_file = 'functional_calc.nii.gz'
12841288
>>> calc.inputs.outputtype = "NIFTI"
12851289
>>> calc.cmdline
1286-
'3dcalc -a functional.nii -b functional2.nii -expr "a*b" -prefix functional_calc.nii'
1290+
'3dcalc -a functional.nii -b functional2.nii -expr "a*b" -prefix functional_calc.nii.gz'
12871291
12881292
"""
12891293

nipype/interfaces/afni/tests/test_preprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_fim():
117117
ignore_exception = dict(usedefault=True,),
118118
in_file = dict(argstr=' -input %s',mandatory=True,),
119119
out = dict(argstr='-out %s',),
120-
out_file = dict(argstr='-prefix %s'),
120+
out_file = dict(argstr='-bucket %s'),
121121
outputtype = dict(),
122122
)
123123
instance = afni.Fim()
@@ -346,7 +346,7 @@ def test_maskave():
346346
ignore_exception = dict(usedefault=True,),
347347
in_file = dict(argstr='%s',mandatory=True,),
348348
mask = dict(argstr='-mask %s',),
349-
out_file = dict(argstr='-prefix %s',),
349+
out_file = dict(argstr='> %s',),
350350
outputtype = dict(),
351351
quiet = dict(argstr='-quiet',),
352352
)

nipype/interfaces/base.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,6 @@ def _format_arg(self, name, trait_spec, value):
12021202

12031203
def _gen_filename(self, name):
12041204
trait_spec = self.inputs.trait(name)
1205-
argstr = trait_spec.argstr
12061205
value = getattr(self.inputs, name)
12071206
if isdefined(value):
12081207
if "%s" in value:
@@ -1212,11 +1211,11 @@ def _gen_filename(self, name):
12121211
retval = value
12131212
else:
12141213
raise NotImplementedError
1215-
1216-
if trait_spec.keep_extension:
1217-
return retval
1218-
else:
1214+
_,_,ext = split_filename(retval)
1215+
if trait_spec.overload_extension or not ext:
12191216
return self._overload_extension(retval)
1217+
else:
1218+
return retval
12201219

12211220
def _overload_extension(self, value):
12221221
return value

0 commit comments

Comments
 (0)