Skip to content

Commit f785919

Browse files
committed
rf: move tests to more appropriate file
1 parent f0822f9 commit f785919

File tree

1 file changed

+0
-48
lines changed

1 file changed

+0
-48
lines changed

nitransforms/tests/test_io.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
from nibabel.affines import from_matvec
1818
from scipy.io import loadmat
1919
from nitransforms.linear import Affine
20-
from nitransforms import nonlinear as nitnl
2120
from nitransforms.io import (
2221
afni,
2322
fsl,
2423
lta as fs,
2524
itk,
26-
x5,
2725
)
2826
from nitransforms.io.lta import (
2927
VolumeGeometry as VG,
@@ -766,52 +764,6 @@ def test_itk_displacements(tmp_path, get_testdata, image_orientation, field_is_r
766764
np.testing.assert_allclose(LPS @ itk_nit_nii.affine, nit_nii.affine)
767765

768766

769-
@pytest.mark.parametrize("is_deltas", [True, False])
770-
def test_densefield_x5_roundtrip(tmp_path, is_deltas):
771-
"""Ensure dense field transforms roundtrip via X5."""
772-
ref = nb.Nifti1Image(np.zeros((2, 2, 2), dtype="uint8"), np.eye(4))
773-
disp = nb.Nifti1Image(np.random.rand(2, 2, 2, 3).astype("float32"), np.eye(4))
774-
775-
xfm = nitnl.DenseFieldTransform(disp, is_deltas=is_deltas, reference=ref)
776-
777-
node = xfm.to_x5(metadata={"GeneratedBy": "pytest"})
778-
assert node.type == "nonlinear"
779-
assert node.subtype == "densefield"
780-
assert node.representation == "displacements" if is_deltas else "deformations"
781-
assert node.domain.size == ref.shape
782-
assert node.metadata["GeneratedBy"] == "pytest"
783-
784-
fname = tmp_path / "test.x5"
785-
x5.to_filename(fname, [node])
786-
787-
xfm2 = nitnl.DenseFieldTransform.from_filename(fname, fmt="X5")
788-
789-
assert xfm2.reference.shape == ref.shape
790-
assert np.allclose(xfm2.reference.affine, ref.affine)
791-
assert xfm == xfm2
792-
793-
794-
def test_bspline_to_x5(tmp_path):
795-
"""Check BSpline transforms export to X5."""
796-
coeff = nb.Nifti1Image(np.zeros((2, 2, 2, 3), dtype="float32"), np.eye(4))
797-
ref = nb.Nifti1Image(np.zeros((2, 2, 2), dtype="uint8"), np.eye(4))
798-
799-
xfm = nitnl.BSplineFieldTransform(coeff, reference=ref)
800-
node = xfm.to_x5(metadata={"tool": "pytest"})
801-
assert node.type == "nonlinear"
802-
assert node.subtype == "bspline"
803-
assert node.representation == "coefficients"
804-
assert node.metadata["tool"] == "pytest"
805-
806-
fname = tmp_path / "bspline.x5"
807-
x5.to_filename(fname, [node])
808-
809-
xfm2 = nitnl.BSplineFieldTransform.from_filename(fname, fmt="X5")
810-
assert np.allclose(xfm._coeffs, xfm2._coeffs)
811-
assert xfm2.reference.shape == ref.shape
812-
assert np.allclose(xfm2.reference.affine, ref.affine)
813-
814-
815767
# Added tests for h5 orientation bug
816768
@pytest.mark.xfail(
817769
reason="GH-137/GH-171: displacement field dimension order is wrong",

0 commit comments

Comments
 (0)