@@ -1457,76 +1457,102 @@ def _gen_filename(self, name):
1457
1457
1458
1458
class RobustRegisterInputSpec (FSTraitedSpec ):
1459
1459
1460
- source_file = File (mandatory = True , argstr = '--mov %s' ,
1460
+ source_file = File (exists = True , mandatory = True , argstr = '--mov %s' ,
1461
1461
desc = 'volume to be registered' )
1462
- target_file = File (mandatory = True , argstr = '--dst %s' ,
1462
+ target_file = File (exists = True , 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' )
1466
- registered_file = traits .Either (traits .Bool , File , argstr = '--warp %s' ,
1467
- desc = 'registered image; either True or filename' )
1468
- weights_file = traits .Either (traits .Bool , File , argstr = '--weights %s' ,
1469
- desc = 'weights image to write; either True or filename' )
1470
- est_int_scale = traits .Bool (argstr = '--iscale' ,
1471
- desc = 'estimate intensity scale (recommended for unnormalized images)' )
1464
+ out_reg_file = traits .Either (
1465
+ True , File , default = True , usedefault = True , argstr = '--lta %s' ,
1466
+ desc = 'registration file; either True or filename' )
1467
+ registered_file = traits .Either (
1468
+ traits .Bool , File , argstr = '--warp %s' ,
1469
+ desc = 'registered image; either True or filename' )
1470
+ weights_file = traits .Either (
1471
+ traits .Bool , File , argstr = '--weights %s' ,
1472
+ desc = 'weights image to write; either True or filename' )
1473
+ est_int_scale = traits .Bool (
1474
+ argstr = '--iscale' ,
1475
+ desc = 'estimate intensity scale (recommended for unnormalized images)' )
1472
1476
trans_only = traits .Bool (argstr = '--transonly' ,
1473
1477
desc = 'find 3 parameter translation only' )
1474
1478
in_xfm_file = File (exists = True , argstr = '--transform' ,
1475
1479
desc = 'use initial transform on source' )
1476
- half_source = traits .Either (traits .Bool , File , argstr = '--halfmov %s' ,
1477
- desc = "write source volume mapped to halfway space" )
1478
- half_targ = traits .Either (traits .Bool , File , argstr = "--halfdst %s" ,
1479
- desc = "write target volume mapped to halfway space" )
1480
- half_weights = traits .Either (traits .Bool , File , argstr = "--halfweights %s" ,
1481
- desc = "write weights volume mapped to halfway space" )
1482
- half_source_xfm = traits .Either (traits .Bool , File , argstr = "--halfmovlta %s" ,
1483
- desc = "write transform from source to halfway space" )
1484
- half_targ_xfm = traits .Either (traits .Bool , File , argstr = "--halfdstlta %s" ,
1485
- desc = "write transform from target to halfway space" )
1486
- auto_sens = traits .Bool (argstr = '--satit' , xor = ['outlier_sens' ], mandatory = True ,
1487
- desc = 'auto-detect good sensitivity' )
1488
- outlier_sens = traits .Float (argstr = '--sat %.4f' , xor = ['auto_sens' ], mandatory = True ,
1489
- desc = 'set outlier sensitivity explicitly' )
1490
- least_squares = traits .Bool (argstr = '--leastsquares' ,
1491
- desc = 'use least squares instead of robust estimator' )
1480
+ half_source = traits .Either (
1481
+ traits .Bool , File , argstr = '--halfmov %s' ,
1482
+ desc = "write source volume mapped to halfway space" )
1483
+ half_targ = traits .Either (
1484
+ traits .Bool , File , argstr = "--halfdst %s" ,
1485
+ desc = "write target volume mapped to halfway space" )
1486
+ half_weights = traits .Either (
1487
+ traits .Bool , File , argstr = "--halfweights %s" ,
1488
+ desc = "write weights volume mapped to halfway space" )
1489
+ half_source_xfm = traits .Either (
1490
+ traits .Bool , File , argstr = "--halfmovlta %s" ,
1491
+ desc = "write transform from source to halfway space" )
1492
+ half_targ_xfm = traits .Either (
1493
+ traits .Bool , File , argstr = "--halfdstlta %s" ,
1494
+ desc = "write transform from target to halfway space" )
1495
+ auto_sens = traits .Bool (
1496
+ argstr = '--satit' , xor = ['outlier_sens' ], mandatory = True ,
1497
+ desc = 'auto-detect good sensitivity' )
1498
+ outlier_sens = traits .Float (
1499
+ argstr = '--sat %.4f' , xor = ['auto_sens' ], mandatory = True ,
1500
+ desc = 'set outlier sensitivity explicitly' )
1501
+ least_squares = traits .Bool (
1502
+ argstr = '--leastsquares' ,
1503
+ desc = 'use least squares instead of robust estimator' )
1492
1504
no_init = traits .Bool (argstr = '--noinit' , desc = 'skip transform init' )
1493
- init_orient = traits .Bool (argstr = '--initorient' ,
1494
- desc = 'use moments for initial orient (recommended for stripped brains)' )
1505
+ init_orient = traits .Bool (
1506
+ argstr = '--initorient' ,
1507
+ desc = 'use moments for initial orient (recommended for stripped brains)'
1508
+ )
1495
1509
max_iterations = traits .Int (argstr = '--maxit %d' ,
1496
1510
desc = 'maximum # of times on each resolution' )
1497
1511
high_iterations = traits .Int (argstr = '--highit %d' ,
1498
1512
desc = 'max # of times on highest resolution' )
1499
- iteration_thresh = traits .Float (argstr = '--epsit %.3f' ,
1500
- desc = 'stop iterations when below threshold' )
1501
- subsample_thresh = traits .Int (argstr = '--subsample %d' ,
1502
- desc = 'subsample if dimension is above threshold size' )
1513
+ iteration_thresh = traits .Float (
1514
+ argstr = '--epsit %.3f' , desc = 'stop iterations when below threshold' )
1515
+ subsample_thresh = traits .Int (
1516
+ argstr = '--subsample %d' ,
1517
+ desc = 'subsample if dimension is above threshold size' )
1503
1518
outlier_limit = traits .Float (argstr = '--wlimit %.3f' ,
1504
1519
desc = 'set maximal outlier limit in satit' )
1505
- write_vo2vox = traits .Bool (argstr = '--vox2vox' ,
1506
- desc = 'output vox2vox matrix (default is RAS2RAS)' )
1507
- no_multi = traits .Bool (argstr = '--nomulti' , desc = 'work on highest resolution' )
1520
+ write_vo2vox = traits .Bool (
1521
+ argstr = '--vox2vox' , desc = 'output vox2vox matrix (default is RAS2RAS)' )
1522
+ no_multi = traits .Bool (argstr = '--nomulti' ,
1523
+ desc = 'work on highest resolution' )
1508
1524
mask_source = File (exists = True , argstr = '--maskmov %s' ,
1509
1525
desc = 'image to mask source volume with' )
1510
1526
mask_target = File (exists = True , argstr = '--maskdst %s' ,
1511
1527
desc = 'image to mask target volume with' )
1512
- force_double = traits .Bool (argstr = '--doubleprec' , desc = 'use double-precision intensities' )
1513
- force_float = traits .Bool (argstr = '--floattype' , desc = 'use float intensities' )
1528
+ force_double = traits .Bool (argstr = '--doubleprec' ,
1529
+ desc = 'use double-precision intensities' )
1530
+ force_float = traits .Bool (argstr = '--floattype' ,
1531
+ desc = 'use float intensities' )
1514
1532
1515
1533
1516
1534
class RobustRegisterOutputSpec (TraitedSpec ):
1517
1535
1518
1536
out_reg_file = File (exists = True , desc = "output registration file" )
1519
- registered_file = File (desc = "output image with registration applied" )
1520
- weights_file = File (desc = "image of weights used" )
1521
- half_source = File (desc = "source image mapped to halfway space" )
1522
- half_targ = File (desc = "target image mapped to halfway space" )
1523
- half_weights = File (desc = "weights image mapped to halfway space" )
1524
- half_source_xfm = File (desc = "transform file to map source image to halfway space" )
1525
- half_targ_xfm = File (desc = "transform file to map target image to halfway space" )
1537
+ registered_file = File (exists = True ,
1538
+ desc = "output image with registration applied" )
1539
+ weights_file = File (exists = True , desc = "image of weights used" )
1540
+ half_source = File (exists = True ,
1541
+ desc = "source image mapped to halfway space" )
1542
+ half_targ = File (exists = True , desc = "target image mapped to halfway space" )
1543
+ half_weights = File (exists = True ,
1544
+ desc = "weights image mapped to halfway space" )
1545
+ half_source_xfm = File (
1546
+ exists = True ,
1547
+ desc = "transform file to map source image to halfway space" )
1548
+ half_targ_xfm = File (
1549
+ exists = True ,
1550
+ desc = "transform file to map target image to halfway space" )
1526
1551
1527
1552
1528
1553
class RobustRegister (FSCommand ):
1529
- """Perform intramodal linear registration (translation and rotation) using robust statistics.
1554
+ """Perform intramodal linear registration (translation and rotation) using
1555
+ robust statistics.
1530
1556
1531
1557
Examples
1532
1558
--------
@@ -1536,13 +1562,13 @@ class RobustRegister(FSCommand):
1536
1562
>>> reg.inputs.target_file = 'T1.nii'
1537
1563
>>> reg.inputs.auto_sens = True
1538
1564
>>> reg.inputs.init_orient = True
1539
- >>> reg.cmdline # doctest: +ALLOW_UNICODE
1540
- 'mri_robust_register --satit --initorient --lta structural_robustreg.lta --mov structural.nii --dst T1.nii'
1565
+ >>> reg.cmdline # doctest: +ALLOW_UNICODE +ELLIPSIS
1566
+ 'mri_robust_register --satit --initorient --lta .../ structural_robustreg.lta --mov structural.nii --dst T1.nii'
1541
1567
1542
1568
References
1543
1569
----------
1544
- Reuter, M, Rosas, HD, and Fischl, B, (2010). Highly Accurate Inverse Consistent Registration:
1545
- A Robust Approach. Neuroimage 53(4) 1181-96.
1570
+ Reuter, M, Rosas, HD, and Fischl, B, (2010). Highly Accurate Inverse
1571
+ Consistent Registration: A Robust Approach. Neuroimage 53(4) 1181-96.
1546
1572
1547
1573
"""
1548
1574
@@ -1551,24 +1577,20 @@ class RobustRegister(FSCommand):
1551
1577
output_spec = RobustRegisterOutputSpec
1552
1578
1553
1579
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
1580
+ options = ("out_reg_file" , "registered_file" , "weights_file" ,
1581
+ "half_source" , "half_targ" , "half_weights" ,
1582
+ "half_source_xfm" , "half_targ_xfm" )
1583
+ if name in options and isinstance (value , bool ):
1584
+ value = self ._list_outputs ()[name ]
1562
1585
return super (RobustRegister , self )._format_arg (name , spec , value )
1563
1586
1564
1587
def _list_outputs (self ):
1565
1588
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 ),
1589
+ cwd = os .getcwd ()
1590
+ prefices = dict (src = self .inputs .source_file ,
1591
+ trg = self .inputs .target_file )
1592
+ suffices = dict (out_reg_file = ("src" , "_robustreg.lta" , False ),
1593
+ registered_file = ("src" , "_robustreg" , True ),
1572
1594
weights_file = ("src" , "_robustweights" , True ),
1573
1595
half_source = ("src" , "_halfway" , True ),
1574
1596
half_targ = ("trg" , "_halfway" , True ),
@@ -1577,21 +1599,16 @@ def _list_outputs(self):
1577
1599
half_targ_xfm = ("trg" , "_robustxfm.lta" , False ))
1578
1600
for name , sufftup in list (suffices .items ()):
1579
1601
value = getattr (self .inputs , name )
1580
- if isdefined ( value ) :
1581
- if isinstance ( value , bool ) :
1602
+ if value :
1603
+ if value is True :
1582
1604
outputs [name ] = fname_presuffix (prefices [sufftup [0 ]],
1583
1605
suffix = sufftup [1 ],
1584
- newpath = os . getcwd () ,
1606
+ newpath = cwd ,
1585
1607
use_ext = sufftup [2 ])
1586
1608
else :
1587
- outputs [name ] = value
1609
+ outputs [name ] = os . path . abspath ( value )
1588
1610
return outputs
1589
1611
1590
- def _gen_filename (self , name ):
1591
- if name == 'out_reg_file' :
1592
- return self ._list_outputs ()[name ]
1593
- return None
1594
-
1595
1612
1596
1613
class FitMSParamsInputSpec (FSTraitedSpec ):
1597
1614
0 commit comments