napari_shapes_layer_to_rois#

movement.napari.convert_roi.napari_shapes_layer_to_rois(layer)[source]#

Convert all shapes in a napari Shapes layer to movement RoIs.

Parameters:

layer (Shapes) – The napari Shapes layer to be converted. Names are read from layer.properties["name"] when available. Missing or blank names receive the default name defined by BaseRegionOfInterest.

Returns:

One region of interest (RoI) per shape in the layer, in the same order.

Return type:

list[BaseRegionOfInterest]

Raises:

ValueError – If any shape has more than 2 coordinate columns, or has an unrecognised shape type.

Notes

The mapping from napari shape types to movement RoI classes is:

napari shape type

movement RoI class

"line", "path"

LineOfInterest

"polygon", "rectangle"

PolygonOfInterest

"ellipse"

PolygonOfInterest (approximation)

Ellipses are approximated as polygons because neither movement nor its underlying geometry library (shapely) has a native ellipse type. The approximation uses shapely.Point.buffer() scaled and rotated to match the ellipse geometry. This approach was inspired by https://gis.stackexchange.com/questions/243459/drawing-ellipse-with-shapely

See also

rois_to_napari_shapes

The inverse of this function.