rois_to_napari_shapes#
- movement.napari.convert_roi.rois_to_napari_shapes(rois)[source]#
Convert a sequence of
movementRoIs tonaparishapes.The returned dictionary can be passed directly to
napari’s Shapes layer constructor to add all regions of interest (RoIs) in a single call.- Parameters:
rois (
Sequence[BaseRegionOfInterest]) – Sequence ofLineOfInterestorPolygonOfInterestobjects to convert.- Returns:
A dictionary with the following keys:
"data": list of (N, 2) arrays in(y, x)order."shape_type": list ofnaparishape type strings."properties": dict with a"name"key containing the RoI names.
- Return type:
Notes
The mapping from
movementRoI classes tonaparishape types is:movement RoI class
napari shape type
"path""polygon"This function is the inverse of
napari_shapes_layer_to_rois(), but some shape information is not preserved when converting back. Specifically,"line","rectangle", and"ellipse"shapes drawn innapariare all returned as"path"or"polygon".A closed
LineOfInterest(created withloop=True) is also affected:naparihas no closed-path shape type, so the segment connecting the last point back to the first is dropped and a warning is emitted.See also
napari_shapes_layer_to_roisThe inverse of this function.