Skip to content

Commit 8e1d69d

Browse files
committed
fix: topup when out_base is a path
1 parent 7afedad commit 8e1d69d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

nipype/interfaces/fsl/epi.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,27 @@ class TOPUP(FSLCommand):
247247
def _format_arg(self, name, trait_spec, value):
248248
if name == 'encoding_direction':
249249
return trait_spec.argstr % self._generate_encfile()
250+
if name == 'out_base':
251+
path, name, ext = split_filename(value)
252+
if path != '':
253+
if not os.path.exists(path):
254+
raise ValueError('out_base path must exist if provided')
250255
return super(TOPUP, self)._format_arg(name, trait_spec, value)
251256

252257
def _list_outputs(self):
253258
outputs = super(TOPUP, self)._list_outputs()
254259
del outputs['out_base']
260+
base_path = None
255261
if isdefined(self.inputs.out_base):
256-
base = self.inputs.out_base
262+
base_path, base, _ = split_filename(self.inputs.out_base)
263+
if base_path == '':
264+
base_path = None
257265
else:
258266
base = split_filename(self.inputs.in_file)[1] + '_base'
259-
outputs['out_fieldcoef'] = self._gen_fname(base, suffix='_fieldcoef')
267+
outputs['out_fieldcoef'] = self._gen_fname(base, suffix='_fieldcoef',
268+
cwd=base_path)
260269
outputs['out_movpar'] = self._gen_fname(base, suffix='_movpar',
261-
ext='.txt')
270+
ext='.txt', cwd=base_path)
262271

263272
if isdefined(self.inputs.encoding_direction):
264273
outputs['out_enc_file'] = self._get_encfilename()

0 commit comments

Comments
 (0)