ds_to_napari_layers#

movement.napari.convert.ds_to_napari_layers(ds)[source]#

Convert movement dataset to napari Tracks array and properties.

Parameters:

ds (xr.Dataset) – movement dataset containing pose or bounding box tracks, confidence scores, and associated metadata.

Return type:

tuple[ndarray, ndarray | None, DataFrame]

Returns:

  • points_as_napari (np.ndarray) – position data as a napari Tracks array with shape (N, 4), where N is n_keypoints * n_individuals * n_frames and the 4 columns are (track_id, frame_idx, y, x).

  • bboxes_as_napari (np.ndarray | None) – bounding box data as a napari Shapes array with shape (N, 4, 4), where N is n_individuals * n_frames and each (4, 4) entry is a matrix of 4 rows (1 per corner vertex, starting from upper left and progressing in counterclockwise order) with the columns (track_id, frame, y, x). Returns None when the input dataset doesn’t have a “shape” variable.

  • properties (pd.DataFrame) – DataFrame with properties (individual, keypoint, time, confidence) for use with napari layers.

Notes

A corresponding napari Points array can be derived from the Tracks array by taking its last 3 columns: (frame_idx, y, x). See the documentation on the napari Tracks [1] and Points [2] layers.

References