Example #1
0
def test_base_transform():
    position = np.array([10, 20, 30])
    voxel_size = np.array([20, 20, 20])
    transform = suspect.transformation_matrix([1, 0, 0], [0, 1, 0], position, voxel_size)
    base = suspect.base.ImageBase(np.zeros(1), transform)
    np.testing.assert_equal(base.position, position)
    np.testing.assert_equal(base.voxel_size, voxel_size)
    transformed = base.to_scanner(0, 0, 0)
    np.testing.assert_equal(transformed, position)
    transformed = base.to_scanner(np.array([[0, 0, 0], [1, 1, 1]]))
    np.testing.assert_equal(transformed, [position, position + voxel_size])
    transformed = base.from_scanner(position)
    np.testing.assert_equal((0, 0, 0), transformed)
Example #2
0
def test_transforms_fail():
    base = suspect.base.ImageBase(np.zeros(1))
    with pytest.raises(ValueError):
        base.to_scanner(0, 0, 0)
    with pytest.raises(ValueError):
        base.from_scanner(0, 0, 0)
    with pytest.raises(ValueError):
        pos = base.position
    with pytest.raises(ValueError):
        vox = base.voxel_size
    with pytest.raises(ValueError):
        _transforms.normalise_positions_for_transform(0, 0)
    with pytest.raises(ValueError):
        slice_vec = base.slice_vector
    with pytest.raises(ValueError):
        slice_vec = base.row_vector
    with pytest.raises(ValueError):
        slice_vec = base.col_vector
Example #3
0
def test_create_base():
    base = suspect.base.ImageBase(np.zeros(1), np.eye(4))
    np.testing.assert_equal(base.transform, np.eye(4))
    vec = (1, 0, 0)
    tvec = base.to_scanner(*vec)
    np.testing.assert_equal(np.array(vec), tvec)