Example #1
0
def test_affine_raises(raw_image):
    """Make sure that the affine transformation matrix must be the right size"""
    with pytest.raises(ValueError):
        affineGPU(raw_image, np.eye(5))
    with pytest.raises(ValueError):
        affineGPU(raw_image, np.eye(3))
    with pytest.raises(ValueError):
        affineGPU(raw_image, np.eye(2))
Example #2
0
 def test_affine_translate(self):
     """
     test affine translation leads to a bunch of empty values up to
     but not more than the requested amount of translation
     """
     xpix = -50
     ypix = -100
     zpix = -3
     T = np.array([[1, 0, 0, xpix], [0, 1, 0, ypix], [0, 0, 1, zpix],
                   [0, 0, 0, 1]])
     result = affineGPU(self.raw, T)
     self.assertFalse(np.allclose(self.raw, result))
     self.assertTrue(np.alltrue(result[:-zpix] == 0))
     self.assertFalse(np.alltrue(result[:-zpix + 1] == 0))
     self.assertTrue(np.alltrue(result[:, :-xpix, :-zpix] == 0))
Example #3
0
def test_affine_translate(raw_image):
    """
    test affine translation leads to a bunch of empty values up to
    but not more than the requested amount of translation
    """
    xpix = -50
    ypix = -100
    zpix = -3
    T = np.array([[1, 0, 0, xpix], [0, 1, 0, ypix], [0, 0, 1, zpix],
                  [0, 0, 0, 1]])
    result = affineGPU(raw_image, T)
    assert not np.allclose(raw_image, result, atol=10)
    assert np.all(result[:-zpix] == 0)
    assert not np.all(result[:-zpix + 1] == 0)
    assert np.all(result[:, :-xpix, :-zpix] == 0)
Example #4
0
 def test_affine_raises(self):
     """
     Make sure that the affine transformation matrix must be the right size
     """
     with self.assertRaises(ValueError):
         affineGPU(self.raw, np.eye(5))
     with self.assertRaises(ValueError):
         affineGPU(self.raw, np.eye(3))
     with self.assertRaises(ValueError):
         affineGPU(self.raw, np.eye(2))
Example #5
0
 def test_affine_translate_RA(self):
     """
     make sure the referenceing object works to accept transformation
     matrices in units of sample space, instead of world coordinates
     """
     xpix = -50
     ypix = -100
     zpix = -3
     T = np.array([[1, 0, 0, xpix], [0, 1, 0, ypix], [0, 0, 1, zpix],
                   [0, 0, 0, 1]])
     voxsize = [0.5, 0.5, 0.5]
     result = affineGPU(self.raw, T, voxsize)
     self.assertFalse(np.allclose(self.raw, result))
     self.assertTrue(np.alltrue(result[:-zpix * 2] == 0))
     self.assertFalse(np.alltrue(result[:(-zpix * 2) + 1] == 0))
     self.assertTrue(np.alltrue(result[:, :-xpix * 2, :-zpix * 2] == 0))
Example #6
0
def test_affine_translate_RA(raw_image):
    """
    make sure the referenceing object works to accept transformation
    matrices in units of sample space, instead of world coordinates
    """
    xpix = -50
    ypix = -100
    zpix = -3
    T = np.array([[1, 0, 0, xpix], [0, 1, 0, ypix], [0, 0, 1, zpix],
                  [0, 0, 0, 1]])
    voxsize = (0.5, 0.5, 0.5)
    result = affineGPU(raw_image, T, voxsize)
    assert not np.allclose(raw_image, result, atol=10)
    assert np.all(result[:-zpix * 2] == 0)
    assert not np.all(result[:(-zpix * 2) + 1] == 0)
    assert np.all(result[:, :-xpix * 2, :-zpix * 2] == 0)
Example #7
0
 def test_affine_eye(self):
     """
     test that an affine transform with the identity matrix does not change the input
     """
     result = affineGPU(self.raw, np.eye(4))
     self.assertTrue(np.allclose(result, result))
Example #8
0
def test_affine_eye(raw_image):
    """test that an affine transform with identity matrix does not change the input"""
    result = affineGPU(raw_image, np.eye(4))
    npt.assert_allclose(result, raw_image)