From ca9e2110729777ca8605497b1aff98f340edc4c3 Mon Sep 17 00:00:00 2001 From: Ahmet Nihat Simsek Date: Mon, 25 Mar 2024 10:42:11 +0100 Subject: [PATCH 01/15] Extract bboxes from image feature configs instead --- siibra/configuration/factory.py | 13 ++++++++++++- siibra/features/image/image.py | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/siibra/configuration/factory.py b/siibra/configuration/factory.py index e787de8e0..185ed49c3 100644 --- a/siibra/configuration/factory.py +++ b/siibra/configuration/factory.py @@ -24,7 +24,7 @@ ) from ..features.image import sections, volume_of_interest from ..core import atlas, parcellation, space, region -from ..locations import point, pointset +from ..locations import point, pointset, boundingbox from ..retrieval import datasets, repositories from ..volumes import volume, sparsemap, parcellationmap from ..volumes.providers.provider import VolumeProvider @@ -349,6 +349,16 @@ def build_pointset(cls, spec): coords = [tuple(c) for c in spec.get("coordinates")] return pointset.PointSet(coords, space=space_id) + @classmethod + @build_type("siibra/location/boundingbox/v0.1") + def build_boundingbox(cls, spec): + bboxspec = spec.get("boundingbox", None) + if bboxspec is None: + return None + space_id = spec.get("space").get("@id") + coords = [tuple(c) for c in bboxspec.get("coordinates")] + return boundingbox.BoundingBox(coords[0], coords[1], space=space_id) + @classmethod @build_type("siibra/feature/fingerprint/receptor/v0.1") def build_receptor_density_fingerprint(cls, spec): @@ -399,6 +409,7 @@ def build_section(cls, spec): "space_spec": vol._space_spec, "providers": vol._providers.values(), "datasets": cls.extract_datasets(spec), + "boundingbox": cls.build_boundingbox(spec) } modality = spec.get('modality', "") if modality == "cell body staining": diff --git a/siibra/features/image/image.py b/siibra/features/image/image.py index 26141ccf9..22cf7f17f 100644 --- a/siibra/features/image/image.py +++ b/siibra/features/image/image.py @@ -21,6 +21,7 @@ from ...volumes import volume as _volume from ...volumes.providers import provider +from ...locations import boundingbox from typing import List @@ -63,6 +64,7 @@ def __init__( providers: List[provider.VolumeProvider], region: str = None, datasets: List = [], + boundingbox: "boundingbox.BoundingBox" = None ): feature.Feature.__init__( self, @@ -83,6 +85,15 @@ def __init__( self._anchor_cached = ImageAnchor(self, region=region) self._description_cached = None self._name_cached = name + self._boundingbox = boundingbox + + def get_boundingbox( + self, clip: bool = True, background: float = 0.0, **fetch_kwargs + ) -> "boundingbox.BoundingBox": + if self._boundingbox is None: + return super().get_boundingbox(clip, background, **fetch_kwargs) + else: + return self._boundingbox def _to_zip(self, fh: ZipFile): super()._to_zip(fh) From 269aaf9c2c9706cebf3d89bcf42b75ba924c9926 Mon Sep 17 00:00:00 2001 From: Ahmet Nihat Simsek Date: Mon, 25 Mar 2024 10:42:45 +0100 Subject: [PATCH 02/15] Use `enh_use_precalc_img_bboxes` config branch to test --- siibra/configuration/configuration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/siibra/configuration/configuration.py b/siibra/configuration/configuration.py index 00d818546..44545567d 100644 --- a/siibra/configuration/configuration.py +++ b/siibra/configuration/configuration.py @@ -42,7 +42,7 @@ class Configuration: conn( server_or_owner, project_or_repo, - reftag="siibra-{}".format(__version__), + reftag="enh_use_precalc_img_bboxes", skip_branchtest=True ) for conn, server_or_owner, project_or_repo in CONFIG_REPOS From 5845cbcbf1d6061965ede600fa08a2fb56719fe9 Mon Sep 17 00:00:00 2001 From: Ahmet Nihat Simsek Date: Tue, 9 Apr 2024 10:54:29 +0200 Subject: [PATCH 03/15] Enh: allow digesting bounding boxes of volumes from preconfiguration --- siibra/configuration/factory.py | 8 +++++--- siibra/features/image/image.py | 13 +------------ siibra/volumes/volume.py | 5 +++++ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/siibra/configuration/factory.py b/siibra/configuration/factory.py index 185ed49c3..bb751959c 100644 --- a/siibra/configuration/factory.py +++ b/siibra/configuration/factory.py @@ -274,7 +274,10 @@ def build_volume(cls, spec): name=spec.get("name", ""), variant=spec.get("variant"), datasets=cls.extract_datasets(spec), + bbox=cls.build_boundingbox(spec) ) + if result._boundingbox is not None: + assert result._boundingbox.space == result.space, "BoundingBox of a volume cannot be in a different space than the volume's space." return result @@ -355,7 +358,7 @@ def build_boundingbox(cls, spec): bboxspec = spec.get("boundingbox", None) if bboxspec is None: return None - space_id = spec.get("space").get("@id") + space_id = bboxspec.get("space").get("@id") coords = [tuple(c) for c in bboxspec.get("coordinates")] return boundingbox.BoundingBox(coords[0], coords[1], space=space_id) @@ -408,8 +411,7 @@ def build_section(cls, spec): "region": spec.get('region', None), "space_spec": vol._space_spec, "providers": vol._providers.values(), - "datasets": cls.extract_datasets(spec), - "boundingbox": cls.build_boundingbox(spec) + "datasets": cls.extract_datasets(spec) } modality = spec.get('modality', "") if modality == "cell body staining": diff --git a/siibra/features/image/image.py b/siibra/features/image/image.py index 22cf7f17f..6d989b0d8 100644 --- a/siibra/features/image/image.py +++ b/siibra/features/image/image.py @@ -21,7 +21,6 @@ from ...volumes import volume as _volume from ...volumes.providers import provider -from ...locations import boundingbox from typing import List @@ -63,8 +62,7 @@ def __init__( space_spec: dict, providers: List[provider.VolumeProvider], region: str = None, - datasets: List = [], - boundingbox: "boundingbox.BoundingBox" = None + datasets: List = [] ): feature.Feature.__init__( self, @@ -85,15 +83,6 @@ def __init__( self._anchor_cached = ImageAnchor(self, region=region) self._description_cached = None self._name_cached = name - self._boundingbox = boundingbox - - def get_boundingbox( - self, clip: bool = True, background: float = 0.0, **fetch_kwargs - ) -> "boundingbox.BoundingBox": - if self._boundingbox is None: - return super().get_boundingbox(clip, background, **fetch_kwargs) - else: - return self._boundingbox def _to_zip(self, fh: ZipFile): super()._to_zip(fh) diff --git a/siibra/volumes/volume.py b/siibra/volumes/volume.py index 2f48b0411..5b1bc6fdb 100644 --- a/siibra/volumes/volume.py +++ b/siibra/volumes/volume.py @@ -75,12 +75,14 @@ def __init__( name: str = "", variant: str = None, datasets: List['TypeDataset'] = [], + bbox: "boundingbox.BoundingBox" = None ): self._name = name self._space_spec = space_spec self.variant = variant self._providers: Dict[str, _provider.VolumeProvider] = {} self.datasets = datasets + self._boundingbox = bbox for provider in providers: srctype = provider.srctype assert srctype not in self._providers @@ -140,6 +142,9 @@ def get_boundingbox(self, clip: bool = True, background: float = 0.0, **fetch_kw RuntimeError If the volume provider does not have a bounding box calculator. """ + if self._boundingbox is not None and len(fetch_kwargs) == 0: + return self._boundingbox + fmt = fetch_kwargs.get("format") if (fmt is not None) and (fmt not in self.formats): raise ValueError( From 5e2efa0c7478d3da9f9b58f26705ffb69255e45a Mon Sep 17 00:00:00 2001 From: Ahmet Nihat Simsek Date: Tue, 9 Apr 2024 15:42:49 +0200 Subject: [PATCH 04/15] Check `BoundingBox._space_spec` w `Volume._space_spec` to prevent recursion --- siibra/configuration/factory.py | 6 +++--- siibra/locations/location.py | 14 +++++++++++--- test/core/test_parcellation.py | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/siibra/configuration/factory.py b/siibra/configuration/factory.py index bb751959c..de1478856 100644 --- a/siibra/configuration/factory.py +++ b/siibra/configuration/factory.py @@ -277,7 +277,7 @@ def build_volume(cls, spec): bbox=cls.build_boundingbox(spec) ) if result._boundingbox is not None: - assert result._boundingbox.space == result.space, "BoundingBox of a volume cannot be in a different space than the volume's space." + assert result._boundingbox._space_spec == result._space_spec, "BoundingBox of a volume cannot be in a different space than the volume's space." return result @@ -358,9 +358,9 @@ def build_boundingbox(cls, spec): bboxspec = spec.get("boundingbox", None) if bboxspec is None: return None - space_id = bboxspec.get("space").get("@id") + space_spec = bboxspec.get("space") coords = [tuple(c) for c in bboxspec.get("coordinates")] - return boundingbox.BoundingBox(coords[0], coords[1], space=space_id) + return boundingbox.BoundingBox(coords[0], coords[1], space=space_spec) @classmethod @build_type("siibra/feature/fingerprint/receptor/v0.1") diff --git a/siibra/locations/location.py b/siibra/locations/location.py index f11c545e6..f9d59992a 100644 --- a/siibra/locations/location.py +++ b/siibra/locations/location.py @@ -21,6 +21,10 @@ import numpy as np from abc import abstractmethod +from typing import TYPE_CHECKING, Union, Dict +if TYPE_CHECKING: + from siibra.core.space import Space + class Location(BrainStructure): """ @@ -42,15 +46,19 @@ class Location(BrainStructure): _MASK_MEMO = {} # cache region masks for Location._assign_region() _ASSIGNMENT_CACHE = {} # caches assignment results, see Region.assign() - def __init__(self, space): - self._space_spec = space + def __init__(self, spacespec: Union[str, Dict[str, str], "Space"]): + self._space_spec = spacespec self._space_cached = None @property def space(self): if self._space_cached is None: from ..core.space import Space - self._space_cached = Space.get_instance(self._space_spec) + if isinstance(self._space_spec, dict): + spec = self._space_spec.get("@id") or self._space_spec.get("name") + self._space_cached = Space.get_instance(spec) + else: + self._space_cached = Space.get_instance(self._space_spec) return self._space_cached @abstractmethod diff --git a/test/core/test_parcellation.py b/test/core/test_parcellation.py index 949b98b06..e24f7b9dc 100644 --- a/test/core/test_parcellation.py +++ b/test/core/test_parcellation.py @@ -238,7 +238,7 @@ def test_get_region(self, regionspec, find_topmost, allow_tuple, result): @pytest.mark.parametrize('space_id,parc_id,map_type', [ - ('waxholm', 'v4', 'labelled') + ('waxholm', 'waxholm v4', 'labelled') ]) def test_should_be_able_to_fetch_map(space_id, parc_id, map_type): From ce2a08ec43253718d434fe4b046812526017e925 Mon Sep 17 00:00:00 2001 From: Ahmet Nihat Simsek Date: Thu, 11 Apr 2024 11:13:07 +0200 Subject: [PATCH 05/15] Do not build a volume twice for Image features. Factory can now build providers independent of building volumes --- siibra/configuration/factory.py | 34 +++++++++++++++------------- siibra/features/image/image.py | 12 ++++++---- siibra/volumes/providers/provider.py | 2 +- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/siibra/configuration/factory.py b/siibra/configuration/factory.py index de1478856..1013e9ce6 100644 --- a/siibra/configuration/factory.py +++ b/siibra/configuration/factory.py @@ -253,11 +253,9 @@ def build_parcellation(cls, spec): return p @classmethod - @build_type("siibra/volume/v0.0.1") - def build_volume(cls, spec): - providers: List[volume.VolumeProvider] = [] - - for srctype, provider_spec in spec.get("providers", {}).items(): + def build_volumeproviders(cls, provider_specs: Dict) -> List["VolumeProvider"]: + providers: List[VolumeProvider] = [] + for srctype, provider_spec in provider_specs.items(): for ProviderType in VolumeProvider._SUBCLASSES: if srctype == ProviderType.srctype: providers.append(ProviderType(provider_spec)) @@ -266,11 +264,15 @@ def build_volume(cls, spec): if srctype not in cls._warnings_issued: logger.warning(f"No provider defined for volume Source type {srctype}") cls._warnings_issued.append(srctype) - assert all([isinstance(p, VolumeProvider) for p in providers]) + return providers + + @classmethod + @build_type("siibra/volume/v0.0.1") + def build_volume(cls, spec): result = volume.Volume( space_spec=spec.get("space", {}), - providers=providers, + providers=cls.build_volumeproviders(spec.get("providers")), name=spec.get("name", ""), variant=spec.get("variant"), datasets=cls.extract_datasets(spec), @@ -405,13 +407,13 @@ def build_cell_density_profile(cls, spec): @classmethod @build_type("siibra/feature/section/v0.1") def build_section(cls, spec): - vol = cls.build_volume(spec) kwargs = { - "name": spec.get('name', ""), + "name": spec.get("name"), "region": spec.get('region', None), - "space_spec": vol._space_spec, - "providers": vol._providers.values(), - "datasets": cls.extract_datasets(spec) + "space_spec": spec.get("space"), + "providers": cls.build_volumeproviders(spec.get("providers")), + "datasets": cls.extract_datasets(spec), + "bbox": cls.build_boundingbox(spec) } modality = spec.get('modality', "") if modality == "cell body staining": @@ -422,13 +424,13 @@ def build_section(cls, spec): @classmethod @build_type("siibra/feature/voi/v0.1") def build_volume_of_interest(cls, spec): - vol = cls.build_volume(spec) kwargs = { - "name": spec.get('name', ""), + "name": spec.get("name"), "region": spec.get('region', None), - "space_spec": vol._space_spec, - "providers": vol._providers.values(), + "space_spec": spec.get("space"), + "providers": cls.build_volumeproviders(spec.get("providers")), "datasets": cls.extract_datasets(spec), + "bbox": cls.build_boundingbox(spec) } modality = spec.get('modality', "") if modality == "cell body staining": diff --git a/siibra/features/image/image.py b/siibra/features/image/image.py index 6d989b0d8..f41b154e5 100644 --- a/siibra/features/image/image.py +++ b/siibra/features/image/image.py @@ -20,9 +20,11 @@ from .. import anchor as _anchor from ...volumes import volume as _volume -from ...volumes.providers import provider -from typing import List +from typing import List, TYPE_CHECKING +if TYPE_CHECKING: + from ...locations.boundingbox import BoundingBox + from ...volumes.providers import provider class ImageAnchor(_anchor.AnatomicalAnchor): @@ -60,9 +62,10 @@ def __init__( name: str, modality: str, space_spec: dict, - providers: List[provider.VolumeProvider], + providers: List["provider.VolumeProvider"], region: str = None, - datasets: List = [] + datasets: List = [], + bbox: "BoundingBox" = None ): feature.Feature.__init__( self, @@ -78,6 +81,7 @@ def __init__( providers=providers, name=name, datasets=datasets, + bbox=bbox ) self._anchor_cached = ImageAnchor(self, region=region) diff --git a/siibra/volumes/providers/provider.py b/siibra/volumes/providers/provider.py index 77090e6d7..f97de460b 100644 --- a/siibra/volumes/providers/provider.py +++ b/siibra/volumes/providers/provider.py @@ -28,7 +28,7 @@ class VolumeProvider(ABC): - _SUBCLASSES = [] + _SUBCLASSES: List[VolumeProvider] = [] def __init_subclass__(cls, srctype: str) -> None: cls.srctype = srctype From fc7b2cfeb54626f73ce7855a978e9cacfee29ba0 Mon Sep 17 00:00:00 2001 From: Ahmet Nihat Simsek Date: Thu, 11 Apr 2024 16:55:20 +0200 Subject: [PATCH 06/15] Test: preconfigured BoundingBoxes --- e2e/volumes/test_preconfigured_boundingbox.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 e2e/volumes/test_preconfigured_boundingbox.py diff --git a/e2e/volumes/test_preconfigured_boundingbox.py b/e2e/volumes/test_preconfigured_boundingbox.py new file mode 100644 index 000000000..ec35fd826 --- /dev/null +++ b/e2e/volumes/test_preconfigured_boundingbox.py @@ -0,0 +1,31 @@ +import siibra +from siibra.features.image.image import Image +from siibra.volumes.volume import Volume +import pytest + +space_vols = [v for s in siibra.spaces for v in s.volumes] +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 = space_vols + map_vols + imagefeatures + + +@pytest.mark.parametrize("volume", volumes) +def test_onthefly_and_preconfig_bboxes(volume: Volume): + configured_bbox = volume._boundingbox + if configured_bbox is None: + pytest.skip(f"No preconfigured BoundingBox for {volume} is found.") + volume._boundingbox = None + kwargs = {"clip": True} + if "neuroglancer/precomputed" in volume.providers: + kwargs.update({ + "clip": False, + "resolution_mm": -1, + "format": "neuroglancer/precomputed", + "max_bytes": 2 * 1024**3 + }) + bbox = volume.get_boundingbox(**kwargs) + assert configured_bbox == bbox, f'{volume}' From 8505c4e7b2f66f09bc760a3611196cc645b84649 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Tue, 22 Oct 2024 14:01:23 +0200 Subject: [PATCH 07/15] [ci:usecfg] enh_use_precalc_img_bboxes update reftag --- siibra/configuration/configuration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/siibra/configuration/configuration.py b/siibra/configuration/configuration.py index 44545567d..00d818546 100644 --- a/siibra/configuration/configuration.py +++ b/siibra/configuration/configuration.py @@ -42,7 +42,7 @@ class Configuration: conn( server_or_owner, project_or_repo, - reftag="enh_use_precalc_img_bboxes", + reftag="siibra-{}".format(__version__), skip_branchtest=True ) for conn, server_or_owner, project_or_repo in CONFIG_REPOS From d48a78722a29b6cf741655f3eb99bc07ecd4f971 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Wed, 23 Oct 2024 10:20:07 +0200 Subject: [PATCH 08/15] fix cache unit test --- test/retrieval/test_cache.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/retrieval/test_cache.py b/test/retrieval/test_cache.py index fddd2e0dd..ce8f72fff 100644 --- a/test/retrieval/test_cache.py +++ b/test/retrieval/test_cache.py @@ -14,8 +14,18 @@ dummy_data2 = MagicMock() +# This fixture temporarily clears production warmup fns +# and restores them after test finishes +@pytest.fixture(scope="session") +def clearwarmup_cache(): + warmup_fns = Warmup._warmup_fns + Warmup._warmup_fns = [] + yield + Warmup._warmup_fns = warmup_fns + + @pytest.fixture -def register_dummy1(): +def register_dummy1(clearwarmup_cache): wrapped_fn = Warmup.register_warmup_fn(WarmupLevel.INSTANCE)(dummy1) yield wrapped_fn Warmup.deregister_warmup_fn(dummy1) @@ -26,7 +36,7 @@ def register_dummy1(): @pytest.fixture -def register_dummy2(): +def register_dummy2(clearwarmup_cache): wrapped_fn = Warmup.register_warmup_fn(WarmupLevel.INSTANCE)(dummy2) yield wrapped_fn Warmup.deregister_warmup_fn(dummy2) @@ -34,7 +44,7 @@ def register_dummy2(): @pytest.fixture -def register_dummy_data1(): +def register_dummy_data1(clearwarmup_cache): wrapped_fn = Warmup.register_warmup_fn(WarmupLevel.DATA)(dummy_data1) yield wrapped_fn Warmup.deregister_warmup_fn(dummy_data1) @@ -42,7 +52,7 @@ def register_dummy_data1(): @pytest.fixture -def register_dummy_data2(): +def register_dummy_data2(clearwarmup_cache): wrapped_fn = Warmup.register_warmup_fn(WarmupLevel.DATA)(dummy_data2) yield wrapped_fn Warmup.deregister_warmup_fn(dummy_data2) From 35344332fe0aa5471dcdf9f1d7bd7b1837817b57 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Wed, 23 Oct 2024 12:26:22 +0200 Subject: [PATCH 09/15] fix: e2e test for preconf bbox --- e2e/volumes/test_preconfigured_boundingbox.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/e2e/volumes/test_preconfigured_boundingbox.py b/e2e/volumes/test_preconfigured_boundingbox.py index ec35fd826..7010be505 100644 --- a/e2e/volumes/test_preconfigured_boundingbox.py +++ b/e2e/volumes/test_preconfigured_boundingbox.py @@ -2,30 +2,32 @@ from siibra.features.image.image import Image from siibra.volumes.volume import Volume import pytest +from itertools import repeat -space_vols = [v for s in siibra.spaces for v in s.volumes] 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 = space_vols + map_vols + imagefeatures +volumes = list(zip(map_vols, repeat(True))) + list(zip(imagefeatures, repeat(False))) -@pytest.mark.parametrize("volume", volumes) -def test_onthefly_and_preconfig_bboxes(volume: Volume): +@pytest.mark.parametrize("volume, clip_flag", map_vols) +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": True} + kwargs = {"clip": clip_flag} if "neuroglancer/precomputed" in volume.providers: - kwargs.update({ - "clip": False, - "resolution_mm": -1, - "format": "neuroglancer/precomputed", - "max_bytes": 2 * 1024**3 - }) + kwargs.update( + { + "clip": False, + "resolution_mm": -1, + "format": "neuroglancer/precomputed", + "max_bytes": 2 * 1024**3, + } + ) bbox = volume.get_boundingbox(**kwargs) - assert configured_bbox == bbox, f'{volume}' + assert configured_bbox == bbox, f"{volume}" From 69c017ea48ac506660edf11b1f08ea0590378e50 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Wed, 23 Oct 2024 12:27:43 +0200 Subject: [PATCH 10/15] [ci:usecfg] enh_use_precalc_img_bboxes use branch specific branch --- e2e/volumes/test_preconfigured_boundingbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/volumes/test_preconfigured_boundingbox.py b/e2e/volumes/test_preconfigured_boundingbox.py index 7010be505..60292d9dd 100644 --- a/e2e/volumes/test_preconfigured_boundingbox.py +++ b/e2e/volumes/test_preconfigured_boundingbox.py @@ -30,4 +30,4 @@ def test_onthefly_and_preconfig_bboxes(volume: Volume, clip_flag: bool): } ) bbox = volume.get_boundingbox(**kwargs) - assert configured_bbox == bbox, f"{volume}" + assert configured_bbox == bbox, f" {volume}" From b77bbeea130694561e684690bcd601c72033c214 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Wed, 23 Oct 2024 13:12:39 +0200 Subject: [PATCH 11/15] [ci:usecfg] enh_use_precalc_img_bboxes fix: preconfigure bbox e2e test parameters --- e2e/volumes/test_preconfigured_boundingbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/volumes/test_preconfigured_boundingbox.py b/e2e/volumes/test_preconfigured_boundingbox.py index 60292d9dd..b450b1b71 100644 --- a/e2e/volumes/test_preconfigured_boundingbox.py +++ b/e2e/volumes/test_preconfigured_boundingbox.py @@ -13,7 +13,7 @@ volumes = list(zip(map_vols, repeat(True))) + list(zip(imagefeatures, repeat(False))) -@pytest.mark.parametrize("volume, clip_flag", map_vols) +@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: From 15711d92708df04ef1074d50d624375dbb506b2d Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Thu, 24 Oct 2024 09:53:55 +0200 Subject: [PATCH 12/15] fix(test): update expected number of images fix(test): preconf bbox ng format should not overwrite clip flag --- e2e/features/image/test_image.py | 52 ++++++++++++++----- e2e/volumes/test_preconfigured_boundingbox.py | 1 - 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/e2e/features/image/test_image.py b/e2e/features/image/test_image.py index f0b9789b9..75c81da3c 100644 --- a/e2e/features/image/test_image.py +++ b/e2e/features/image/test_image.py @@ -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] @@ -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 @@ -33,7 +58,7 @@ 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" @@ -41,10 +66,9 @@ 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) diff --git a/e2e/volumes/test_preconfigured_boundingbox.py b/e2e/volumes/test_preconfigured_boundingbox.py index b450b1b71..033da3b30 100644 --- a/e2e/volumes/test_preconfigured_boundingbox.py +++ b/e2e/volumes/test_preconfigured_boundingbox.py @@ -23,7 +23,6 @@ def test_onthefly_and_preconfig_bboxes(volume: Volume, clip_flag: bool): if "neuroglancer/precomputed" in volume.providers: kwargs.update( { - "clip": False, "resolution_mm": -1, "format": "neuroglancer/precomputed", "max_bytes": 2 * 1024**3, From 6590d36bc8ab853a22f64d88e9487a5844a46400 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Thu, 24 Oct 2024 10:09:18 +0200 Subject: [PATCH 13/15] [ci:usecfg] enh_use_precalc_img_bboxes use config branch --- e2e/volumes/test_preconfigured_boundingbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/volumes/test_preconfigured_boundingbox.py b/e2e/volumes/test_preconfigured_boundingbox.py index 033da3b30..0a97cc532 100644 --- a/e2e/volumes/test_preconfigured_boundingbox.py +++ b/e2e/volumes/test_preconfigured_boundingbox.py @@ -17,7 +17,7 @@ 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.") + pytest.skip(f"No preconfigured BoundingBox for {volume} is found. ") volume._boundingbox = None kwargs = {"clip": clip_flag} if "neuroglancer/precomputed" in volume.providers: From 4c9ea85ca426089e7e35d95ef08de57b1d8d98a7 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Fri, 25 Oct 2024 09:15:59 +0200 Subject: [PATCH 14/15] [ci:usecfg] enh_use_precalc_img_bboxes do not set max_bytes or resolution_mm --- e2e/volumes/test_preconfigured_boundingbox.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/e2e/volumes/test_preconfigured_boundingbox.py b/e2e/volumes/test_preconfigured_boundingbox.py index 0a97cc532..5d7f747ca 100644 --- a/e2e/volumes/test_preconfigured_boundingbox.py +++ b/e2e/volumes/test_preconfigured_boundingbox.py @@ -20,13 +20,5 @@ def test_onthefly_and_preconfig_bboxes(volume: Volume, clip_flag: bool): pytest.skip(f"No preconfigured BoundingBox for {volume} is found. ") volume._boundingbox = None kwargs = {"clip": clip_flag} - if "neuroglancer/precomputed" in volume.providers: - kwargs.update( - { - "resolution_mm": -1, - "format": "neuroglancer/precomputed", - "max_bytes": 2 * 1024**3, - } - ) bbox = volume.get_boundingbox(**kwargs) assert configured_bbox == bbox, f" {volume}" From d4d66c56796961cb109b8d6a69b5a801eb100719 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Mon, 28 Oct 2024 17:03:48 +0100 Subject: [PATCH 15/15] [ci:usecfg] enh_use_precalc_img_bboxes fix image test --- e2e/features/image/test_image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/features/image/test_image.py b/e2e/features/image/test_image.py index 75c81da3c..aae39f88b 100644 --- a/e2e/features/image/test_image.py +++ b/e2e/features/image/test_image.py @@ -25,7 +25,7 @@ siibra.features.get( siibra.get_template("mni152"), "image", restrict_space=False ), - 14, + 13, ), ( siibra.features.get( @@ -58,7 +58,7 @@ 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) == 10, "expected 9 distinct names" + assert len(all_ds_names) == 9, "expected 9 distinct names" assert duration < 1, "Expected getting dataset names to be less than 1s"