@@ -975,3 +975,89 @@ def _list_outputs(self):
975975 if len (self .inputs .save_state ):
976976 outputs ['save_state' ] = os .path .abspath (self .inputs .save_state )
977977 return outputs
978+
979+
980+
981+
982+
983+ class RegistrationSynQuickInputSpec (ANTSCommandInputSpec ):
984+ dimension = traits .Enum (3 , 2 , argstr = '-d %d' ,
985+ usedefault = True , desc = 'image dimension (2 or 3)' )
986+ fixed_image = InputMultiPath (File (exists = True ), mandatory = True , argstr = '-f %s' ,
987+ desc = 'Fixed image or source image or reference image' )
988+ moving_image = InputMultiPath (File (exists = True ), mandatory = True , argstr = '-m %s' ,
989+ desc = 'Moving image or target image' )
990+ output_prefix = traits .Str ("transform" , usedefault = True , argstr = '-o %s' ,
991+ desc = "A prefix that is prepended to all output files" )
992+
993+ # todo ANTSCommandInputSpec already has this, but I can't figure out how to set it without defining it again
994+ num_threads = traits .Int (default_value = 1 , desc = 'Number of threads (default = 1)' , argstr = '-n %d' )
995+
996+ transform_type = traits .Enum ('s' , 't' , 'r' , 'a' , 'sr' , 'b' , 'br' , argstr = '-t %s' ,
997+ desc = 'transform type\n \
998+ t: translation\
999+ r: rigid \n \
1000+ a: rigid + affine\n \
1001+ s: rigid + affine + deformable syn (default)\
1002+ sr: rigid + deformable syn\
1003+ b: rigid + affine + deformable b-spline syn\n \
1004+ br: rigid + deformable b-spline syn' ,
1005+ usedefault = True )
1006+
1007+ use_histogram_matching = traits .Bool (default = False , argstr = '-j %s' ,
1008+ desc = 'use histogram matching' )
1009+ histogram_bins = traits .Int (default_value = 32 , argstr = '-r %d' ,
1010+ desc = 'histogram bins for mutual information in SyN stage \
1011+ (default = 32)' )
1012+ spline_distance = traits .Int (default_value = 26 , argstr = '-s %d' ,
1013+ desc = 'spline distance for deformable B-spline SyN transform \
1014+ (default = 26)' )
1015+ precision_type = traits .Enum ('double' , 'float' , argstr = '-p %s' ,
1016+ desc = 'precision type (default = double)' , usedefault = True )
1017+
1018+
1019+ class RegistrationSynQuickOutputSpec (TraitedSpec ):
1020+ warped_image = File (exists = True , desc = "Warped image" )
1021+ inverse_warped_image = File (exists = True , desc = "Inverse warped image" )
1022+ out_matrix = File (exists = True , desc = 'Affine matrix' )
1023+ forward_warp_field = File (exists = True , desc = 'Forward warp field' )
1024+ inverse_warp_field = File (exists = True , desc = 'Inverse warp field' )
1025+
1026+
1027+ class RegistrationSynQuick (ANTSCommand ):
1028+ """
1029+ Examples
1030+ --------
1031+
1032+ """
1033+ # todo examples
1034+
1035+ _cmd = 'antsRegistrationSynQuick.sh'
1036+ input_spec = RegistrationSynQuickInputSpec
1037+ output_spec = RegistrationSynQuickOutputSpec
1038+
1039+ def _format_arg (self , name , spec , value ):
1040+ if name == 'use_histogram_matching' :
1041+ if isdefined (self .inputs .use_histogram_matching ):
1042+ return spec .argstr % {False : '0' , True : '1' }[value ]
1043+
1044+ elif name == 'precision_type' :
1045+ if isdefined (self .inputs .precision_type ):
1046+ return spec .argstr % {'float' : 'f' , 'double' : 'd' }[value ]
1047+ return super (RegistrationSynQuick , self )._format_arg (name , spec , value )
1048+
1049+ def _list_outputs (self ):
1050+ outputs = self .output_spec ().get ()
1051+ outputs ['warped_image' ] = os .path .abspath (self .inputs .output_prefix + 'Warped.nii.gz' )
1052+ outputs ['inverse_warped_image' ] = os .path .abspath (
1053+ self .inputs .output_prefix + 'InverseWarped.nii.gz' )
1054+ outputs ['out_matrix' ] = os .path .abspath (self .inputs .output_prefix + '0GenericAffine.mat' )
1055+
1056+ # todo in the case of linear transformation-only there won't be fields. is there a more elegant way to specify that?
1057+ if self .inputs .transform_type not in ('t' , 'r' , 'a' ):
1058+ outputs ['forward_warp_field' ] = os .path .abspath (
1059+ self .inputs .output_prefix + '1Warp.nii.gz' )
1060+ outputs ['inverse_warp_field' ] = os .path .abspath (
1061+ self .inputs .output_prefix + '1InverseWarp.nii.gz' )
1062+ return outputs
1063+
0 commit comments