locan.data.region.Interval#

class locan.data.region.Interval(lower_bound=0, upper_bound=1)[source]#

Bases: Region1D

Region class to define an interval.

Parameters:
  • lower_bound (float) – The lower bound of the interval.

  • upper_bound (float) – The upper bound of the interval.

Methods

__init__([lower_bound, upper_bound])

as_artist([origin])

Matplotlib 2D patch object for this region (e.g. matplotlib.patches.Ellipse).

buffer(distance, **kwargs)

Extend the region perpendicular by a distance.

contains(points)

Return list of indices for all points that are inside the region of interest.

from_intervals(intervals)

Constructor for instantiating Region from list of (min, max) bounds.

intersection(other)

Returns a region representing the intersection of this region with other.

symmetric_difference(other)

Returns the union of the two regions minus any areas contained in the intersection of the two regions.

union(other)

Returns a region representing the union of this region with other.

Attributes

bounding_box

A region describing the minimum axis-aligned bounding box that encloses the original region.

bounds

Region bounds min_x, min_y, ..., max_x, max_y, .

centroid

Point coordinates for region centroid.

dimension

The region dimension.

extent

The extent (max_x - min_x), (max_y - min_y), .

intervals

Provide bounds in a tuple (min, max) arrangement.

lower_bound

The lower boundary.

max_distance

The maximum distance between any two points within the region.

points

Point coordinates.

region_measure

Region measure, i.e. area (for 2d) or volume (for 3d).

region_specs

Legacy interface to serve legacy RoiRegion.

subregion_measure

Measure of the sub-dimensional region, i.e. circumference (for 2d) or surface (for 3d).

upper_bound

The upper boundary.

as_artist(origin=(0, 0), **kwargs)[source]#

Matplotlib 2D patch object for this region (e.g. matplotlib.patches.Ellipse).

Parameters:
  • origin (Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) – The (x, y) pixel position of the origin of the displayed image. Default is (0, 0).

  • kwargs (Any) – Other parameters passed to the matplotlib.patches object.

Returns:

Matplotlib patch for the specified region.

Return type:

matplotlib.patches.Patch

property bounding_box: Self#

A region describing the minimum axis-aligned bounding box that encloses the original region.

Return type:

Region

property bounds: ndarray[Any, dtype[float64]]#

Region bounds min_x, min_y, …, max_x, max_y, … for each dimension.

Returns:

of shape (2 * dimension,)

Return type:

npt.NDArray[np.float64] | None

buffer(distance, **kwargs)[source]#

Extend the region perpendicular by a distance.

Parameters:

distance (float) – Distance by which the region is extended.

Returns:

The extended region.

Return type:

Region

property centroid: ndarray[Any, dtype[float64]]#

Point coordinates for region centroid.

Returns:

of shape (dimension,)

Return type:

npt.NDArray[np.float64] | None

contains(points)[source]#

Return list of indices for all points that are inside the region of interest.

Parameters:

points (Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) – Coordinates of points that are tested for being inside the specified region.

Returns:

Array with indices for all points in original point array that are within the region.

Return type:

npt.NDArray[np.int64]

property extent: ndarray[Any, dtype[float64]]#

The extent (max_x - min_x), (max_y - min_y), … for each dimension.

Returns:

of shape (dimension,)

Return type:

npt.NDArray[np.float64] | None

classmethod from_intervals(intervals)[source]#

Constructor for instantiating Region from list of (min, max) bounds. Takes array-like intervals instead of interval to be consistent with Rectangle.from_intervals.

Parameters:

intervals (Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) – The region bounds for each dimension of shape (2,)

Return type:

Interval

property intervals: ndarray[Any, dtype[float64]]#

Provide bounds in a tuple (min, max) arrangement.

Returns:

((min_x, max_x), …) of shape(dimension, 2).

Return type:

tuple[tuple[float, float], …]

property lower_bound: float#

The lower boundary.

Return type:

float

property max_distance: float#

The maximum distance between any two points within the region.

Return type:

float

property points: ndarray[Any, dtype[float64]]#

Point coordinates.

Returns:

of shape (n_points, dimension)

Return type:

npt.NDArray[np.float64] | list[npt.NDArray[np.float64]]

property region_measure: float#

Region measure, i.e. area (for 2d) or volume (for 3d).

Return type:

float

property region_specs: tuple[float, float]#

Legacy interface to serve legacy RoiRegion.

Warning

Do not use - will be deprecated.

Return type:

tuple[float, float]

property subregion_measure: int#

Measure of the sub-dimensional region, i.e. circumference (for 2d) or surface (for 3d).

Return type:

float

property upper_bound: float#

The upper boundary.

Return type:

float