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

Use precalculated bounding boxes of image-features to speed up image feature query #583

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
52 changes: 38 additions & 14 deletions e2e/features/image/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,40 @@

# Update this as new configs are added
results = [
(siibra.features.get(siibra.get_template("big brain"), "CellbodyStainedSection"), 145),
(siibra.features.get(siibra.get_template("big brain"), "CellBodyStainedVolumeOfInterest"), 2),
(siibra.features.get(siibra.get_template("mni152"), "image", restrict_space=True), 4),
(siibra.features.get(siibra.get_template("mni152"), "image", restrict_space=False), 13),
(siibra.features.get(siibra.get_region('julich 3.1', 'hoc1 left'), "CellbodyStainedSection"), 45),
(siibra.features.get(siibra.get_region('julich 2.9', 'hoc1 left'), "CellbodyStainedSection"), 41)
(
siibra.features.get(siibra.get_template("big brain"), "CellbodyStainedSection"),
145,
),
(
siibra.features.get(
siibra.get_template("big brain"), "CellBodyStainedVolumeOfInterest"
),
2,
),
(
siibra.features.get(
siibra.get_template("mni152"), "image", restrict_space=True
),
4,
),
(
siibra.features.get(
siibra.get_template("mni152"), "image", restrict_space=False
),
14,
),
(
siibra.features.get(
siibra.get_region("julich 3.1", "hoc1 left"), "CellbodyStainedSection"
),
45,
),
(
siibra.features.get(
siibra.get_region("julich 2.9", "hoc1 left"), "CellbodyStainedSection"
),
41,
),
]
features = [f for fts, _ in results for f in fts]

Expand All @@ -21,10 +49,7 @@ def test_feature_has_datasets(feature: Image):


@pytest.mark.parametrize("features, result_len", results)
def test_image_query_results(
features: Image,
result_len: int
):
def test_image_query_results(features: Image, result_len: int):
assert len(features) == result_len


Expand All @@ -33,18 +58,17 @@ def test_images_datasets_names():
all_ds_names = {ds.name for f in features for ds in f.datasets}
end = time.time()
duration = start - end
assert len(all_ds_names) == 9, "expected 9 distinct names"
assert len(all_ds_names) == 10, "expected 9 distinct names"
assert duration < 1, "Expected getting dataset names to be less than 1s"


def test_color_channel_fetching():
dti_rgb_vol = [
f
for f in siibra.features.get(
siibra.get_template('mni152'),
siibra.features.fibres.DTIVolumeOfInterest
siibra.get_template("mni152"), siibra.features.fibres.DTIVolumeOfInterest
)
if 'rgb' in f.name
if "rgb" in f.name
][0]
_ = dti_rgb_vol.fetch(channel=0)
_ = dti_rgb_vol.fetch(channel=1)
Expand Down
24 changes: 24 additions & 0 deletions e2e/volumes/test_preconfigured_boundingbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import siibra
from siibra.features.image.image import Image
from siibra.volumes.volume import Volume
import pytest
from itertools import repeat

map_vols = [v for m in siibra.maps for v in m.volumes]
imagefeatures = [
feat
for ftype in siibra.features.Feature._SUBCLASSES[Image]
for feat in ftype._get_instances()
]
volumes = list(zip(map_vols, repeat(True))) + list(zip(imagefeatures, repeat(False)))


@pytest.mark.parametrize("volume, clip_flag", volumes)
def test_onthefly_and_preconfig_bboxes(volume: Volume, clip_flag: bool):
configured_bbox = volume._boundingbox
if configured_bbox is None:
pytest.skip(f"No preconfigured BoundingBox for {volume} is found. ")
volume._boundingbox = None
kwargs = {"clip": clip_flag}
bbox = volume.get_boundingbox(**kwargs)
assert configured_bbox == bbox, f" {volume}"
Loading
Loading