|
1 | 1 | import pytest
|
2 |
| -import siibra |
3 | 2 | from e2e.util import check_duplicate
|
4 | 3 |
|
| 4 | +import siibra |
| 5 | +from siibra.locations import Location, PointCloud |
| 6 | +from siibra.livequeries.bigbrain import WagstylProfileLoader |
| 7 | +from siibra.features.feature import CompoundFeature |
| 8 | + |
| 9 | +import numpy as np |
| 10 | + |
5 | 11 |
|
6 | 12 | # We get all registered subclasses of Feature
|
7 | 13 | @pytest.mark.parametrize(
|
@@ -67,8 +73,53 @@ def test_querying_with_volume():
|
67 | 73 | # Use features with location anchors only. Because hybrid ones will also
|
68 | 74 | # employ semantic links between regions, potentially changing the result.
|
69 | 75 | region = siibra.get_region("julich 2.9", "ca1")
|
70 |
| - volume = region.get_regional_mask('mni152') |
| 76 | + volume = region.get_regional_mask("mni152") |
71 | 77 | profiles_region = siibra.features.get(region, "BigBrainIntensityProfile")[0]
|
72 | 78 | profiles_volume = siibra.features.get(volume, "BigBrainIntensityProfile")[0]
|
73 | 79 | # the ids will be different but the content has to be the same. Even the order.
|
74 |
| - assert [p.location for p in profiles_region] == [p.location for p in profiles_volume] |
| 80 | + assert [p.location for p in profiles_region] == [ |
| 81 | + p.location for p in profiles_volume |
| 82 | + ] |
| 83 | + |
| 84 | + |
| 85 | +WagstylProfileLoader._load() |
| 86 | +verts = WagstylProfileLoader._vertices |
| 87 | +np.random.seed(10) |
| 88 | +loc_queries = [ |
| 89 | + ( |
| 90 | + siibra.get_map("julich 2.9", "bigbrain") |
| 91 | + .get_volume("hoc1 left") |
| 92 | + .get_boundingbox(clip=True), |
| 93 | + "BigBrainIntensityProfile", |
| 94 | + 13968, |
| 95 | + ), |
| 96 | + ( |
| 97 | + PointCloud(verts[np.random.randint(0, len(verts) - 1, 100)], space="bigbrain"), |
| 98 | + "BigBrainIntensityProfile", |
| 99 | + 100, |
| 100 | + ), |
| 101 | + ( |
| 102 | + PointCloud( |
| 103 | + np.concatenate( |
| 104 | + [ |
| 105 | + verts[np.random.randint(0, len(verts) - 1, 100)] + 1000, |
| 106 | + verts[np.random.randint(0, len(verts) - 1, 10)], |
| 107 | + ] |
| 108 | + ), |
| 109 | + space="bigbrain", |
| 110 | + ), |
| 111 | + "BigBrainIntensityProfile", |
| 112 | + 10, |
| 113 | + ), |
| 114 | +] |
| 115 | + |
| 116 | + |
| 117 | +@pytest.mark.parametrize("loc, feat_type, res_len", loc_queries) |
| 118 | +def test_query_w_locations(loc: Location, feat_type: str, res_len: int): |
| 119 | + results = siibra.features.get(loc, feat_type) |
| 120 | + assert len(results) > 0 |
| 121 | + assert results[0].data is not None |
| 122 | + if len(results) == 1 and isinstance(results[0], CompoundFeature): |
| 123 | + assert len(results[0]) == res_len |
| 124 | + else: |
| 125 | + assert len(results) == res_len |
0 commit comments