@@ -132,3 +132,79 @@ class CiftiDilate(WBCommand):
132
132
input_spec = CiftiDilateInputSpec
133
133
output_spec = CiftiDilateOutputSpec
134
134
_cmd = "wb_command -cifti-dilate"
135
+
136
+
137
+ class VolumeAffineResampleInputSpec (CommandLineInputSpec ):
138
+ in_file = File (
139
+ exists = True ,
140
+ mandatory = True ,
141
+ argstr = "%s" ,
142
+ position = 0 ,
143
+ desc = "volume to resample" ,
144
+ )
145
+ volume_space = File (
146
+ exists = True ,
147
+ mandatory = True ,
148
+ argstr = "%s" ,
149
+ position = 1 ,
150
+ desc = "a volume file in the volume space you want for the output" ,
151
+ )
152
+ method = traits .Enum ("CUBIC" , "ENCLOSING_VOXEL" , "TRILINEAR" ,
153
+ mandatory = True ,
154
+ argstr = "%s" ,
155
+ position = 2 ,
156
+ desc = "The resampling method. The recommended methods are CUBIC "
157
+ "(cubic spline) for most data, and ENCLOSING_VOXEL for label data." ,
158
+ )
159
+ out_file = File (
160
+ name_source = ["in_file" ],
161
+ name_template = "resampled_%s.nii.gz" ,
162
+ keep_extension = True ,
163
+ argstr = "%s" ,
164
+ position = 3 ,
165
+ desc = "the output volume" ,
166
+ )
167
+ affine = File (
168
+ exists = True ,
169
+ mandatory = True ,
170
+ argstr = "-affine %s" ,
171
+ position = 4 ,
172
+ desc = "the affine file to apply" ,
173
+ )
174
+ flirt = traits .Bool (
175
+ argstr = "-flirt %s %s" ,
176
+ position = 5 ,
177
+ desc = "Set ``True`` if ``affine`` is a FLIRT affine." ,
178
+ )
179
+ flirt_source_volume = File (
180
+ exists = True ,
181
+ desc = "the source volume used when generating the affine; defaults to in_file" ,
182
+ requires = ['flirt' ],
183
+ )
184
+ flirt_target_volume = File (
185
+ exists = True ,
186
+ desc = "the target volume used when generating the affine; defaults to volume_space" ,
187
+ requires = ['flirt' ],
188
+ )
189
+
190
+
191
+ class VolumeAffineResampleOutputSpec (TraitedSpec ):
192
+ out_file = File (exists = True , desc = "the output volume" )
193
+
194
+
195
+ class VolumeAffineResample (WBCommand ):
196
+ """
197
+ Resample a volume file with an affine transformation.
198
+ """
199
+
200
+ input_spec = VolumeAffineResampleInputSpec
201
+ output_spec = VolumeAffineResampleOutputSpec
202
+ _cmd = "wb_command -volume-resample"
203
+
204
+ def _format_arg (self , opt , spec , val ):
205
+ if opt == "flirt" and val :
206
+ val = (
207
+ self .inputs .flirt_source_volume or self .inputs .in_file ,
208
+ self .inputs .flirt_target_volume or self .inputs .volume_space ,
209
+ )
210
+ return super ()._format_arg (opt , spec , val )
0 commit comments