napari_shapes_layer_to_rois#
- movement.napari.convert_roi.napari_shapes_layer_to_rois(layer)[source]#
Convert all shapes in a
napariShapes layer tomovementRoIs.- Parameters:
layer (
Shapes) – ThenapariShapes layer to be converted. Names are read fromlayer.properties["name"]when available. Missing or blank names receive the default name defined byBaseRegionOfInterest.- Returns:
One region of interest (RoI) per shape in the layer, in the same order.
- Return type:
- Raises:
ValueError – If any shape has more than 2 coordinate columns, or has an unrecognised shape type.
Notes
The mapping from
naparishape types tomovementRoI classes is:napari shape type
movement RoI class
"line","path""polygon","rectangle""ellipse"PolygonOfInterest(approximation)Ellipses are approximated as polygons because neither
movementnor its underlying geometry library (shapely) has a native ellipse type. The approximation usesshapely.Point.buffer()scaled and rotated to match the ellipse geometry. This approach was inspired by https://gis.stackexchange.com/questions/243459/drawing-ellipse-with-shapelySee also
rois_to_napari_shapesThe inverse of this function.