locan.rois.roi.RoiLegacy_0#

class locan.rois.roi.RoiLegacy_0(region_type, region_specs, reference=None, properties_for_roi=())[source]#

Bases: object

Class for a region of interest on LocData (roi).

Roi objects define a region of interest for a referenced LocData object.

Parameters:
  • reference (LocData, dict, locan.data.metadata_pb2.Metadata, None) – Reference to localization data for which the region of interests are defined. It can be a LocData object, a reference to a saved SMLM file, or None for indicating no specific reference. When referencing a saved SMLM file, reference must be a dict or locan.data.metadata_pb2.Metadata with keys file_path and file_type for a path pointing to a localization file and an integer or string indicating the file type. Integer or string should be according to locan.constants.FileType.

  • 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 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) * ellipse: ((center_x, center_y), width, height, angle) * polygon: ((point1_x, point1_y), (point2_x, point2_y), …, (point1_x, point1_y)) 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: (…)

  • properties_for_roi (tuple[str, ...]) – Localization properties in LocData object on which the region selection will be applied (for instance the coordinate_keys).

Variables:
  • reference (LocData | locan.data.metadata_pb2.Metadata | None) – Reference to localization data for which the regions of interest are defined. It can be a LocData object, a reference (locan.data.metadata_pb2.Metadata) to a saved SMLM file, or None for indicating no specific reference. When referencing a saved SMLM file, reference as attributes file_path and file_type for a path pointing to a localization file and an integer indicating the file type. The integer should be according to locan.data.metadata_pb2.Metadata.file_type.

  • _region (RoiRegion | list[RoiRegion]) – Object specifying the geometrical region of interest. In case a list of RoiRegion is provided it is the union that makes up the region of interest.

  • properties_for_roi (tuple[str, ...]) – Localization properties in LocData object on which the region selection will be applied (for instance the coordinate_keys).

Warning

RoiLegacy is deprecated and should only be used to read legacy _roi.yaml files. Use locan.Roi instead.

Methods

__init__(region_type, region_specs[, ...])

from_yaml(path)

Read Roi object from yaml format.

locdata([reduce])

Localization data according to roi specifications.

to_yaml([path])

Save Roi object in yaml format.

Attributes

classmethod from_yaml(path)[source]#

Read Roi object from yaml format.

Parameters:

path (str | os.PathLike) – Path for yaml file.

locdata(reduce=True)[source]#

Localization data according to roi specifications.

The ROI is applied on locdata properties as specified in self.loc_properties or by taking the first applicable locdata.coordinate_keys.

Parameters:

reduce (bool) – Return the reduced LocData object or keep references alive.

Returns:

A new instance of LocData with all localizations within region of interest.

Return type:

LocData

property region#
to_yaml(path=None)[source]#

Save Roi object in yaml format.

Parameters:

path (str | os.PathLike | None) – Path for yaml file. If None a roi file path is generated from the metadata.