Skip to content

Commit

Permalink
enh: add itk i/o test
Browse files Browse the repository at this point in the history
  • Loading branch information
oesteban committed Mar 2, 2022
1 parent 1fa7eeb commit 11d96cb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion nitransforms/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import numpy as np
import pytest
from h5py import File as H5File

import nibabel as nb
from nibabel.eulerangles import euler2mat
Expand Down Expand Up @@ -408,7 +409,7 @@ def test_afni_Displacements():
afni.AFNIDisplacementsField.from_image(field)


def test_itk_h5(testdata_path):
def test_itk_h5(tmpdir, testdata_path):
"""Test displacements fields."""
assert (
len(
Expand All @@ -430,6 +431,20 @@ def test_itk_h5(testdata_path):
)
)

tmpdir.chdir()
shutil.copy(
testdata_path / "ds-005_sub-01_from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5",
"test.h5",
)

with H5File("test.h5", "r+") as h5file:
h5group = h5file["TransformGroup"]
xfm = h5group[list(h5group.keys())[1]]
xfm["TransformType"][0] = b"InventTransform"

with pytest.raises(TransformIOError):
itk.ITKCompositeH5.from_filename("test.h5")


@pytest.mark.parametrize(
"file_type, test_file", [(LTA, "from-fsnative_to-scanner_mode-image.lta")]
Expand Down

0 comments on commit 11d96cb

Please sign in to comment.