Skip to content

Commit

Permalink
fix region.assign(bbox) and update e2e test for image search
Browse files Browse the repository at this point in the history
Wikibrain stem image feature cannot be found anymore when mni152 template is given since the warping fails
  • Loading branch information
AhmetNSimsek committed Oct 13, 2024
1 parent f27e5ef commit ebc8508
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions e2e/features/image/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
(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.0.3', 'hoc1 left'), "CellbodyStainedSection"), 47),
(siibra.features.get(siibra.get_template("mni152"), "image", restrict_space=False), 12),
(siibra.features.get(siibra.get_region('julich 3.1', 'hoc1 left'), "CellbodyStainedSection"), 49),
(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 @@ -33,7 +33,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) == 8, "expected 8 distinct names"
assert duration < 1, "Expected getting dataset names to be less than 1s"


Expand Down
17 changes: 9 additions & 8 deletions siibra/core/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from . import concept, structure, space as _space, parcellation as _parcellation
from .assignment import Qualification, AnatomicalAssignment

from ..locations import location, point, pointset
from ..locations import location, point, pointset, boundingbox as _boundingbox
from ..volumes import parcellationmap, volume
from ..commons import (
logger,
Expand Down Expand Up @@ -642,13 +642,14 @@ def assign(self, other: structure.BrainStructure) -> AnatomicalAssignment:
self._ASSIGNMENT_CACHE[self, other] = regionmap.assign(other)
return self._ASSIGNMENT_CACHE[self, other]

try:
regionbbox_otherspace = self.get_boundingbox(other.space, restrict_space=False)
if regionbbox_otherspace is not None:
self._ASSIGNMENT_CACHE[self, other] = regionbbox_otherspace.assign(other)
return self._ASSIGNMENT_CACHE[self, other]
except Exception as e:
logger.debug(e)
if isinstance(other, _boundingbox.BoundingBox): # volume.intersection(bbox) gets boundingbox anyway
try:
regionbbox_otherspace = self.get_boundingbox(other.space, restrict_space=False)
if regionbbox_otherspace is not None:
self._ASSIGNMENT_CACHE[self, other] = regionbbox_otherspace.assign(other)
return self._ASSIGNMENT_CACHE[self, other]
except Exception as e:
logger.debug(e)

assignment_result = None
for targetspace in self.supported_spaces:
Expand Down

0 comments on commit ebc8508

Please sign in to comment.