Пример #1
0
 def test_affine(self):
     test_img = nib.Nifti1Image(np.zeros((1, 2, 3)), np.eye(4) * 20.0)
     test_img = correct_nifti_header_if_necessary(test_img)
     np.testing.assert_allclose(
         test_img.affine,
         np.array([[20.0, 0.0, 0.0, 0.0], [0.0, 20.0, 0.0, 0.0],
                   [0.0, 0.0, 20.0, 0.0], [0.0, 0.0, 0.0, 20.0]]),
     )
Пример #2
0
 def test_correct(self):
     test_img = nib.Nifti1Image(np.zeros((1, 2, 3)), np.eye(4))
     test_img.header.set_zooms((100, 100, 100))
     test_img = correct_nifti_header_if_necessary(test_img)
     np.testing.assert_allclose(
         test_img.affine,
         np.array([[100.0, 0.0, 0.0, 0.0], [0.0, 100.0, 0.0, 0.0],
                   [0.0, 0.0, 100.0, 0.0], [0.0, 0.0, 0.0, 1.0]]),
     )