@@ -265,6 +265,37 @@ def test_mgh_load_fileobj():
265
265
assert_array_equal (img .get_data (), img2 .get_data ())
266
266
267
267
268
+ def test_mgh_reject_little_endian ():
269
+ bblock = b'\x00 ' * MGHHeader .template_dtype .itemsize
270
+ with assert_raises (ValueError ):
271
+ MGHHeader (bblock , endianness = '<' )
272
+
273
+
274
+ def test_mgh_affine_default ():
275
+ hdr = MGHHeader ()
276
+ hdr ['ras_good' ] = 0
277
+ hdr2 = MGHHeader (hdr .binaryblock )
278
+ assert_equal (hdr2 ['ras_good' ], 1 )
279
+ assert_array_equal (hdr ['x_ras' ], hdr2 ['x_ras' ])
280
+ assert_array_equal (hdr ['y_ras' ], hdr2 ['y_ras' ])
281
+ assert_array_equal (hdr ['z_ras' ], hdr2 ['z_ras' ])
282
+ assert_array_equal (hdr ['c_ras' ], hdr2 ['c_ras' ])
283
+
284
+
285
+ def test_mgh_set_data_shape ():
286
+ hdr = MGHHeader ()
287
+ hdr .set_data_shape ((5 ,))
288
+ assert_array_equal (hdr .get_data_shape (), (5 , 1 , 1 ))
289
+ hdr .set_data_shape ((5 , 4 ))
290
+ assert_array_equal (hdr .get_data_shape (), (5 , 4 , 1 ))
291
+ hdr .set_data_shape ((5 , 4 , 3 ))
292
+ assert_array_equal (hdr .get_data_shape (), (5 , 4 , 3 ))
293
+ hdr .set_data_shape ((5 , 4 , 3 , 2 ))
294
+ assert_array_equal (hdr .get_data_shape (), (5 , 4 , 3 , 2 ))
295
+ with assert_raises (ValueError ):
296
+ hdr .set_data_shape ((5 , 4 , 3 , 2 , 1 ))
297
+
298
+
268
299
class TestMGHImage (tsi .TestSpatialImage , tsi .MmapImageMixin ):
269
300
""" Apply general image tests to MGHImage
270
301
"""
0 commit comments