ROI#

class pypillometry.ROI(name=None, setup=None)[source]#

Bases: object

Base class for Region of Interest (ROI).

This class provides common functionality for different types of ROIs. Subclasses should implement the contains() method to define their specific containment logic (coords in roi uses it for single points) and the plot() method.

Coordinates are specified in pixels with origin at the upper-left corner of the screen (y increases downward). Use factory methods from_mm() or from_degrees() on subclasses for alternative coordinate systems.

Parameters:
  • name (str) – Name of the ROI

  • setup (Optional[ExperimentalSetup]) – Experimental setup for coordinate conversions. If provided, enables coordinate system conversion methods.

Methods

contains

Test if coordinates are within the ROI.

plot

Plot the ROI on the given axes.

Details

contains(coords)[source]#

Test if coordinates are within the ROI.

Supports both single coordinate and array of coordinates.

Parameters:

coords (Union[Tuple[float, float], ndarray]) – a single (x, y) point or an array of shape (n, 2) with one point per row (in pixels)

Return type:

Union[bool, ndarray]

Returns:

for a single point, whether it is inside the ROI; for an array, a boolean array of length n

plot(ax=None, **kwargs)[source]#

Plot the ROI on the given axes.

Parameters:
  • ax (matplotlib.axes.Axes, optional) – The axes to plot on. If None, the current axes will be used.

  • **kwargs (dict) – Additional keyword arguments passed to the plotting function.

Return type:

matplotlib.axes.Axes

Returns:

the axes of the plot