From aa6470a9f4523b4ac72b8f13a5d03f70ff6ca0ba Mon Sep 17 00:00:00 2001 From: 36000 Date: Wed, 13 Nov 2024 14:44:21 -0800 Subject: [PATCH] add test for scalar name from file name --- AFQ/tests/test_definitions.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/AFQ/tests/test_definitions.py b/AFQ/tests/test_definitions.py index de1f774b..65c66aed 100644 --- a/AFQ/tests/test_definitions.py +++ b/AFQ/tests/test_definitions.py @@ -9,6 +9,7 @@ from AFQ.definitions.image import * # interprets images from eval from AFQ.definitions.mapping import * # interprets mappings from eval from AFQ.tests.test_api import create_dummy_bids_path +from AFQ.definitions.utils import name_from_path def test_str_instantiates_mixin(): @@ -23,6 +24,15 @@ def test_str_instantiates_mixin(): thresh_image_from_str.upper_bound) +def test_name_from_path(): + path = "/data/sub-01/ses-01/dwi/sub-01_ses-01_desc-icvf_dwi.nii.gz" + assert name_from_path(path) == "icvf" + path = "/data/sub-01/ses-01/dwi/sub-01_ses-01_desc-od_dwi.nii.gz" + assert name_from_path(path) == "od" + path = "/data/sub-01/ses-01/anat/sub-01_ses-01_T1w.nii.gz" + assert name_from_path(path) == "T1w" + + def test_resample_image(): image_data = np.zeros((2, 2, 2), dtype=bool) image_data[0] = True