Skip to content

Commit c107a30

Browse files
committed
enh: add one unit test
1 parent 6ed47ae commit c107a30

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

sdcflows/interfaces/tests/test_bspline.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import nibabel as nb
55
import pytest
66

7-
from ..bspline import bspline_grid, Coefficients2Warp, BSplineApprox
7+
from ..bspline import bspline_grid, Coefficients2Warp, BSplineApprox, TOPUPCoeffReorient
88

99

1010
@pytest.mark.parametrize("testnum", range(100))
@@ -52,3 +52,26 @@ def test_bsplines(tmp_path, testnum):
5252

5353
# Absolute error of the interpolated field is always below 2 Hz
5454
assert np.all(np.abs(nb.load(test2.outputs.out_error).get_fdata()) < 2)
55+
56+
57+
def test_topup_coeffs(tmpdir, testdata_dir):
58+
"""Check the revision of TOPUP headers."""
59+
60+
tmpdir.chdir()
61+
result = TOPUPCoeffReorient(
62+
in_coeff=str(testdata_dir / "topup-coeff.nii.gz"),
63+
fmap_ref=str(testdata_dir / "epi.nii.gz"),
64+
).run()
65+
66+
nii = nb.load(result.outputs.out_coeff)
67+
ctrl = nb.load(testdata_dir / "topup-coeff-fixed.nii.gz")
68+
assert np.allclose(nii.affine, ctrl.affine)
69+
70+
nb.Nifti1Image(nii.get_fdata()[:-1, :-1, :-1], nii.affine, nii.header).to_filename(
71+
"failing.nii.gz"
72+
)
73+
74+
with pytest.raises(ValueError):
75+
TOPUPCoeffReorient(
76+
in_coeff="failing.nii.gz", fmap_ref=str(testdata_dir / "epi.nii.gz"),
77+
).run()
29.1 KB
Binary file not shown.
29 KB
Binary file not shown.

0 commit comments

Comments
 (0)