11
11
12
12
import os
13
13
14
- from ...utils .filemanip import split_filename
15
- from ..base import (TraitedSpec , File , traits , isdefined , InputMultiPath ,
16
- CommandLine , CommandLineInputSpec )
14
+ from ..base import TraitedSpec , File , traits , InputMultiPath
17
15
from .base import ANTSCommand , ANTSCommandInputSpec
18
16
19
17
@@ -59,12 +57,16 @@ def _list_outputs(self):
59
57
class AverageImagesInputSpec (ANTSCommandInputSpec ):
60
58
dimension = traits .Enum (3 , 2 , argstr = '%d' , mandatory = True ,
61
59
position = 0 , desc = 'image dimension (2 or 3)' )
62
- output_average_image = File ("average.nii" , argstr = '%s' , position = 1 , desc = 'the name of the resulting image.' ,
63
- usedefault = True , hash_files = False )
64
- normalize = traits .Bool (argstr = "%d" , mandatory = True , position = 2 , desc = 'Normalize: if true, the 2nd image' +
65
- 'is divided by its mean. This will select the largest image to average into.' )
66
- images = InputMultiPath (File (exists = True ), argstr = '%s' , mandatory = True , position = 3 ,
67
- desc = 'image to apply transformation to (generally a coregistered functional)' )
60
+ output_average_image = File (
61
+ "average.nii" , argstr = '%s' , position = 1 , usedefault = True , hash_files = False ,
62
+ desc = 'the name of the resulting image.' )
63
+ normalize = traits .Bool (
64
+ argstr = "%d" , mandatory = True , position = 2 ,
65
+ desc = 'Normalize: if true, the 2nd image is divided by its mean. '
66
+ 'This will select the largest image to average into.' )
67
+ images = InputMultiPath (
68
+ File (exists = True ), argstr = '%s' , mandatory = True , position = 3 ,
69
+ desc = 'image to apply transformation to (generally a coregistered functional)' )
68
70
69
71
70
72
class AverageImagesOutputSpec (TraitedSpec ):
@@ -101,9 +103,11 @@ def _list_outputs(self):
101
103
class MultiplyImagesInputSpec (ANTSCommandInputSpec ):
102
104
dimension = traits .Enum (3 , 2 , argstr = '%d' , usedefault = False , mandatory = True , position = 0 ,
103
105
desc = 'image dimension (2 or 3)' )
104
- first_input = File (argstr = '%s' , exists = True , mandatory = True , position = 1 , desc = 'image 1' )
105
- second_input = traits .Either (File (exists = True ), traits .Float , argstr = '%s' , mandatory = True , position = 2 ,
106
- desc = 'image 2 or multiplication weight' )
106
+ first_input = File (argstr = '%s' , exists = True ,
107
+ mandatory = True , position = 1 , desc = 'image 1' )
108
+ second_input = traits .Either (
109
+ File (exists = True ), traits .Float , argstr = '%s' , mandatory = True , position = 2 ,
110
+ desc = 'image 2 or multiplication weight' )
107
111
output_product_image = File (argstr = '%s' , mandatory = True , position = 3 ,
108
112
desc = 'Outputfname.nii.gz: the name of the resulting image.' )
109
113
@@ -138,22 +142,25 @@ def _list_outputs(self):
138
142
self .inputs .output_product_image )
139
143
return outputs
140
144
145
+
141
146
class CreateJacobianDeterminantImageInputSpec (ANTSCommandInputSpec ):
142
147
imageDimension = traits .Enum (3 , 2 , argstr = '%d' , usedefault = False , mandatory = True ,
143
- position = 0 , desc = 'image dimension (2 or 3)' )
148
+ position = 0 , desc = 'image dimension (2 or 3)' )
144
149
deformationField = File (argstr = '%s' , exists = True , mandatory = True ,
145
- position = 1 , desc = 'deformation transformation file' )
150
+ position = 1 , desc = 'deformation transformation file' )
146
151
outputImage = File (argstr = '%s' , mandatory = True ,
147
- position = 2 ,
148
- desc = 'output filename' )
152
+ position = 2 ,
153
+ desc = 'output filename' )
149
154
doLogJacobian = traits .Enum (0 , 1 , argstr = '%d' , position = 3 ,
150
- desc = 'return the log jacobian' )
155
+ desc = 'return the log jacobian' )
151
156
useGeometric = traits .Enum (0 , 1 , argstr = '%d' , position = 4 ,
152
- desc = 'return the geometric jacobian' )
157
+ desc = 'return the geometric jacobian' )
158
+
153
159
154
160
class CreateJacobianDeterminantImageOutputSpec (TraitedSpec ):
155
161
jacobian_image = File (exists = True , desc = 'jacobian image' )
156
162
163
+
157
164
class CreateJacobianDeterminantImage (ANTSCommand ):
158
165
"""
159
166
Examples
@@ -203,6 +210,7 @@ class AffineInitializerInputSpec(ANTSCommandInputSpec):
203
210
desc = ' determines if a local optimization is run at each search point for the set '
204
211
'number of iterations' )
205
212
213
+
206
214
class AffineInitializerOutputSpec (TraitedSpec ):
207
215
out_file = File (desc = 'output transform file' )
208
216
@@ -225,3 +233,38 @@ class AffineInitializer(ANTSCommand):
225
233
226
234
def _list_outputs (self ):
227
235
return {'out_file' : os .path .abspath (self .inputs .out_file )}
236
+
237
+
238
+ class ComposeMultiTransformInputSpec (ANTSCommandInputSpec ):
239
+ dimension = traits .Enum (3 , 2 , argstr = '%d' , usedefault = True , position = 0 ,
240
+ desc = 'image dimension (2 or 3)' )
241
+ output_transform = File (argstr = '%s' , position = 1 , name_source = ['transforms' ],
242
+ name_template = '%s_composed' , keep_ext = True ,
243
+ desc = 'the name of the resulting transform.' )
244
+ reference_image = File (argstr = '%s' , position = 2 ,
245
+ desc = 'Reference image (only necessary when output is warpfield)' )
246
+ transforms = InputMultiPath (File (exists = True ), argstr = '%s' , mandatory = True ,
247
+ position = 3 , desc = 'transforms to average' )
248
+
249
+
250
+ class ComposeMultiTransformOutputSpec (TraitedSpec ):
251
+ output_transform = File (exists = True , desc = 'Composed transform file' )
252
+
253
+
254
+ class ComposeMultiTransform (ANTSCommand ):
255
+ """
256
+ Take a set of transformations and convert them to a single transformation matrix/warpfield.
257
+
258
+ Examples
259
+ --------
260
+ >>> from nipype.interfaces.ants import ComposeMultiTransform
261
+ >>> compose_transform = ComposeMultiTransform()
262
+ >>> compose_transform.inputs.dimension = 3
263
+ >>> compose_transform.inputs.transforms = ['struct_to_template.mat', 'func_to_struct.mat']
264
+ >>> compose_transform.cmdline # doctest: +ALLOW_UNICODE
265
+ 'ComposeMultiTransform 3 struct_to_template_composed struct_to_template.mat func_to_struct.mat'
266
+
267
+ """
268
+ _cmd = 'ComposeMultiTransform'
269
+ input_spec = ComposeMultiTransformInputSpec
270
+ output_spec = ComposeMultiTransformOutputSpec
0 commit comments