@@ -66,16 +66,35 @@ def test_concat():
66
66
img0_mem = Nifti1Image (data0 , affine )
67
67
img1_mem = Nifti1Image (data0 - 10 , affine )
68
68
69
- concat_img1 = concat_images ([img0_mem , img1_mem ])
69
+ # 4d, same shape, append on axis 3
70
+ concat_img1 = concat_images ([img0_mem , img1_mem ], axis = 3 )
70
71
expected_shape1 = shape_4D .copy ()
71
72
expected_shape1 [- 1 ] *= 2
72
73
assert_array_equal (concat_img1 .shape , expected_shape1 )
73
74
75
+ # 4d, same shape, append on axis 0
74
76
concat_img2 = concat_images ([img0_mem , img1_mem ], axis = 0 )
75
77
expected_shape2 = shape_4D .copy ()
76
78
expected_shape2 [0 ] *= 2
77
79
assert_array_equal (concat_img2 .shape , expected_shape2 )
78
80
81
+ # 4d, same shape, append on axis -1
82
+ concat_img3 = concat_images ([img0_mem , img1_mem ], axis = - 1 )
83
+ expected_shape3 = shape_4D .copy ()
84
+ expected_shape3 [- 1 ] *= 2
85
+ assert_array_equal (concat_img3 .shape , expected_shape3 )
86
+
87
+ # 4d, different shape, append on axis that's different
88
+ print ('%s %s' % (str (concat_img3 .shape ), str (img1_mem .shape )))
89
+ concat_img4 = concat_images ([concat_img3 , img1_mem ], axis = - 1 )
90
+ expected_shape4 = shape_4D .copy ()
91
+ expected_shape4 [- 1 ] *= 3
92
+ assert_array_equal (concat_img4 .shape , expected_shape4 )
93
+
94
+ # 4d, different shape, append on axis that's not different...
95
+ # Doesn't work!
96
+ assert_raises (ValueError , concat_images , [concat_img3 , img1_mem ], axis = 1 )
97
+
79
98
80
99
def test_closest_canonical ():
81
100
arr = np .arange (24 ).reshape ((2 ,3 ,4 ,1 ))
0 commit comments