16
16
from ...utils .filemanip import split_filename
17
17
from nipype .interfaces .base import InputMultiPath
18
18
19
+
19
20
class AverageAffineTransformInputSpec (ANTSCommandInputSpec ):
20
21
dimension = traits .Enum (3 , 2 , argstr = '%d' , usedefault = False , mandatory = True , position = 0 , desc = 'image dimension (2 or 3)' )
21
22
output_affine_transform = File (argstr = '%s' , mandatory = True , position = 1 , desc = 'Outputfname.txt: the name of the resulting transform.' )
22
- transforms = InputMultiPath (File (exists = True ), argstr = '%s' , mandatory = True , position = 3 , desc = ('transforms to average' ) )
23
+ transforms = InputMultiPath (File (exists = True ), argstr = '%s' , mandatory = True ,
24
+ position = 3 , desc = ('transforms to average' ))
25
+
23
26
24
27
class AverageAffineTransformOutputSpec (TraitedSpec ):
25
28
affine_transform = File (exists = True , desc = 'average transform file' )
26
29
30
+
27
31
class AverageAffineTransform (ANTSCommand ):
28
32
"""
29
33
Examples
@@ -45,20 +49,24 @@ def _format_arg(self, opt, spec, val):
45
49
46
50
def _list_outputs (self ):
47
51
outputs = self ._outputs ().get ()
48
- outputs ['affine_transform' ] = os .path .abspath (self .inputs .output_affine_transform )
52
+ outputs ['affine_transform' ] = os .path .abspath (
53
+ self .inputs .output_affine_transform )
49
54
return outputs
50
55
51
56
52
57
class AverageImagesInputSpec (ANTSCommandInputSpec ):
53
- dimension = traits .Enum (3 , 2 , argstr = '%d' , mandatory = True , position = 0 , desc = 'image dimension (2 or 3)' )
58
+ dimension = traits .Enum (3 , 2 , argstr = '%d' , mandatory = True ,
59
+ position = 0 , desc = 'image dimension (2 or 3)' )
54
60
output_average_image = File ("average.nii" , argstr = '%s' , position = 1 , desc = 'the name of the resulting image.' , usedefault = True , hash_files = False )
55
61
normalize = traits .Bool (argstr = "%d" , mandatory = True , position = 2 , desc = 'Normalize: if true, the 2nd image' +
56
62
'is divided by its mean. This will select the largest image to average into.' )
57
- images = InputMultiPath (File (exists = True ), argstr = '%s' , mandatory = True , position = 3 , desc = ('image to apply transformation to (generally a coregistered functional)' ) )
63
+ images = InputMultiPath (File (exists = True ), argstr = '%s' , mandatory = True , position = 3 , desc = ('image to apply transformation to (generally a coregistered functional)' ))
64
+
58
65
59
66
class AverageImagesOutputSpec (TraitedSpec ):
60
67
output_average_image = File (exists = True , desc = 'average image file' )
61
68
69
+
62
70
class AverageImages (ANTSCommand ):
63
71
"""
64
72
Examples
@@ -81,18 +89,23 @@ def _format_arg(self, opt, spec, val):
81
89
82
90
def _list_outputs (self ):
83
91
outputs = self ._outputs ().get ()
84
- outputs ['output_average_image' ] = os .path .realpath (self .inputs .output_average_image )
92
+ outputs ['output_average_image' ] = os .path .realpath (
93
+ self .inputs .output_average_image )
85
94
return outputs
86
95
96
+
87
97
class MultiplyImagesInputSpec (ANTSCommandInputSpec ):
88
98
dimension = traits .Enum (3 , 2 , argstr = '%d' , usedefault = False , mandatory = True , position = 0 , desc = 'image dimension (2 or 3)' )
89
- first_input = File (argstr = '%s' , exists = True , mandatory = True , position = 1 , desc = 'image 1' )
99
+ first_input = File (
100
+ argstr = '%s' , exists = True , mandatory = True , position = 1 , desc = 'image 1' )
90
101
second_input = traits .Either (File (exists = True ), traits .Float , argstr = '%s' , mandatory = True , position = 2 , desc = 'image 2 or multiplication weight' )
91
102
output_product_image = File (argstr = '%s' , mandatory = True , position = 3 , desc = 'Outputfname.nii.gz: the name of the resulting image.' )
92
103
104
+
93
105
class MultiplyImagesOutputSpec (TraitedSpec ):
94
106
output_product_image = File (exists = True , desc = 'average image file' )
95
107
108
+
96
109
class MultiplyImages (ANTSCommand ):
97
110
"""
98
111
Examples
@@ -115,34 +128,40 @@ def _format_arg(self, opt, spec, val):
115
128
116
129
def _list_outputs (self ):
117
130
outputs = self ._outputs ().get ()
118
- outputs ['output_product_image' ] = os .path .abspath (self .inputs .output_product_image )
131
+ outputs ['output_product_image' ] = os .path .abspath (
132
+ self .inputs .output_product_image )
119
133
return outputs
120
134
121
135
122
136
class JacobianDeterminantInputSpec (ANTSCommandInputSpec ):
123
137
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' )
138
+ warp_file = File (argstr = '%s' , exists = True , mandatory = True ,
139
+ position = 1 , desc = 'input warp file' )
125
140
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' )
141
+ use_log = traits .Enum (0 , 1 , argstr = '%d' , mandatory = False , position = 3 ,
142
+ desc = 'log transform the jacobian determinant' )
143
+ template_mask = File (argstr = '%s' , exists = True , mandatory = False , position = 4 ,
144
+ desc = 'template mask to adjust for head size' )
128
145
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
146
projection_vector = traits .List (traits .Float (), argstr = '%s' , sep = 'x' , mandatory = False , position = 6 , desc = 'vector to project warp against' )
130
147
148
+
131
149
class JacobianDeterminantOutputSpec (TraitedSpec ):
132
150
jacobian_image = File (exists = True , desc = '(log transformed) jacobian image' )
133
151
152
+
134
153
class JacobianDeterminant (ANTSCommand ):
135
154
"""
136
155
Examples
137
156
--------
138
157
>>> from nipype.interfaces.ants import JacobianDeterminant
139
158
>>> jacobian = JacobianDeterminant()
140
159
>>> jacobian.inputs.dimension = 3
141
- >>> jacobian.inputs.warp_file = 'Sub001_2Warp .nii'
160
+ >>> jacobian.inputs.warp_file = 'ants_Warp .nii.gz '
142
161
>>> jacobian.inputs.output_prefix = 'Sub001_'
143
162
>>> jacobian.inputs.use_log = 1
144
163
>>> jacobian.cmdline
145
- 'ANTSJacobian 3 Sub001_2Warp .nii.gz Sub001_ 1'
164
+ 'ANTSJacobian 3 ants_Warp .nii.gz Sub001_ 1'
146
165
"""
147
166
148
167
_cmd = 'ANTSJacobian'
@@ -161,7 +180,9 @@ def _gen_filename(self, name):
161
180
def _list_outputs (self ):
162
181
outputs = self ._outputs ().get ()
163
182
if self .inputs .use_log == 1 :
164
- outputs ['jacobian_image' ] = os .path .abspath (self ._gen_filename ('output_prefix' ) + 'logjacobian.nii.gz' )
183
+ outputs ['jacobian_image' ] = os .path .abspath (
184
+ self ._gen_filename ('output_prefix' ) + 'logjacobian.nii.gz' )
165
185
else :
166
- outputs ['jacobian_image' ] = os .path .abspath (self ._gen_filename ('output_prefix' ) + 'jacobian.nii.gz' )
186
+ outputs ['jacobian_image' ] = os .path .abspath (
187
+ self ._gen_filename ('output_prefix' ) + 'jacobian.nii.gz' )
167
188
return outputs
0 commit comments