@@ -1349,8 +1349,23 @@ class Tkregister2InputSpec(FSTraitedSpec):
13491349
13501350 moving_image = File (exists = True , mandatory = True , argstr = "--mov %s" ,
13511351 desc = 'moving volume' )
1352+ # Input registration file options
13521353 fsl_in_matrix = File (exists = True , argstr = "--fsl %s" ,
13531354 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+
13541369 subject_id = traits .String (argstr = "--s %s" ,
13551370 desc = 'freesurfer subject ID' )
13561371 noedit = traits .Bool (True , argstr = "--noedit" , usedefault = True ,
@@ -1361,19 +1376,16 @@ class Tkregister2InputSpec(FSTraitedSpec):
13611376 reg_header = traits .Bool (False , argstr = '--regheader' ,
13621377 desc = 'compute regstration from headers' )
13631378 fstal = traits .Bool (False , argstr = '--fstal' ,
1364- xor = ['target_image' , 'moving_image' ],
1379+ xor = ['target_image' , 'moving_image' , 'reg_file' ],
13651380 desc = 'set mov to be tal and reg to be tal xfm' )
13661381 movscale = traits .Float (argstr = '--movscale %f' ,
13671382 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' )
13721383
13731384
13741385class Tkregister2OutputSpec (TraitedSpec ):
13751386 reg_file = File (exists = True , desc = 'freesurfer-style registration file' )
13761387 fsl_file = File (desc = 'FSL-style registration file' )
1388+ lta_file = File (desc = 'LTA-style registration file' )
13771389
13781390
13791391class Tkregister2 (FSCommand ):
@@ -1413,11 +1425,34 @@ class Tkregister2(FSCommand):
14131425 input_spec = Tkregister2InputSpec
14141426 output_spec = Tkregister2OutputSpec
14151427
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+
14161435 def _list_outputs (self ):
14171436 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 )
14211456 return outputs
14221457
14231458 def _gen_outfilename (self ):
0 commit comments