diff --git a/e2e/features/image/test_image.py b/e2e/features/image/test_image.py index a7e990505..581acf43f 100644 --- a/e2e/features/image/test_image.py +++ b/e2e/features/image/test_image.py @@ -9,7 +9,7 @@ (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', 'hoc1 left'), "CellbodyStainedSection"), 47), + (siibra.features.get(siibra.get_region('julich 3.0.3', 'hoc1 left'), "CellbodyStainedSection"), 47), (siibra.features.get(siibra.get_region('julich 2.9', 'hoc1 left'), "CellbodyStainedSection"), 41) ] features = [f for fts, _ in results for f in fts] diff --git a/siibra/core/region.py b/siibra/core/region.py index 905887da6..756fc9704 100644 --- a/siibra/core/region.py +++ b/siibra/core/region.py @@ -642,17 +642,28 @@ 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) + assignment_result = None - for space in self.supported_spaces: + for targetspace in self.supported_spaces: try: - other_warped = other.warp(space) - regionmap = self.get_regional_map(space) + other_warped = other.warp(targetspace) + regionmap = self.get_regional_map(targetspace) assignment_result = regionmap.assign(other_warped) except SpaceWarpingFailedError: try: - regionbbox_warped = self.get_boundingbox( - space, restrict_space=True - ).warp(other.space) + regionbbox_targetspace = self.get_boundingbox( + targetspace, restrict_space=True + ) + if regionbbox_targetspace is None: + continue + regionbbox_warped = regionbbox_targetspace.warp(other.space) except SpaceWarpingFailedError: continue assignment_result = regionbbox_warped.assign(other) @@ -694,7 +705,7 @@ def get_boundingbox( space: _space.Space, maptype: MapType = MapType.LABELLED, threshold_statistical=None, - restrict_space=False, + restrict_space=True, **fetch_kwargs ): """Compute the bounding box of this region in the given space. @@ -740,7 +751,7 @@ def get_boundingbox( bbox_warped = bbox.warp(spaceobj) except SpaceWarpingFailedError: continue - logger.warning( + logger.debug( f"No bounding box for {self.name} defined in {spaceobj.name}, " f"warped the bounding box from {other_space.name} instead." )