@@ -248,18 +248,27 @@ class TOPUP(FSLCommand):
248
248
def _format_arg (self , name , trait_spec , value ):
249
249
if name == 'encoding_direction' :
250
250
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' )
251
256
return super (TOPUP , self )._format_arg (name , trait_spec , value )
252
257
253
258
def _list_outputs (self ):
254
259
outputs = super (TOPUP , self )._list_outputs ()
255
260
del outputs ['out_base' ]
261
+ base_path = None
256
262
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
258
266
else :
259
267
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 )
261
270
outputs ['out_movpar' ] = self ._gen_fname (base , suffix = '_movpar' ,
262
- ext = '.txt' )
271
+ ext = '.txt' , cwd = base_path )
263
272
264
273
if isdefined (self .inputs .encoding_direction ):
265
274
outputs ['out_enc_file' ] = self ._get_encfilename ()
0 commit comments