Skip to content

Commit c4d1d8a

Browse files
committed
Merge pull request #504 from bpinsard/bug/afni
fixing wrong output directory in afni base gen_filename
2 parents 33d72e7 + cd74c05 commit c4d1d8a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

nipype/interfaces/afni/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ def _gen_filename(self, name):
216216

217217
_, base, _ = split_filename(
218218
getattr(self.inputs, trait_spec.name_source))
219-
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd='')
219+
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd=os.getcwd())
220220
else:
221-
return super(AFNICommand, self)._gen_filename(name)
221+
return os.path.join(os.getcwd(),
222+
super(AFNICommand, self)._gen_filename(name))
222223

223224
def _overload_extension(self, value):
224225
path, base, _ = split_filename(value)
@@ -231,7 +232,8 @@ def _list_outputs(self):
231232
outputs = self.output_spec().get()
232233
for name in out_names:
233234
out = self._gen_filename(name)
234-
outputs[name] = os.path.abspath(out)
235+
if isdefined(out):
236+
outputs[name] = os.path.abspath(out)
235237
return outputs
236238

237239

nipype/interfaces/afni/preprocess.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import os
1313
from .base import AFNIBaseCommandInputSpec, AFNIBaseCommand
1414
from ..base import (Directory, CommandLineInputSpec, CommandLine, TraitedSpec,
15-
traits, isdefined, File, InputMultiPath)
15+
traits, isdefined, File, InputMultiPath, Undefined)
1616
from ...utils.filemanip import (load_json, save_json, split_filename)
1717
from nipype.utils.filemanip import fname_presuffix
1818
from nipype.interfaces.afni.base import AFNICommand, AFNICommandInputSpec,\
@@ -280,7 +280,7 @@ class ResampleInputSpec(AFNICommandInputSpec):
280280
argstr='-orient %s')
281281

282282

283-
class Resample(AFNIBaseCommand):
283+
class Resample(AFNICommand):
284284
"""Resample or reorient an image using AFNI 3dresample command
285285
286286
For complete details, see the `3dresample Documentation.
@@ -534,7 +534,7 @@ def _gen_filename(self, name):
534534

535535
_, base, _ = split_filename(
536536
getattr(self.inputs, trait_spec.name_source))
537-
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd='')
537+
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd=os.getcwd())
538538
elif name == "brain_file" and isdefined(self.inputs.apply_suffix):
539539
suffix = ''
540540
prefix = ''
@@ -543,7 +543,7 @@ def _gen_filename(self, name):
543543

544544
_, base, _ = split_filename(
545545
getattr(self.inputs, trait_spec.name_source))
546-
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd='')
546+
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd=os.getcwd())
547547
elif name == "apply_mask" and isdefined(self.inputs.apply_suffix):
548548
suffix = ''
549549
prefix = ''
@@ -552,9 +552,10 @@ def _gen_filename(self, name):
552552

553553
_, base, _ = split_filename(
554554
getattr(self.inputs, trait_spec.name_source))
555-
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd='')
556-
else:
557-
return super(AFNICommand, self)._gen_filename(name)
555+
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd=os.getcwd())
556+
elif hasattr(self.inputs,name) and isdefined(getattr(self.inputs,name)):
557+
return super(Automask, self)._gen_filename(name)
558+
return Undefined
558559

559560
def _list_outputs(self):
560561
outputs = super(Automask, self)._list_outputs()

0 commit comments

Comments
 (0)