locan.rois.roi.Roi#
- class locan.rois.roi.Roi(region, reference=None, loc_properties=None)[source]#
Bases:
object
Class for defining a region of interest for a referenced LocData object.
- Parameters:
region (Region) – Geometrical region of interest.
reference (LocData | dict | locan.data.metadata_pb2.Metadata | locan.data.metadata_pb2.File | None) – Reference to localization data for which the region of interest is defined. It can be a LocData object, a reference to a saved SMLM file, or None for indicating no specific reference. When dict it must have keys file_path`and `file_type. When Metadata message it must have 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.
loc_properties (Sequence[str] | None) – Localization properties in LocData object on which the region selection will be applied (for instance the coordinate_keys).
- Variables:
region (Region) – Geometrical region of interest.
reference (LocData | locan.data.metadata_pb2.Metadata | None) – Reference to localization data for which the region of interest is 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 has attributes file.path and file.type for a path pointing to a localization file and an integer indicating the file type.
loc_properties (tuple[str, ...] | None) – Localization properties in LocData object on which the region selection will be applied (for instance the coordinate_keys).
Methods
__init__
(region[, reference, loc_properties])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
|PathLike
[Any
]) – Path for yaml file.- Return type:
TypeVar
(T_Roi
, bound= Roi)
- 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: