@@ -1461,8 +1461,9 @@ class RobustRegisterInputSpec(FSTraitedSpec):
1461
1461
desc = 'volume to be registered' )
1462
1462
target_file = File (mandatory = True , argstr = '--dst %s' ,
1463
1463
desc = 'target volume for the registration' )
1464
- out_reg_file = File (genfile = True , argstr = '--lta %s' ,
1465
- desc = 'registration file to write' )
1464
+ out_reg_file = traits .Either (
1465
+ True , File , default = True , usedefault = True , argstr = '--lta %s' ,
1466
+ desc = 'registration file; either True or filename' )
1466
1467
registered_file = traits .Either (traits .Bool , File , argstr = '--warp %s' ,
1467
1468
desc = 'registered image; either True or filename' )
1468
1469
weights_file = traits .Either (traits .Bool , File , argstr = '--weights %s' ,
@@ -1551,24 +1552,20 @@ class RobustRegister(FSCommand):
1551
1552
output_spec = RobustRegisterOutputSpec
1552
1553
1553
1554
def _format_arg (self , name , spec , value ):
1554
- for option in ["registered_file" , "weights_file" , "half_source" , "half_targ" ,
1555
- "half_weights" , "half_source_xfm" , "half_targ_xfm" ]:
1556
- if name == option :
1557
- if isinstance (value , bool ):
1558
- fname = self ._list_outputs ()[name ]
1559
- else :
1560
- fname = value
1561
- return spec .argstr % fname
1555
+ options = ("out_reg_file" , "registered_file" , "weights_file" ,
1556
+ "half_source" , "half_targ" , "half_weights" ,
1557
+ "half_source_xfm" , "half_targ_xfm" )
1558
+ if name in options and isinstance (value , bool ):
1559
+ value = self ._list_outputs ()[name ]
1562
1560
return super (RobustRegister , self )._format_arg (name , spec , value )
1563
1561
1564
1562
def _list_outputs (self ):
1565
1563
outputs = self .output_spec ().get ()
1566
- outputs ['out_reg_file' ] = self .inputs .out_reg_file
1567
- if not isdefined (self .inputs .out_reg_file ) and self .inputs .source_file :
1568
- outputs ['out_reg_file' ] = fname_presuffix (self .inputs .source_file ,
1569
- suffix = '_robustreg.lta' , use_ext = False )
1570
- prefices = dict (src = self .inputs .source_file , trg = self .inputs .target_file )
1571
- suffices = dict (registered_file = ("src" , "_robustreg" , True ),
1564
+ cwd = os .getcwd ()
1565
+ prefices = dict (src = self .inputs .source_file ,
1566
+ trg = self .inputs .target_file )
1567
+ suffices = dict (out_reg_file = ("src" , "_robustreg.lta" , False ),
1568
+ registered_file = ("src" , "_robustreg" , True ),
1572
1569
weights_file = ("src" , "_robustweights" , True ),
1573
1570
half_source = ("src" , "_halfway" , True ),
1574
1571
half_targ = ("trg" , "_halfway" , True ),
@@ -1577,21 +1574,16 @@ def _list_outputs(self):
1577
1574
half_targ_xfm = ("trg" , "_robustxfm.lta" , False ))
1578
1575
for name , sufftup in list (suffices .items ()):
1579
1576
value = getattr (self .inputs , name )
1580
- if isdefined ( value ) :
1581
- if isinstance ( value , bool ) :
1577
+ if value :
1578
+ if value is True :
1582
1579
outputs [name ] = fname_presuffix (prefices [sufftup [0 ]],
1583
1580
suffix = sufftup [1 ],
1584
- newpath = os . getcwd () ,
1581
+ newpath = cwd ,
1585
1582
use_ext = sufftup [2 ])
1586
1583
else :
1587
- outputs [name ] = value
1584
+ outputs [name ] = os . path . abspath ( value )
1588
1585
return outputs
1589
1586
1590
- def _gen_filename (self , name ):
1591
- if name == 'out_reg_file' :
1592
- return self ._list_outputs ()[name ]
1593
- return None
1594
-
1595
1587
1596
1588
class FitMSParamsInputSpec (FSTraitedSpec ):
1597
1589
0 commit comments