@@ -43,9 +43,12 @@ class WarpTimeSeriesImageMultiTransformInputSpec(ANTSCommandInputSpec):
43
43
desc = 'transformation file(s) to be applied' ,
44
44
mandatory = True , copyfile = False )
45
45
invert_affine = traits .List (traits .Int ,
46
- desc = ('List of Affine transformations to invert. '
46
+ desc = ('List of Affine transformations to invert.'
47
47
'E.g.: [1,4,5] inverts the 1st, 4th, and 5th Affines '
48
- 'found in transformation_series' ))
48
+ 'found in transformation_series. Note that indexing '
49
+ 'starts with 1 and does not include warp fields. Affine '
50
+ 'transformations are distinguished '
51
+ 'from warp fields by the word "affine" included in their filenames.' ))
49
52
50
53
51
54
class WarpTimeSeriesImageMultiTransformOutputSpec (TraitedSpec ):
@@ -67,6 +70,14 @@ class WarpTimeSeriesImageMultiTransform(ANTSCommand):
67
70
'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii -R ants_deformed.nii.gz ants_Warp.nii.gz \
68
71
ants_Affine.txt'
69
72
73
+ >>> wtsimt = WarpTimeSeriesImageMultiTransform()
74
+ >>> wtsimt.inputs.input_image = 'resting.nii'
75
+ >>> wtsimt.inputs.reference_image = 'ants_deformed.nii.gz'
76
+ >>> wtsimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt']
77
+ >>> wtsimt.inputs.invert_affine = [1] # # this will invert the 1st Affine file: ants_Affine.txt
78
+ >>> wtsimt.cmdline # doctest: +ALLOW_UNICODE
79
+ 'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii -R ants_deformed.nii.gz ants_Warp.nii.gz \
80
+ -i ants_Affine.txt'
70
81
"""
71
82
72
83
_cmd = 'WarpTimeSeriesImageMultiTransform'
@@ -81,13 +92,22 @@ def _format_arg(self, opt, spec, val):
81
92
if opt == 'transformation_series' :
82
93
series = []
83
94
affine_counter = 0
95
+ affine_invert = []
84
96
for transformation in val :
85
97
if 'Affine' in transformation and \
86
98
isdefined (self .inputs .invert_affine ):
87
99
affine_counter += 1
88
100
if affine_counter in self .inputs .invert_affine :
89
- series += ['-i' ],
101
+ series += ['-i' ]
102
+ affine_invert .append (affine_counter )
90
103
series += [transformation ]
104
+
105
+ if isdefined (self .inputs .invert_affine ):
106
+ diff_inv = set (self .inputs .invert_affine ) - set (affine_invert )
107
+ if diff_inv :
108
+ raise Exceptions ("Review invert_affine, not all indexes from invert_affine were used, "
109
+ "check the description for the full definition" )
110
+
91
111
return ' ' .join (series )
92
112
return super (WarpTimeSeriesImageMultiTransform , self )._format_arg (opt , spec , val )
93
113
@@ -168,7 +188,7 @@ class WarpImageMultiTransform(ANTSCommand):
168
188
>>> wimt.inputs.reference_image = 'functional.nii'
169
189
>>> wimt.inputs.transformation_series = ['func2anat_coreg_Affine.txt','func2anat_InverseWarp.nii.gz', \
170
190
'dwi2anat_Warp.nii.gz','dwi2anat_coreg_Affine.txt']
171
- >>> wimt.inputs.invert_affine = [1]
191
+ >>> wimt.inputs.invert_affine = [1] # this will invert the 1st Affine file: 'func2anat_coreg_Affine.txt'
172
192
>>> wimt.cmdline # doctest: +ALLOW_UNICODE
173
193
'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii \
174
194
-i func2anat_coreg_Affine.txt func2anat_InverseWarp.nii.gz dwi2anat_Warp.nii.gz dwi2anat_coreg_Affine.txt'
@@ -190,14 +210,24 @@ def _format_arg(self, opt, spec, val):
190
210
if opt == 'transformation_series' :
191
211
series = []
192
212
affine_counter = 0
213
+ affine_invert = []
193
214
for transformation in val :
194
215
if "affine" in transformation .lower () and \
195
216
isdefined (self .inputs .invert_affine ):
196
217
affine_counter += 1
197
218
if affine_counter in self .inputs .invert_affine :
198
- series += '-i' ,
219
+ series += ['-i' ]
220
+ affine_invert .append (affine_counter )
199
221
series += [transformation ]
222
+
223
+ if isdefined (self .inputs .invert_affine ):
224
+ diff_inv = set (self .inputs .invert_affine ) - set (affine_invert )
225
+ if diff_inv :
226
+ raise Exceptions ("Review invert_affine, not all indexes from invert_affine were used, "
227
+ "check the description for the full definition" )
228
+
200
229
return ' ' .join (series )
230
+
201
231
return super (WarpImageMultiTransform , self )._format_arg (opt , spec , val )
202
232
203
233
def _list_outputs (self ):
0 commit comments