Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add e2e test to ensure labelled/stat map is of expected size #367

Merged
merged 3 commits into from
Jun 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions e2e/volumes/test_parcellationmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,43 @@ def test_sparsemap_cache_uniqueness():
mp157 = siibra.get_map("julich 3.0", "colin 27", "statistical", spec="157")
mp175 = siibra.get_map("julich 3.0", "colin 27", "statistical", spec="175")
assert mp157.sparse_index.probs[0] != mp175.sparse_index.probs[0]

# checks labelled/statistical returns volume size matches template
# see https://github.com/FZJ-INM1-BDA/siibra-python/issues/302
MNI152_ID="minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2"
COLIN_ID="minds/core/referencespace/v1.0.0/7f39f7be-445b-47c0-9791-e971c0b6d992"

JBA_29_ID="minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579-290"
JBA_30_ID="minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579-300"

HOC1_RIGHT="Area hOc1 (V1, 17, CalcS) - right hemisphere"
FP1_RIGHT="Area Fp1 (FPole) - right hemisphere"

STATISTIC_ENDPOINT="statistical"
LABELLED_ENDPOINT="labelled"

map_shape_args = product(
((MNI152_ID, (193, 229, 193)),),
(JBA_29_ID,),
(STATISTIC_ENDPOINT, LABELLED_ENDPOINT),
(HOC1_RIGHT, FP1_RIGHT, None),
)

@pytest.mark.parametrize('space_shape,parc_id,map_endpoint,region_name', map_shape_args)
def test_map_shape(space_shape,parc_id,map_endpoint,region_name):
if region_name is None and map_endpoint == STATISTIC_ENDPOINT:
assert True
return
space_id, expected_shape = space_shape

volume_data = None
if region_name is not None:
region = siibra.get_region(parc_id, region_name)
volume_data = region.fetch_regional_map(space_id, map_endpoint)
else:
labelled_map = siibra.get_map(parc_id, space_id, map_endpoint)
assert labelled_map is not None
volume_data = labelled_map.fetch()

assert volume_data
assert volume_data.get_fdata().shape == expected_shape, f"{volume_data.get_fdata().shape}, {expected_shape}, {region_name}, {map_endpoint}, {space_id}"