PolygonOfInterest#

class movement.roi.polygon.PolygonOfInterest(exterior_boundary, holes=None, name=None)[source]#

Bases: BaseRegionOfInterest

Representation of a two-dimensional region in the x-y plane.

This class can be used to represent polygonal regions or subregions of the area in which the experimental data was gathered. These might include the arms of a maze, a nesting area, a food source, or other similar areas of the experimental enclosure that have some significance.

An instance of this class can be used to represent these regions of interest (RoIs) in an analysis. The basic usage is to construct an instance of this class by passing in a list of points, which will then be joined (in sequence) by straight lines between consecutive pairs of points, to form the exterior boundary of the RoI. Note that the exterior boundary (accessible as via the .exterior property) is a (closed) LineOfInterest, and may be treated accordingly.

The class also supports holes - subregions properly contained inside the region that are not part of the region itself. These can be specified by the holes argument, and define the interior boundaries of the region. These interior boundaries are accessible via the .interior_boundaries property, and the polygonal regions that make up the holes are accessible via the holes property.

property coords: CoordinateSequence#

Coordinates of the points that define the region.

These are the points passed to the constructor argument points.

Note that for Polygonal regions, these are the coordinates of the exterior boundary, interior boundaries must be accessed via self.region.interior.coords.

property dimensions: int#

Dimensionality of the region.

property exterior_boundary: LineOfInterest#

The exterior boundary of this RoI.

property holes: tuple[PolygonOfInterest, ...]#

The interior holes of this RoI.

Holes are regions properly contained within the exterior boundary of the RoI that are not part of the RoI itself (like the centre of a doughnut, for example). A region with no holes returns the empty tuple.

property interior_boundaries: tuple[LineOfInterest, ...]#

The interior boundaries of this RoI.

Interior boundaries are the boundaries of holes contained within the polygon. A region with no holes returns the empty tuple.

property is_closed: bool#

Return True if the region is closed.

A closed region is either: - A polygon (2D RoI). - A 1D LoI whose final point connects back to its first.

property name: str#

Name of the instance.

property region: LinearRing | LineString | Polygon#

shapely.Geometry representation of the region.