Skip to content
Open
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
14 changes: 11 additions & 3 deletions deepdrr/vol/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -1621,9 +1621,17 @@ def get_bbox_IJK(self) -> Optional[np.ndarray]:
np.ndarray: The bounding box as a [3, 2] array.
None, if the volume is empty.
"""
any_material = np.zeros_like(self.data, dtype=bool)
for d in self.materials.values():
any_material = np.logical_or(any_material, d)
if isinstance(self.materials, tuple):
# New materials format
material_map, label_volume = self.materials
valid_ids = list(material_map.values())
any_material = np.isin(label_volume, valid_ids) if valid_ids else np.zeros_like(self.data, dtype=bool)
else:
# Legacy materials format
any_material = np.zeros_like(self.data, dtype=bool)
for d in self.materials.values():
any_material = np.logical_or(any_material, d)

indices = np.nonzero(any_material)
if len(indices[0]) == 0:
return None
Expand Down