From e7d26976c265c39a956fd9864239f2aaaee06df5 Mon Sep 17 00:00:00 2001 From: Philip Cook Date: Tue, 6 Aug 2024 21:57:54 -0400 Subject: [PATCH] ENH: Fix a bug, test for it --- tests/test_core_ants_transform.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_core_ants_transform.py b/tests/test_core_ants_transform.py index f6aef044..4b195ced 100644 --- a/tests/test_core_ants_transform.py +++ b/tests/test_core_ants_transform.py @@ -175,6 +175,15 @@ def test_apply_ants_transform_to_image(self): tx.set_parameters((0.9,0,0,1.1,10,11)) img2 = ants.apply_ants_transform_to_image(tx, img, img) + def test_apply_ants_transform_to_image_displacement_field(self): + img = ants.image_read(ants.get_ants_data("r27")).clone('float') + img2 = ants.image_read(ants.get_ants_data("r16")).clone('float') + reg = ants.registration(fixed=img, moving=img2, type_of_transform="SyN") + tra = ants.transform_from_displacement_field(ants.image_read(reg['fwdtransforms'][0])) + deformed = tra.apply_to_image(img2, reference=img) + deformed_aat = ants.apply_transforms(img, img2, reg['fwdtransforms'][0], singleprecision=True) + nptest.assert_allclose(deformed.numpy(), deformed_aat.numpy(), atol=1e-6) + def test_invert_ants_transform(self): img = ants.image_read(ants.get_ants_data("r16")).clone('float') tx = ants.new_ants_transform(dimension=2)