locan.data.region.RoiRegion#
- class locan.data.region.RoiRegion(region_type, region_specs)[source]#
Bases:
object
Deprecated Region object to specify regions of interest.
A region that defines a region of interest with methods for getting a printable representation (that can also be saved in a yaml file), for returning a matplotlib patch that can be shown in a graph, for finding points within the region.
Warning
This class is to be deprecated and should only be used to deal with legacy _roi.yaml files. Use Region classes instead.
- Parameters:
region_type (str) – A string indicating the roi shape. In 1D it can be interval. In 2D it can be either rectangle, ellipse, or closed polygon. In 2D it can also be shapelyPolygon or shapelyMultiPolygon. In 3D it can be either cuboid or ellipsoid or polyhedron (not implemented yet).
region_specs (tuple) – 1D rois are defined by the following tuple: * interval: (start, stop) 2D rois are defined by the following tuples: * rectangle: ((corner_x, corner_y), width, height, angle) with angle in degree * ellipse: ((center_x, center_y), width, height, angle) with angle in degree * polygon: ((point1_x, point1_y), (point2_x, point2_y), …, (point1_x, point1_y)) * shapelyPolygon: ((point_tuples), ((hole_tuples), …)) * shapelyMultiPolygon: (shapelyPolygon_specs_1, shapelyPolygon_specs_2, …) 3D rois are defined by the following tuples: * cuboid: ((corner_x, corner_y, corner_z), length, width, height, angle_1, angle_2, angle_3) * ellipsoid: ((center_x, center_y, center_z), length, width, height, angle_1, angle_2, angle_3) * polyhedron: (…)
- Variables:
region_type (str) – Type of region
region_specs (tuple) – Specifications for region
_region (RoiRegion) – RoiRegion instance for the specified region type.
polygon (tuple[npt.ArrayLike, ...]) – Array of points for a closed polygon approximating the region of interest in clockwise orientation. The first and last point must be identical.
dimension (int) – Spatial dimension of region
centroid (tuple[float, ...]) – Centroid coordinates
max_distance (npt.NDArray[np.float64]) – Maximum distance between any two points in the region
region_measure (float) – Hull measure, i.e. area or volume
subregion_measure (float) – Measure of the sub-dimensional region, i.e. circumference or surface.
Methods
__init__
(region_type, region_specs)as_artist
(**kwargs)Matplotlib patch object for this region (e.g. matplotlib.patches.Ellipse).
contains
(points)Return list of indices for all points that are inside the region of interest.
from_shapely
(region_type, shapely_obj)Convert region to a polygon and return as shapely object.
Attributes
- as_artist(**kwargs)[source]#
Matplotlib patch object for this region (e.g. matplotlib.patches.Ellipse).
- Parameters:
kwargs (
Any
) – Other parameters passed to the matplotlib.patches object.- Returns:
Matplotlib patch for the specified region.
- Return type:
matplotlib.patches.Patch
- contains(points)[source]#
Return list of indices for all points that are inside the region of interest.
- Parameters:
points (npt.ArrayLike) – 2D or 3D coordinates of oints 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 region#