@@ -117,3 +117,54 @@ def _list_outputs(self):
117
117
outputs = self ._outputs ().get ()
118
118
outputs ['output_product_image' ] = os .path .abspath (self .inputs .output_product_image )
119
119
return outputs
120
+
121
+
122
+ class JacobianDeterminantInputSpec (ANTSCommandInputSpec ):
123
+ dimension = traits .Enum (3 , 2 , argstr = '%d' , usedefault = False , mandatory = True , position = 0 , desc = 'image dimension (2 or 3)' )
124
+ warp_file = File (argstr = '%s' , exists = True , mandatory = True , position = 1 , desc = 'input warp file' )
125
+ output_prefix = File (argstr = '%s' , genfile = True , hash_files = False , position = 2 , desc = 'prefix of the output image filename: PREFIX(log)jacobian.nii.gz' )
126
+ use_log = traits .Enum (0 , 1 , argstr = '%d' , mandatory = False , position = 3 , desc = 'log transform the jacobian determinant' )
127
+ template_mask = File (argstr = '%s' , exists = True , mandatory = False , position = 4 , desc = 'template mask to adjust for head size' )
128
+ norm_by_total = traits .Enum (0 , 1 , argstr = '%d' , mandatory = False , position = 5 , desc = 'normalize jacobian by total in mask to adjust for head size' )
129
+ projection_vector = traits .List (traits .Float (), argstr = '%s' , sep = 'x' , mandatory = False , position = 6 , desc = 'vector to project warp against' )
130
+
131
+ class JacobianDeterminantOutputSpec (TraitedSpec ):
132
+ jacobian_image = File (exists = True , desc = '(log transformed) jacobian image' )
133
+
134
+ class JacobianDeterminant (ANTSCommand ):
135
+ """
136
+ Examples
137
+ --------
138
+ >>> from nipype.interfaces.ants import JacobianDeterminant
139
+ >>> jacobian = JacobianDeterminant()
140
+ >>> jacobian.inputs.dimension = 3
141
+ >>> jacobian.inputs.warp_file = 'Sub001_2Warp.nii'
142
+ >>> jacobian.inputs.output_prefix = 'Sub001_'
143
+ >>> jacobian.inputs.use_log = 1
144
+ >>> jacobian.cmdline
145
+ 'ANTSJacobian 3 xyz_2Warp.nii.gz xyz_ 1'
146
+ """
147
+
148
+ _cmd = 'ANTSJacobian'
149
+ input_spec = JacobianDeterminantInputSpec
150
+ output_spec = JacobianDeterminantOutputSpec
151
+
152
+ # def _format_arg(self, opt, spec, val):
153
+ # return super(JacobianDeterminant, self)._format_arg(opt, spec, val)
154
+
155
+ def _gen_filename (self , name ):
156
+ if name == 'output_prefix' :
157
+ output = self .inputs .output_prefix
158
+ if not isdefined (output ):
159
+ _ , name , ext = split_filename (self .inputs .warp_file )
160
+ output = name + '_'
161
+ return output
162
+ return None
163
+
164
+ def _list_outputs (self ):
165
+ outputs = self ._outputs ().get ()
166
+ if self .inputs .use_log == 1 :
167
+ outputs ['jacobian_image' ] = os .path .abspath (self ._gen_filename ('output_prefix' ) + 'logjacobian.nii.gz' )
168
+ else :
169
+ outputs ['jacobian_image' ] = os .path .abspath (self ._gen_filename ('output_prefix' ) + 'jacobian.nii.gz' )
170
+ return outputs
0 commit comments