@@ -286,17 +286,27 @@ def test_densefield_map_against_ants(testdata_path, tmp_path):
286
286
assert np .allclose (mapped , ants_pts , atol = 1e-6 )
287
287
288
288
289
- def test_constant_field_vs_ants (tmp_path ):
289
+ @pytest .mark .parametrize (
290
+ "mat" ,
291
+ [
292
+ np .eye (3 ),
293
+ np .diag ([- 1.0 , 1.0 , 1.0 ]),
294
+ np .diag ([1.0 , - 1.0 , 1.0 ]),
295
+ np .array ([[0.0 , 1.0 , 0.0 ], [1.0 , 0.0 , 0.0 ], [0.0 , 0.0 , 1.0 ]]),
296
+ ],
297
+ )
298
+ def test_constant_field_vs_ants (tmp_path , mat ):
290
299
"""Create a constant displacement field and compare mappings."""
291
300
292
- # Create a reference centered at the origin
301
+ # Create a reference centered at the origin with various axis orders/flips
293
302
shape = (25 , 25 , 25 )
294
- ref_affine = from_matvec (np .eye (3 ), - (np .array (shape ) - 1 ) / 2 )
303
+ center = (np .array (shape ) - 1 ) / 2
304
+ ref_affine = from_matvec (mat , - mat @ center )
295
305
296
306
field = np .zeros (shape + (3 ,), dtype = "float32" )
297
307
field [..., 0 ] = - 5
298
- field [..., 1 ] = 5
299
- field [..., 2 ] = 0 # No flip in the third axis
308
+ field [..., 1 ] = 2
309
+ field [..., 2 ] = 0 # No displacement in the third axis
300
310
301
311
warpfile = tmp_path / "const_disp.nii.gz"
302
312
itk_img = sitk .GetImageFromArray (field , isVector = True )
0 commit comments