from_sleap_file#

movement.io.load_poses.from_sleap_file(file_path, fps=None)[source]#

Create a movement poses dataset from a SLEAP file.

Parameters:
  • file_path (pathlib.Path or str) – Path to the file containing the SLEAP predictions in .h5 (analysis) format. Alternatively, a .slp (labels) file can also be supplied (but this feature is experimental, see Notes).

  • fps (float, optional) – The number of frames per second in the video. If None (default), the time coordinates will be in frame numbers.

Returns:

movement dataset containing the pose tracks, confidence scores, and associated metadata.

Return type:

xarray.Dataset

Notes

The SLEAP predictions are normally saved in .slp files, e.g. “v1.predictions.slp”. An analysis file, suffixed with “.h5” can be exported from the .slp file, using either the command line tool sleap-convert (with the “–format analysis” option enabled) or the SLEAP GUI (Choose “Export Analysis HDF5…” from the “File” menu) [1]. This is the preferred format for loading pose tracks from SLEAP into movement.

You can also directly load the .slp file. However, if the file contains multiple videos, only the pose tracks from the first video will be loaded. If the file contains a mix of user-labelled and predicted instances, user labels are prioritised over predicted instances to mirror SLEAP’s approach when exporting .h5 analysis files [2].

movement expects the tracks to be assigned and proofread before loading them, meaning each track is interpreted as a single individual. If no tracks are found in the file, movement assumes that this is a single-individual track, and will assign a default individual name. If multiple instances without tracks are present in a frame, the last instance is selected [2]. Follow the SLEAP guide for tracking and proofreading [3].

References

Examples

>>> from movement.io import load_poses
>>> ds = load_poses.from_sleap_file("path/to/file.analysis.h5", fps=30)