@@ -19,6 +19,7 @@ class ImageMathInputSpec(ANTSCommandInputSpec):
19
19
keep_extension = True ,
20
20
)
21
21
operation = traits .Enum (
22
+ # Mathematical Operations
22
23
"m" ,
23
24
"vm" ,
24
25
"+" ,
@@ -37,6 +38,7 @@ class ImageMathInputSpec(ANTSCommandInputSpec):
37
38
"vtotal" ,
38
39
"Decision" ,
39
40
"Neg" ,
41
+ # Spatial Filtering Operations
40
42
"Project" ,
41
43
"G" ,
42
44
"MD" ,
@@ -47,22 +49,72 @@ class ImageMathInputSpec(ANTSCommandInputSpec):
47
49
"GE" ,
48
50
"GO" ,
49
51
"GC" ,
50
- "TruncateImageIntensity" ,
51
- "Laplacian" ,
52
- "GetLargestComponent" ,
52
+ "ExtractContours" ,
53
+ # Transform Image Operations
54
+ "Translate" ,
55
+ # Tensor Operations
56
+ "4DTensorTo3DTensor" ,
57
+ "ExtractVectorComponent" ,
58
+ "TensorColor" ,
59
+ "TensorFA" ,
60
+ "TensorFADenominator" ,
61
+ "TensorFANumerator" ,
62
+ "TensorMeanDiffusion" ,
63
+ "TensorRadialDiffusion" ,
64
+ "TensorAxialDiffusion" ,
65
+ "TensorEigenvalue" ,
66
+ "TensorToVector" ,
67
+ "TensorToVectorComponent" ,
68
+ "TensorMask" ,
69
+ # Unclassified Operators
70
+ "Byte" ,
71
+ "CorruptImage" ,
72
+ "D" ,
73
+ "MaurerDistance" ,
74
+ "ExtractSlice" ,
53
75
"FillHoles" ,
76
+ "Convolve" ,
77
+ "Finite" ,
78
+ "FlattenImage" ,
79
+ "GetLargestComponent" ,
80
+ "Grad" ,
81
+ "RescaleImage" ,
82
+ "WindowImage" ,
83
+ "NeighborhoodStats" ,
84
+ "ReplicateDisplacement" ,
85
+ "ReplicateImage" ,
86
+ "LabelStats" ,
87
+ "Laplacian" ,
88
+ "Canny" ,
89
+ "Lipschitz" ,
90
+ "MTR" ,
91
+ "Normalize" ,
54
92
"PadImage" ,
93
+ "SigmoidImage" ,
94
+ "Sharpen" ,
95
+ "UnsharpMask" ,
96
+ "PValueImage" ,
97
+ "ReplaceVoxelValue" ,
98
+ "SetTimeSpacing" ,
99
+ "SetTimeSpacingWarp" ,
100
+ "stack" ,
101
+ "ThresholdAtMean" ,
102
+ "TriPlanarView" ,
103
+ "TruncateImageIntensity" ,
55
104
mandatory = True ,
56
105
position = 3 ,
57
106
argstr = "%s" ,
58
107
desc = "mathematical operations" ,
59
108
)
60
109
op1 = File (
61
- exists = True , mandatory = True , position = - 2 , argstr = "%s" , desc = "first operator"
110
+ exists = True , mandatory = True , position = - 3 , argstr = "%s" , desc = "first operator"
62
111
)
63
112
op2 = traits .Either (
64
- File (exists = True ), Str , position = - 1 , argstr = "%s" , desc = "second operator"
113
+ File (exists = True ), Str , position = - 2 , argstr = "%s" , desc = "second operator"
65
114
)
115
+
116
+ args = Str (position = - 1 , argstr = "%s" , desc = "Additional parameters to the command" )
117
+
66
118
copy_header = traits .Bool (
67
119
True ,
68
120
usedefault = True ,
@@ -106,7 +158,7 @@ class ImageMath(ANTSCommand, CopyHeaderInterface):
106
158
107
159
By default, Nipype copies headers from the first input image (``op1``)
108
160
to the output image.
109
- For the ``PadImage`` operation, the header cannot be copied from inputs to
161
+ For some operations, as the ``PadImage`` operation, the header cannot be copied from inputs to
110
162
outputs, and so ``copy_header`` option is automatically set to ``False``.
111
163
112
164
>>> pad = ImageMath(
@@ -135,22 +187,34 @@ class ImageMath(ANTSCommand, CopyHeaderInterface):
135
187
input_spec = ImageMathInputSpec
136
188
output_spec = ImageMathOuputSpec
137
189
_copy_header_map = {"output_image" : "op1" }
190
+ _no_copy_header_operation = (
191
+ "PadImage" ,
192
+ "LabelStats" ,
193
+ "SetTimeSpacing" ,
194
+ "SetTimeSpacingWarp" ,
195
+ "TriPlanarView" ,
196
+ )
138
197
139
198
def __init__ (self , ** inputs ):
140
199
super (ImageMath , self ).__init__ (** inputs )
141
- if self .inputs .operation in ( "PadImage" ,) :
200
+ if self .inputs .operation in self . _no_copy_header_operation :
142
201
self .inputs .copy_header = False
143
202
144
203
self .inputs .on_trait_change (self ._operation_update , "operation" )
145
204
self .inputs .on_trait_change (self ._copyheader_update , "copy_header" )
146
205
147
206
def _operation_update (self ):
148
- if self .inputs .operation in ( "PadImage" ,) :
207
+ if self .inputs .operation in self . _no_copy_header_operation :
149
208
self .inputs .copy_header = False
150
209
151
210
def _copyheader_update (self ):
152
- if self .inputs .copy_header and self .inputs .operation in ("PadImage" ,):
153
- warn ("copy_header cannot be updated to True with PadImage as operation." )
211
+ if (
212
+ self .inputs .copy_header
213
+ and self .inputs .operation in self ._no_copy_header_operation
214
+ ):
215
+ warn (
216
+ f"copy_header cannot be updated to True with { self .inputs .operation } as operation."
217
+ )
154
218
self .inputs .copy_header = False
155
219
156
220
0 commit comments