Skip to content
Snippets Groups Projects
Commit 2d642abb authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

TEST: Replace voxToScaledVox with getAffine

parent 1f55df41
No related branches found
No related tags found
No related merge requests found
...@@ -1055,11 +1055,11 @@ def _test_Image_5D(imgtype): ...@@ -1055,11 +1055,11 @@ def _test_Image_5D(imgtype):
img = None img = None
def test_Image_voxToScaledVox_analyze(): _test_Image_voxToScaledVox(0) def test_Image_voxToFSL_analyze(): _test_Image_voxToFSL(0)
def test_Image_voxToScaledVox_nifti1(): _test_Image_voxToScaledVox(1) def test_Image_voxToFSL_nifti1(): _test_Image_voxToFSL(1)
def test_Image_voxToScaledVox_nifti2(): _test_Image_voxToScaledVox(2) def test_Image_voxToFSL_nifti2(): _test_Image_voxToFSL(2)
def _test_Image_voxToScaledVox(imgtype): def _test_Image_voxToFSL(imgtype):
dims = [(10, 10, 10)] dims = [(10, 10, 10)]
pixdims = [(-1, 1, 1), pixdims = [(-1, 1, 1),
...@@ -1088,8 +1088,8 @@ def _test_Image_voxToScaledVox(imgtype): ...@@ -1088,8 +1088,8 @@ def _test_Image_voxToScaledVox(imgtype):
expected = expect(imgtype, dim, pixdim) expected = expect(imgtype, dim, pixdim)
invexpected = npla.inv(expected) invexpected = npla.inv(expected)
assert np.all(np.isclose(expected, img.voxToScaledVoxMat)) assert np.all(np.isclose(expected, img.getAffine('voxel', 'fsl')))
assert np.all(np.isclose(invexpected, img.scaledVoxToVoxMat)) assert np.all(np.isclose(invexpected, img.getAffine('fsl', 'voxel')))
img = None img = None
......
...@@ -84,7 +84,7 @@ def _random_affine_field(): ...@@ -84,7 +84,7 @@ def _random_affine_field():
np.arange(ref.shape[2]), indexing='ij') np.arange(ref.shape[2]), indexing='ij')
rvoxels = np.vstack((rx.flatten(), ry.flatten(), rz.flatten())).T rvoxels = np.vstack((rx.flatten(), ry.flatten(), rz.flatten())).T
rcoords = affine.transform(rvoxels, ref.voxToScaledVoxMat) rcoords = affine.transform(rvoxels, ref.getAffine('voxel', 'fsl'))
scoords = affine.transform(rcoords, xform) scoords = affine.transform(rcoords, xform)
field = np.zeros(list(ref.shape[:3]) + [3]) field = np.zeros(list(ref.shape[:3]) + [3])
...@@ -162,7 +162,7 @@ def test_convertDeformationSpace(): ...@@ -162,7 +162,7 @@ def test_convertDeformationSpace():
np.random.randint(0, basefield.shape[1], 5), np.random.randint(0, basefield.shape[1], 5),
np.random.randint(0, basefield.shape[2], 5)] np.random.randint(0, basefield.shape[2], 5)]
refcoords = np.array(refcoords, dtype=int).T refcoords = np.array(refcoords, dtype=int).T
refcoords = affine.transform(refcoords, ref.voxToScaledVoxMat) refcoords = affine.transform(refcoords, ref.getAffine('voxel', 'fsl'))
srccoords = basefield.transform(refcoords) srccoords = basefield.transform(refcoords)
field = nonlinear.convertDeformationSpace(basefield, from_, to) field = nonlinear.convertDeformationSpace(basefield, from_, to)
...@@ -190,9 +190,9 @@ def test_DeformationField_transform(): ...@@ -190,9 +190,9 @@ def test_DeformationField_transform():
np.arange(ref.shape[1]), np.arange(ref.shape[1]),
np.arange(ref.shape[2]), indexing='ij') np.arange(ref.shape[2]), indexing='ij')
rvoxels = np.vstack((rx.flatten(), ry.flatten(), rz.flatten())).T rvoxels = np.vstack((rx.flatten(), ry.flatten(), rz.flatten())).T
rcoords = affine.transform(rvoxels, ref.voxToScaledVoxMat) rcoords = affine.transform(rvoxels, ref.getAffine('voxel', 'fsl'))
scoords = affine.transform(rcoords, xform) scoords = affine.transform(rcoords, xform)
svoxels = affine.transform(scoords, src.scaledVoxToVoxMat) svoxels = affine.transform(scoords, src.getAffine('fsl', 'voxel'))
absfield = np.zeros(list(ref.shape[:3]) + [3]) absfield = np.zeros(list(ref.shape[:3]) + [3])
absfield[:] = scoords.reshape(*it.chain(ref.shape, [3])) absfield[:] = scoords.reshape(*it.chain(ref.shape, [3]))
...@@ -217,9 +217,9 @@ def test_DeformationField_transform(): ...@@ -217,9 +217,9 @@ def test_DeformationField_transform():
# test out of bounds are returned as nan # test out of bounds are returned as nan
rvoxels = np.array([[-1, -1, -1], rvoxels = np.array([[-1, -1, -1],
[ 0, 0, 0]]) [ 0, 0, 0]])
rcoords = affine.transform(rvoxels, ref.voxToScaledVoxMat) rcoords = affine.transform(rvoxels, ref.getAffine('voxel', 'fsl'))
scoords = affine.transform(rcoords, xform) scoords = affine.transform(rcoords, xform)
svoxels = affine.transform(scoords, src.scaledVoxToVoxMat) svoxels = affine.transform(scoords, src.getAffine('fsl', 'voxel'))
got = relfield.transform(rcoords) got = relfield.transform(rcoords)
assert np.all(np.isnan(got[0, :])) assert np.all(np.isnan(got[0, :]))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment