Standalone utilities for working with pose data from SLEAP and other tools.
Project description
sleap-io
Standalone utilities for working with animal pose tracking data.
This is intended to be a complement to the core SLEAP package that aims to provide functionality for interacting with pose tracking-related data structures and file formats with minimal dependencies. This package does not have any functionality related to labeling, training, or inference.
Installation
pip install sleap-io
For development, use one of the following syntaxes:
conda env create -f environment.yml
pip install -e .[dev]
See CONTRIBUTING.md
for more information on development.
Usage
Load and save in different formats
import sleap_io as sio
# Load from SLEAP file.
labels = sio.load_slp("predictions.slp")
# Save to NWB file.
sio.save_nwb(labels, "predictions.nwb")
Convert labels to raw arrays
import sleap_io as sio
labels = sio.load_slp("tests/data/slp/centered_pair_predictions.slp")
# Convert predictions to point coordinates in a single array.
trx = labels.numpy()
n_frames, n_tracks, n_nodes, xy = trx.shape
assert xy == 2
# Convert to array with confidence scores appended.
trx_with_scores = labels.numpy(return_confidence=True)
n_frames, n_tracks, n_nodes, xy_score = trx.shape
assert xy_score == 3
Create labels from raw data
import sleap_io as sio
import numpy as np
# Create skeleton.
skeleton = sio.Skeleton(
nodes=["head", "thorax", "abdomen"],
edges=[("head", "thorax"), ("thorax", "abdomen")]
)
# Create video.
video = sio.Video.from_filename("test.mp4")
# Create instance.
instance = sio.Instance.from_numpy(
points=np.array([
[10.2, 20.4],
[5.8, 15.1],
[0.3, 10.6],
]),
skeleton=skeleton
)
# Create labeled frame.
lf = sio.LabeledFrame(video=video, frame_idx=0, instances=[instance])
# Create labels.
labels = sio.Labels(videos=[video], skeletons=[skeleton], labeled_frames=[lf])
Support
For technical inquiries specific to this package, please open an Issue with a description of your problem or request.
For general SLEAP usage, see the main website.
Other questions? Reach out to talmo@salk.edu
.
License
This package is distributed under a BSD 3-Clause License and can be used without
restrictions. See LICENSE
for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sleap_io-0.0.13-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cacb1706e6eeb5e0b3199c2996d1fb4a0997e7025586affb8ca833583b0a763e |
|
MD5 | 4ee64dcf13210fda69344b82e3f3e57d |
|
BLAKE2b-256 | ca16168e0216559bdb4d9a1d9322294ab58dd110c7cb37a72c6cc3652ed032ab |