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