@@ -1349,8 +1349,23 @@ class Tkregister2InputSpec(FSTraitedSpec):
1349
1349
1350
1350
moving_image = File (exists = True , mandatory = True , argstr = "--mov %s" ,
1351
1351
desc = 'moving volume' )
1352
+ # Input registration file options
1352
1353
fsl_in_matrix = File (exists = True , argstr = "--fsl %s" ,
1353
1354
desc = 'fsl-style registration input matrix' )
1355
+ xfm = File (exists = True , argstr = '--xfm %s' ,
1356
+ desc = 'use a matrix in MNI coordinates as initial registration' )
1357
+ lta_in = File (exists = True , argstr = '--lta %s' ,
1358
+ desc = 'use a matrix in MNI coordinates as initial registration' )
1359
+ invert_lta_in = traits .Bool (requires = ['lta_in' ],
1360
+ desc = 'Invert input LTA before applying' )
1361
+ # Output registration file options
1362
+ fsl_out = traits .Either (True , File , argstr = '--fslregout %s' ,
1363
+ desc = 'compute an FSL-compatible resgitration matrix' )
1364
+ lta_out = traits .Either (True , File , argstr = '--ltaout %s' ,
1365
+ desc = 'output registration file (LTA format)' )
1366
+ invert_lta_out = traits .Bool (argstr = '--ltaout-inv' , requires = ['lta_in' ],
1367
+ desc = 'Invert input LTA before applying' )
1368
+
1354
1369
subject_id = traits .String (argstr = "--s %s" ,
1355
1370
desc = 'freesurfer subject ID' )
1356
1371
noedit = traits .Bool (True , argstr = "--noedit" , usedefault = True ,
@@ -1361,19 +1376,16 @@ class Tkregister2InputSpec(FSTraitedSpec):
1361
1376
reg_header = traits .Bool (False , argstr = '--regheader' ,
1362
1377
desc = 'compute regstration from headers' )
1363
1378
fstal = traits .Bool (False , argstr = '--fstal' ,
1364
- xor = ['target_image' , 'moving_image' ],
1379
+ xor = ['target_image' , 'moving_image' , 'reg_file' ],
1365
1380
desc = 'set mov to be tal and reg to be tal xfm' )
1366
1381
movscale = traits .Float (argstr = '--movscale %f' ,
1367
1382
desc = 'adjust registration matrix to scale mov' )
1368
- xfm = File (exists = True , argstr = '--xfm %s' ,
1369
- desc = 'use a matrix in MNI coordinates as initial registration' )
1370
- fsl_out = File (argstr = '--fslregout %s' ,
1371
- desc = 'compute an FSL-compatible resgitration matrix' )
1372
1383
1373
1384
1374
1385
class Tkregister2OutputSpec (TraitedSpec ):
1375
1386
reg_file = File (exists = True , desc = 'freesurfer-style registration file' )
1376
1387
fsl_file = File (desc = 'FSL-style registration file' )
1388
+ lta_file = File (desc = 'LTA-style registration file' )
1377
1389
1378
1390
1379
1391
class Tkregister2 (FSCommand ):
@@ -1413,11 +1425,34 @@ class Tkregister2(FSCommand):
1413
1425
input_spec = Tkregister2InputSpec
1414
1426
output_spec = Tkregister2OutputSpec
1415
1427
1428
+ def _format_arg (self , name , spec , value ):
1429
+ if name == 'lta_in' and self .inputs .invert_lta_in :
1430
+ spec = '--lta-inv %s'
1431
+ if name in ('fsl_out' , 'lta_out' ) and value is True :
1432
+ value = self ._list_outputs ()[name ]
1433
+ return super (Tkregister2 , self )._format_arg (name , spec , value )
1434
+
1416
1435
def _list_outputs (self ):
1417
1436
outputs = self ._outputs ().get ()
1418
- outputs ['reg_file' ] = os .path .abspath (self .inputs .reg_file )
1419
- if isdefined (self .inputs .fsl_out ):
1420
- outputs ['fsl_file' ] = os .path .abspath (self .inputs .fsl_out )
1437
+ reg_file = os .path .abspath (self .inputs .reg_file )
1438
+ outputs ['reg_file' ] = reg_file
1439
+
1440
+ cwd = os .getcwd ()
1441
+ fsl_out = self .inputs .fsl_out
1442
+ if isdefined (fsl_out ):
1443
+ if fsl_out is True :
1444
+ outputs ['fsl_file' ] = fname_presuffix (
1445
+ reg_file , suffix = '.mat' , newpath = cwd , use_ext = False )
1446
+ else :
1447
+ outputs ['fsl_file' ] = os .path .abspath (self .inputs .fsl_out )
1448
+
1449
+ lta_out = self .inputs .lta_out
1450
+ if isdefined (lta_out ):
1451
+ if lta_out is True :
1452
+ outputs ['lta_file' ] = fname_presuffix (
1453
+ reg_file , suffix = '.lta' , newpath = cwd , use_ext = False )
1454
+ else :
1455
+ outputs ['lta_file' ] = os .path .abspath (self .inputs .lta_out )
1421
1456
return outputs
1422
1457
1423
1458
def _gen_outfilename (self ):
0 commit comments