Skip to content

Commit efa7d39

Browse files
committed
Merge pull request #928 from satra/fix/topup
fix: topup when out_base is a path
2 parents e94b5bf + 0c06170 commit efa7d39

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
@@ -248,18 +248,27 @@ class TOPUP(FSLCommand):
248248
def _format_arg(self, name, trait_spec, value):
249249
if name == 'encoding_direction':
250250
return trait_spec.argstr % self._generate_encfile()
251+
if name == 'out_base':
252+
path, name, ext = split_filename(value)
253+
if path != '':
254+
if not os.path.exists(path):
255+
raise ValueError('out_base path must exist if provided')
251256
return super(TOPUP, self)._format_arg(name, trait_spec, value)
252257

253258
def _list_outputs(self):
254259
outputs = super(TOPUP, self)._list_outputs()
255260
del outputs['out_base']
261+
base_path = None
256262
if isdefined(self.inputs.out_base):
257-
base = self.inputs.out_base
263+
base_path, base, _ = split_filename(self.inputs.out_base)
264+
if base_path == '':
265+
base_path = None
258266
else:
259267
base = split_filename(self.inputs.in_file)[1] + '_base'
260-
outputs['out_fieldcoef'] = self._gen_fname(base, suffix='_fieldcoef')
268+
outputs['out_fieldcoef'] = self._gen_fname(base, suffix='_fieldcoef',
269+
cwd=base_path)
261270
outputs['out_movpar'] = self._gen_fname(base, suffix='_movpar',
262-
ext='.txt')
271+
ext='.txt', cwd=base_path)
263272

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

0 commit comments

Comments
 (0)