From 91a4f9ecacb7577668a53a5f9d75320bd78afb04 Mon Sep 17 00:00:00 2001 From: Philip Cook Date: Mon, 25 Nov 2024 09:55:12 -0500 Subject: [PATCH 1/2] ENH: Test reg precision --- tests/test_registration.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/test_registration.py b/tests/test_registration.py index e222a3ab..6fe843fa 100644 --- a/tests/test_registration.py +++ b/tests/test_registration.py @@ -462,10 +462,24 @@ def test_label_image_registration(self): mi = ants.resample_image(mi, (60,60), 1, 0) fi_seg = ants.threshold_image(fi, "Kmeans", 3)-1 mi_seg = ants.threshold_image(mi, "Kmeans", 3)-1 - mytx = ants.label_image_registration([fi_seg], + mytx = ants.label_image_registration([fi_seg], [mi_seg], fixed_intensity_images=fi, moving_intensity_images=mi) + + def test_reg_precision_option(self): + # Check that registration and apply transforms works with float and double precision + fi = ants.image_read(ants.get_ants_data("r16")) + mi = ants.image_read(ants.get_ants_data("r64")) + fi = ants.resample_image(fi, (60, 60), 1, 0) + mi = ants.resample_image(mi, (60, 60), 1, 0) + mytx = ants.registration(fixed=fi, moving=mi, type_of_transform="SyN") # should be float precision + info = ants.image_header_info(ants.image_read(mytx["fwdtransforms"][0])) + self.assertEqual(info['pixeltype'], 'float') + mytx = ants.registration(fixed=fi, moving=mi, type_of_transform="SyN", singleprecision=False) + info = ants.image_header_info(ants.image_read(mytx["fwdtransforms"][0])) + self.assertEqual(info['pixeltype'], 'double') + if __name__ == "__main__": run_tests() From b201507619b8bfd7ff784e73597a358d114ed3a3 Mon Sep 17 00:00:00 2001 From: Philip Cook Date: Mon, 25 Nov 2024 12:07:20 -0500 Subject: [PATCH 2/2] BUG: Test files not images --- tests/test_registration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_registration.py b/tests/test_registration.py index 6fe843fa..697e1397 100644 --- a/tests/test_registration.py +++ b/tests/test_registration.py @@ -475,10 +475,10 @@ def test_reg_precision_option(self): fi = ants.resample_image(fi, (60, 60), 1, 0) mi = ants.resample_image(mi, (60, 60), 1, 0) mytx = ants.registration(fixed=fi, moving=mi, type_of_transform="SyN") # should be float precision - info = ants.image_header_info(ants.image_read(mytx["fwdtransforms"][0])) + info = ants.image_header_info(mytx["fwdtransforms"][0]) self.assertEqual(info['pixeltype'], 'float') mytx = ants.registration(fixed=fi, moving=mi, type_of_transform="SyN", singleprecision=False) - info = ants.image_header_info(ants.image_read(mytx["fwdtransforms"][0])) + info = ants.image_header_info(mytx["fwdtransforms"][0]) self.assertEqual(info['pixeltype'], 'double') if __name__ == "__main__":