@@ -34,17 +34,14 @@ def assert_all_in(in_shape, in_affine, out_shape, out_affine):
34
34
assert_true (np .all (out_grid < np .array (out_shape ) + TINY ))
35
35
36
36
37
- def test_vox2out_vox ():
38
- # Test world space bounding box
39
- # Test basic case, identity, no voxel sizes passed
40
- shape , aff = vox2out_vox (((2 , 3 , 4 ), np .eye (4 )))
41
- assert_array_equal (shape , (2 , 3 , 4 ))
42
- assert_array_equal (aff , np .eye (4 ))
37
+ def get_outspace_params ():
38
+ # Return in_shape, in_aff, vox, out_shape, out_aff for output space tests
39
+ # Put in function to use also for resample_to_output tests
43
40
# Some affines as input to the tests
44
41
trans_123 = [[1 , 0 , 0 , 1 ], [0 , 1 , 0 , 2 ], [0 , 0 , 1 , 3 ], [0 , 0 , 0 , 1 ]]
45
42
trans_m123 = [[1 , 0 , 0 , - 1 ], [0 , 1 , 0 , - 2 ], [0 , 0 , 1 , - 3 ], [0 , 0 , 0 , 1 ]]
46
43
rot_3 = from_matvec (euler2mat (np .pi / 4 ), [0 , 0 , 0 ])
47
- for in_shape , in_aff , vox , out_shape , out_aff in (
44
+ return ( # in_shape, in_aff, vox, out_shape, out_aff
48
45
# Identity
49
46
((2 , 3 , 4 ), np .eye (4 ), None , (2 , 3 , 4 ), np .eye (4 )),
50
47
# Flip first axis
@@ -80,7 +77,16 @@ def test_vox2out_vox():
80
77
# Number of voxel sizes matches length
81
78
((2 , 3 ), np .diag ([4 , 5 , 6 , 1 ]), (4 , 5 ),
82
79
(2 , 3 ), np .diag ([4 , 5 , 1 , 1 ])),
83
- ):
80
+ )
81
+
82
+
83
+ def test_vox2out_vox ():
84
+ # Test world space bounding box
85
+ # Test basic case, identity, no voxel sizes passed
86
+ shape , aff = vox2out_vox (((2 , 3 , 4 ), np .eye (4 )))
87
+ assert_array_equal (shape , (2 , 3 , 4 ))
88
+ assert_array_equal (aff , np .eye (4 ))
89
+ for in_shape , in_aff , vox , out_shape , out_aff in get_outspace_params ():
84
90
img = Nifti1Image (np .ones (in_shape ), in_aff )
85
91
for input in ((in_shape , in_aff ), img ):
86
92
shape , aff = vox2out_vox (input , vox )
0 commit comments