@@ -1350,3 +1350,89 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
13501350 stdout = runtime .stdout .split ('\n ' )
13511351 outputs .similarity = float (stdout [0 ])
13521352 return outputs
1353+
1354+
1355+
1356+
1357+
1358+ class RegistrationSynQuickInputSpec (ANTSCommandInputSpec ):
1359+ dimension = traits .Enum (3 , 2 , argstr = '-d %d' ,
1360+ usedefault = True , desc = 'image dimension (2 or 3)' )
1361+ fixed_image = InputMultiPath (File (exists = True ), mandatory = True , argstr = '-f %s' ,
1362+ desc = 'Fixed image or source image or reference image' )
1363+ moving_image = InputMultiPath (File (exists = True ), mandatory = True , argstr = '-m %s' ,
1364+ desc = 'Moving image or target image' )
1365+ output_prefix = traits .Str ("transform" , usedefault = True , argstr = '-o %s' ,
1366+ desc = "A prefix that is prepended to all output files" )
1367+
1368+ # todo ANTSCommandInputSpec already has this, but I can't figure out how to set it without defining it again
1369+ num_threads = traits .Int (default_value = 1 , desc = 'Number of threads (default = 1)' , argstr = '-n %d' )
1370+
1371+ transform_type = traits .Enum ('s' , 't' , 'r' , 'a' , 'sr' , 'b' , 'br' , argstr = '-t %s' ,
1372+ desc = 'transform type\n \
1373+ t: translation\
1374+ r: rigid \n \
1375+ a: rigid + affine\n \
1376+ s: rigid + affine + deformable syn (default)\
1377+ sr: rigid + deformable syn\
1378+ b: rigid + affine + deformable b-spline syn\n \
1379+ br: rigid + deformable b-spline syn' ,
1380+ usedefault = True )
1381+
1382+ use_histogram_matching = traits .Bool (default = False , argstr = '-j %s' ,
1383+ desc = 'use histogram matching' )
1384+ histogram_bins = traits .Int (default_value = 32 , argstr = '-r %d' ,
1385+ desc = 'histogram bins for mutual information in SyN stage \
1386+ (default = 32)' )
1387+ spline_distance = traits .Int (default_value = 26 , argstr = '-s %d' ,
1388+ desc = 'spline distance for deformable B-spline SyN transform \
1389+ (default = 26)' )
1390+ precision_type = traits .Enum ('double' , 'float' , argstr = '-p %s' ,
1391+ desc = 'precision type (default = double)' , usedefault = True )
1392+
1393+
1394+ class RegistrationSynQuickOutputSpec (TraitedSpec ):
1395+ warped_image = File (exists = True , desc = "Warped image" )
1396+ inverse_warped_image = File (exists = True , desc = "Inverse warped image" )
1397+ out_matrix = File (exists = True , desc = 'Affine matrix' )
1398+ forward_warp_field = File (exists = True , desc = 'Forward warp field' )
1399+ inverse_warp_field = File (exists = True , desc = 'Inverse warp field' )
1400+
1401+
1402+ class RegistrationSynQuick (ANTSCommand ):
1403+ """
1404+ Examples
1405+ --------
1406+
1407+ """
1408+ # todo examples
1409+
1410+ _cmd = 'antsRegistrationSynQuick.sh'
1411+ input_spec = RegistrationSynQuickInputSpec
1412+ output_spec = RegistrationSynQuickOutputSpec
1413+
1414+ def _format_arg (self , name , spec , value ):
1415+ if name == 'use_histogram_matching' :
1416+ if isdefined (self .inputs .use_histogram_matching ):
1417+ return spec .argstr % {False : '0' , True : '1' }[value ]
1418+
1419+ elif name == 'precision_type' :
1420+ if isdefined (self .inputs .precision_type ):
1421+ return spec .argstr % {'float' : 'f' , 'double' : 'd' }[value ]
1422+ return super (RegistrationSynQuick , self )._format_arg (name , spec , value )
1423+
1424+ def _list_outputs (self ):
1425+ outputs = self .output_spec ().get ()
1426+ outputs ['warped_image' ] = os .path .abspath (self .inputs .output_prefix + 'Warped.nii.gz' )
1427+ outputs ['inverse_warped_image' ] = os .path .abspath (
1428+ self .inputs .output_prefix + 'InverseWarped.nii.gz' )
1429+ outputs ['out_matrix' ] = os .path .abspath (self .inputs .output_prefix + '0GenericAffine.mat' )
1430+
1431+ # todo in the case of linear transformation-only there won't be fields. is there a more elegant way to specify that?
1432+ if self .inputs .transform_type not in ('t' , 'r' , 'a' ):
1433+ outputs ['forward_warp_field' ] = os .path .abspath (
1434+ self .inputs .output_prefix + '1Warp.nii.gz' )
1435+ outputs ['inverse_warp_field' ] = os .path .abspath (
1436+ self .inputs .output_prefix + '1InverseWarp.nii.gz' )
1437+ return outputs
1438+
0 commit comments