Skip to content

Commit

Permalink
Fix: Volume.intersection(PointSet)
Browse files Browse the repository at this point in the history
BrainStructure.intersects check for not None so return None if intersection has no points, not an empty PointSet
  • Loading branch information
AhmetNSimsek committed Nov 10, 2023
1 parent be0915d commit a63b890
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions siibra/volumes/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def __str__(self):
def __repr__(self):
return self.__str__()

def _points_inside(self, points: pointset.PointSet, **kwargs) -> List[int]:
def _points_inside(self, points: Union['point.Point', 'pointset.PointSet'], **kwargs) -> 'pointset.PointSet':
"""
Reduce a pointset to the points which fall
inside nonzero pixels of this volume.
Expand Down Expand Up @@ -216,13 +216,8 @@ def intersection(self, other: structure.BrainStructure, **kwargs) -> structure.B
TODO write a test for the volume-volume and volume-region intersection
"""
if isinstance(other, (pointset.PointSet, point.Point)):
result = self._points_inside(other, **kwargs)
if len(result) == 0:
return pointset.PointSet([], space=other.space)
elif len(result) == 1:
return result[0]
else:
return result
result = self._points_inside(other, **kwargs) or None # BrainStructure.intersects check for not None
return result[0] if len(result) == 1 else result # if PointSet has single point return as a Point
elif isinstance(other, boundingbox.BoundingBox):
return self.boundingbox.intersection(other)
elif isinstance(other, Volume):
Expand Down

0 comments on commit a63b890

Please sign in to comment.