|
3 | 3 | from siibra.features.image.image import Image
|
4 | 4 | import time
|
5 | 5 |
|
6 |
| -# Update this as new configs are added |
7 |
| -results = [ |
8 |
| - ( |
9 |
| - siibra.features.get(siibra.get_template("big brain"), "CellbodyStainedSection"), |
10 |
| - 145, |
11 |
| - ), |
12 |
| - ( |
13 |
| - siibra.features.get( |
14 |
| - siibra.get_template("big brain"), "CellBodyStainedVolumeOfInterest" |
15 |
| - ), |
16 |
| - 2, |
17 |
| - ), |
18 |
| - ( |
19 |
| - siibra.features.get( |
20 |
| - siibra.get_template("mni152"), "image", restrict_space=True |
21 |
| - ), |
22 |
| - 4, |
23 |
| - ), |
24 |
| - ( |
25 |
| - siibra.features.get( |
26 |
| - siibra.get_template("mni152"), "image", restrict_space=False |
27 |
| - ), |
28 |
| - 13, |
29 |
| - ), |
30 |
| - ( |
31 |
| - siibra.features.get( |
32 |
| - siibra.get_region("julich 3.1", "hoc1 left"), "CellbodyStainedSection" |
33 |
| - ), |
34 |
| - 45, |
35 |
| - ), |
36 |
| - ( |
37 |
| - siibra.features.get( |
38 |
| - siibra.get_region("julich 2.9", "hoc1 left"), "CellbodyStainedSection" |
39 |
| - ), |
40 |
| - 41, |
41 |
| - ), |
| 6 | +PRERELEASE_FEATURES_W_NO_DATASET = [ |
| 7 | + "The Enriched Connectome - Block face images of full sagittal human brain sections (blockface)", |
| 8 | + "The Enriched Connectome - 3D polarized light imaging connectivity data of full sagittal human brain sections (HSV fibre orientation map)", |
42 | 9 | ]
|
43 |
| -features = [f for fts, _ in results for f in fts] |
| 10 | +all_image_features = [f for ft in siibra.features.Feature._SUBCLASSES[siibra.features.image.image.Image] for f in ft._get_instances()] |
44 | 11 |
|
45 | 12 |
|
46 |
| -@pytest.mark.parametrize("feature", features) |
| 13 | +@pytest.mark.parametrize("feature", all_image_features) |
47 | 14 | def test_feature_has_datasets(feature: Image):
|
48 |
| - assert len(feature.datasets) > 0 |
49 |
| - |
50 |
| - |
51 |
| -@pytest.mark.parametrize("features, result_len", results) |
52 |
| -def test_image_query_results(features: Image, result_len: int): |
53 |
| - assert len(features) == result_len |
| 15 | + if feature.name in PRERELEASE_FEATURES_W_NO_DATASET: |
| 16 | + if len(feature.datasets) > 0: |
| 17 | + pytest.fail(f"Feature '{feature}' was listed as prerelase previosly but now have dataset information. Please update `PRERELEASE_FEATURES_W_NO_DATASET`") |
| 18 | + pytest.skip(f"Feature '{feature}' has no datasets yet as it is a prerelease data.") |
| 19 | + assert len(feature.datasets) > 0, f"{feature} has no datasets" |
54 | 20 |
|
55 | 21 |
|
56 | 22 | def test_images_datasets_names():
|
57 | 23 | start = time.time()
|
58 |
| - all_ds_names = {ds.name for f in features for ds in f.datasets} |
| 24 | + all_ds_names = {ds.name for f in all_image_features for ds in f.datasets} |
59 | 25 | end = time.time()
|
60 | 26 | duration = start - end
|
61 |
| - assert len(all_ds_names) == 9, "expected 9 distinct names" |
| 27 | + assert len(all_ds_names) == 10, "expected 10 distinct names" # this must be updated if new datasets are added |
62 | 28 | assert duration < 1, "Expected getting dataset names to be less than 1s"
|
63 | 29 |
|
64 | 30 |
|
| 31 | +# Update this as new configs are added |
| 32 | + |
| 33 | +query_and_results = [ |
| 34 | + (siibra.features.get(siibra.get_template("big brain"), "CellbodyStainedSection"), 145), |
| 35 | + (siibra.features.get(siibra.get_template("big brain"), "CellBodyStainedVolumeOfInterest"), 2), |
| 36 | + (siibra.features.get(siibra.get_template("mni152"), "image", restrict_space=True), 4), |
| 37 | + (siibra.features.get(siibra.get_template("mni152"), "image", restrict_space=False), 13), # TODO: should this query find all the images or it is okay if bigbrain sections fail? |
| 38 | + (siibra.features.get(siibra.get_region('julich 3.1', 'hoc1 left'), "CellbodyStainedSection"), 45), |
| 39 | + (siibra.features.get(siibra.get_region('julich 2.9', 'hoc1 left'), "CellbodyStainedSection"), 41) |
| 40 | +] |
| 41 | + |
| 42 | + |
| 43 | +@pytest.mark.parametrize("query_results, result_len", query_and_results) |
| 44 | +def test_image_query_results( |
| 45 | + query_results: Image, |
| 46 | + result_len: int |
| 47 | +): |
| 48 | + assert len(query_results) == result_len |
| 49 | + |
| 50 | + |
65 | 51 | def test_color_channel_fetching():
|
66 | 52 | dti_rgb_vol = [
|
67 | 53 | f
|
|
0 commit comments