Skip to content

Commit

Permalink
clip voi to template's if voi lies partially outside of the template
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmetNSimsek committed Oct 15, 2024
1 parent b3ed3d5 commit 3d370b8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions siibra/volumes/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ def fetch(
else:
raise ValueError(f"Invalid format requested: {format}")

# ensure the voi is inside the template
voi = kwargs.get("voi", None)
if isinstance(voi, _boundingbox.BoundingBox) and voi.space is not None:
tmplt_bbox = voi.space.get_template().boundingbox
intersection_bbox = voi.intersection(tmplt_bbox)
if intersection_bbox is None:
raise RuntimeError(f"{voi=} provided lies out side the voxel space of the {voi.space.name} template.")
if intersection_bbox.minpoint != voi.minpoint or intersection_bbox.maxpoint != voi.maxpoint:
logger.info(
f"Since provided voi lies outside the template ({voi.space}) it is clipped as: {intersection_bbox}"
)
kwargs["voi"] = intersection_bbox

# try the selected format only
for try_count in range(6):
try:
Expand Down

0 comments on commit 3d370b8

Please sign in to comment.