|
4 | 4 | import pytest
|
5 | 5 | import h5py
|
6 | 6 |
|
7 |
| -from ..base import SpatialReference, SampledSpatialData, ImageGrid, TransformBase |
| 7 | +from ..base import SpatialReference, SampledSpatialData, ImageGrid, TransformBase, _as_homogeneous |
8 | 8 | from .. import linear as nitl
|
9 | 9 | from ..resampling import apply
|
10 | 10 |
|
@@ -42,11 +42,13 @@ def test_ImageGrid(get_testdata, image_orientation):
|
42 | 42 | # Test ras2vox and vox2ras conversions
|
43 | 43 | ijk = [[10, 10, 10], [40, 4, 20], [0, 0, 0], [s - 1 for s in im.shape[:3]]]
|
44 | 44 | xyz = [img._affine.dot(idx + [1])[:-1] for idx in ijk]
|
| 45 | + # xyz = np.array([np.tensordot(img._affine, idx + [1], axes=1)[:-1] for idx in ijk]) |
45 | 46 |
|
46 |
| - assert np.allclose(img.ras(ijk[0]), xyz[0]) |
| 47 | + # import pdb; pdb.set_trace() |
| 48 | + assert np.allclose(np.squeeze(img.ras(ijk[0])), xyz[0]) |
47 | 49 | assert np.allclose(np.round(img.index(xyz[0])), ijk[0])
|
48 |
| - assert np.allclose(img.ras(ijk), xyz) |
49 |
| - assert np.allclose(np.round(img.index(xyz)), ijk) |
| 50 | + assert np.allclose(img.ras(ijk).T, xyz) |
| 51 | + assert np.allclose(np.round(img.index(xyz)).T, ijk) |
50 | 52 |
|
51 | 53 | # nd index / coords
|
52 | 54 | idxs = img.ndindex
|
@@ -92,12 +94,13 @@ def _to_hdf5(klass, x5_root):
|
92 | 94 | img = nb.load(fname)
|
93 | 95 | imgdata = np.asanyarray(img.dataobj, dtype=img.get_data_dtype())
|
94 | 96 |
|
95 |
| - # Test identity transform |
96 | 97 | xfm = TransformBase()
|
97 |
| - xfm.reference = fname |
98 |
| - |
99 | 98 | with pytest.raises(TypeError):
|
100 | 99 | _ = xfm.ndim
|
| 100 | + |
| 101 | + # Test identity transform |
| 102 | + xfm = nitl.Affine() |
| 103 | + xfm.reference = fname |
101 | 104 | moved = apply(xfm, fname, order=0)
|
102 | 105 | assert np.all(
|
103 | 106 | imgdata == np.asanyarray(moved.dataobj, dtype=moved.get_data_dtype())
|
|
0 commit comments