@@ -180,3 +180,35 @@ def test_IntraModalMerge(tmpdir, shape, mshape):
180
180
merged_data = nb .load (merged ).get_fdata (dtype = "float32" )
181
181
new_mshape = (* mshape [:3 ], 2 if len (mshape ) == 3 else mshape [3 ] * 2 )
182
182
assert merged_data .shape == new_mshape
183
+
184
+
185
+ def test_conform_resize (tmpdir ):
186
+ fname = str (tmpdir / "test.nii" )
187
+
188
+ random_data = np .random .random (size = (5 , 5 , 5 ))
189
+ img = nb .Nifti1Image (random_data , np .eye (4 ))
190
+ img .to_filename (fname )
191
+ conform = pe .Node (im .Conform (), name = "conform" , base_dir = str (tmpdir ))
192
+ conform .inputs .in_file = fname
193
+ conform .inputs .target_zooms = (1 , 1 , 1.5 )
194
+ conform .inputs .target_shape = (5 , 5 , 5 )
195
+ res = conform .run ()
196
+
197
+ out_img = nb .load (res .outputs .out_file )
198
+ assert out_img .header .get_zooms () == conform .inputs .target_zooms
199
+
200
+
201
+ def test_conform_set_zooms (tmpdir ):
202
+ fname = str (tmpdir / "test.nii" )
203
+
204
+ random_data = np .random .random (size = (5 , 5 , 5 ))
205
+ img = nb .Nifti1Image (random_data , np .eye (4 ))
206
+ img .to_filename (fname )
207
+ conform = pe .Node (im .Conform (), name = "conform" , base_dir = str (tmpdir ))
208
+ conform .inputs .in_file = fname
209
+ conform .inputs .target_zooms = (1 , 1 , 1.002 )
210
+ conform .inputs .target_shape = (5 , 5 , 5 )
211
+ res = conform .run ()
212
+
213
+ out_img = nb .load (res .outputs .out_file )
214
+ assert np .allclose (out_img .header .get_zooms (), conform .inputs .target_zooms )
0 commit comments