@@ -1488,7 +1488,7 @@ class WarpUtilsInputSpec(FSLCommandInputSpec):
1488
1488
desc = ('Alternative (to --warpres) specifikation of the resolution of '
1489
1489
'the output spline-field.' ))
1490
1490
1491
- out_file = File (genfile = True , hash_files = False , argstr = '--out=%s' ,
1491
+ out_file = File (argstr = '--out=%s' , position = - 1 , name_source = [ 'in_file' ], output_name = 'out_file ' ,
1492
1492
desc = ('Name of output file. The format of the output depends on what other '
1493
1493
'parameters are set. The default format is a (4D) field-file. If the '
1494
1494
'--outformat is set to spline the format will be a (4D) file of spline '
@@ -1531,7 +1531,7 @@ class WarpUtils(FSLCommand):
1531
1531
>>> warputils.inputs.out_format = 'spline'
1532
1532
>>> warputils.inputs.warp_resolution = (10,10,10)
1533
1533
>>> warputils.cmdline # doctest: +ELLIPSIS
1534
- 'fnirtfileutils --in=warpfield.nii --out=.../warpfield_coeffs.nii.gz -- outformat=spline --ref=T1.nii --warpres=10.0000,10.0000,10.0000'
1534
+ 'fnirtfileutils --in=warpfield.nii --outformat=spline --ref=T1.nii --warpres=10.0000,10.0000,10.0000 --out=.../warpfield_coeffs.nii.gz '
1535
1535
>>> res = invwarp.run() # doctest: +SKIP
1536
1536
"""
1537
1537
@@ -1544,49 +1544,29 @@ def _parse_inputs(self, skip=None):
1544
1544
if skip is None :
1545
1545
skip = []
1546
1546
1547
- if self .inputs .write_jacobian :
1548
- if not isdefined (self .inputs .out_jacobian ):
1549
- self .inputs .out_jacobian = self ._gen_fname (self .inputs .in_file ,
1550
- suffix = '_jac' )
1551
- skip += ['write_jacobian' ]
1552
- return super (WarpUtils , self )._parse_inputs (skip = skip )
1553
-
1554
-
1555
-
1556
- def _list_outputs (self ):
1557
- outputs = self .output_spec ().get ()
1558
- outputs ['out_file' ] = self .inputs .out_file
1559
-
1560
1547
suffix = 'field'
1561
-
1562
1548
if isdefined (self .inputs .out_format ) and self .inputs .out_format == 'spline' :
1563
1549
suffix = 'coeffs'
1564
1550
1551
+ trait_spec = self .inputs .trait ('out_file' )
1552
+ trait_spec .name_template = "%s_" + suffix
1565
1553
1566
- if not isdefined (outputs ['out_file' ]):
1567
- outputs ['out_file' ] = self ._gen_fname (self .inputs .in_file ,
1568
- suffix = '_' + suffix )
1569
-
1570
- if isdefined (self .inputs .out_jacobian ):
1571
- outputs ['out_jacobian' ] = os .path .abspath (self .inputs .out_jacobian )
1572
-
1573
- outputs ['out_file' ] = os .path .abspath (outputs ['out_file' ])
1574
- return outputs
1575
-
1576
- def _gen_filename (self , name ):
1577
- if name == 'out_file' :
1578
- return self ._list_outputs ()[name ]
1579
-
1580
- return None
1581
-
1554
+ if self .inputs .write_jacobian :
1555
+ if not isdefined (self .inputs .out_jacobian ):
1556
+ trait_spec = self .inputs .trait ('out_jacobian' )
1557
+ trait_spec .name_source = ['in_file' ]
1558
+ trait_spec .name_template = '%s_jac'
1582
1559
1560
+ skip += ['write_jacobian' ]
1561
+ return super (WarpUtils , self )._parse_inputs (skip = skip )
1583
1562
1584
1563
1585
1564
class ConvertWarpInputSpec (FSLCommandInputSpec ):
1586
1565
reference = File (exists = True , argstr = '--ref=%s' , mandatory = True , position = 1 ,
1587
1566
desc = ('Name of a file in target space of the full transform.' ))
1588
1567
1589
- out_file = File (genfile = True , hash_files = False , argstr = '--out=%s' , position = - 1 ,
1568
+ out_file = File (argstr = '--out=%s' , position = - 1 , name_source = ['reference' ],
1569
+ name_template = '%s_concatwarp' , output_name = 'out_file' ,
1590
1570
desc = ('Name of output file, containing warps that are the combination of all '
1591
1571
'those given as arguments. The format of this will be a field-file (rather '
1592
1572
'than spline coefficients) with any affine components included.' ))
@@ -1678,22 +1658,4 @@ class ConvertWarp(FSLCommand):
1678
1658
1679
1659
input_spec = ConvertWarpInputSpec
1680
1660
output_spec = ConvertWarpOutputSpec
1681
-
1682
1661
_cmd = 'convertwarp'
1683
-
1684
- def _list_outputs (self ):
1685
- outputs = self .output_spec ().get ()
1686
- outputs ['out_file' ] = self .inputs .out_file
1687
-
1688
- if not isdefined (outputs ['out_file' ]):
1689
- outputs ['out_file' ] = self ._gen_fname (self .inputs .reference ,
1690
- suffix = '_concatwarps' )
1691
-
1692
- outputs ['out_file' ] = os .path .abspath (outputs ['out_file' ])
1693
- return outputs
1694
-
1695
- def _gen_filename (self , name ):
1696
- if name == 'out_file' :
1697
- return self ._list_outputs ()[name ]
1698
-
1699
- return None
0 commit comments