sleap-io


Namesleap-io JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryStandalone utilities for working with pose data from SLEAP and other tools.
upload_time2024-04-14 07:43:03
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseBSD-3-Clause
keywords sleap pose tracking pose estimation behavior
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # sleap-io

[![CI](https://github.com/talmolab/sleap-io/actions/workflows/ci.yml/badge.svg)](https://github.com/talmolab/sleap-io/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/talmolab/sleap-io/branch/main/graph/badge.svg?token=Sj8kIFl3pi)](https://codecov.io/gh/talmolab/sleap-io)
[![Release](https://img.shields.io/github/v/release/talmolab/sleap-io?label=Latest)](https://github.com/talmolab/sleap-io/releases/)
[![PyPI](https://img.shields.io/pypi/v/sleap-io?label=PyPI)](https://pypi.org/project/sleap-io)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sleap-io)

Standalone utilities for working with animal pose tracking data.

This is intended to be a complement to the core [SLEAP](https://github.com/talmolab/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`](CONTRIBUTING.md) for more information on development.

## Usage

### Load and save in different formats

```py
import sleap_io as sio

# Load from SLEAP file.
labels = sio.load_file("predictions.slp")

# Save to NWB file.
sio.save_file(labels, "predictions.nwb")
# Or:
# labels.save("predictions.nwb")
```

### Convert labels to raw arrays

```py
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
```

### Read video data

```py
import sleap_io as sio

video = sio.load_video("test.mp4")
n_frames, height, width, channels = video.shape

frame = video[0]
height, width, channels = frame.shape
```

### Create labels from raw data

```py
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.load_video("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])

# Save.
labels.save("labels.slp")
```

## Support
For technical inquiries specific to this package, please [open an Issue](https://github.com/talmolab/sleap-io/issues)
with a description of your problem or request.

For general SLEAP usage, see the [main website](https://sleap.ai).

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`](LICENSE) for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sleap-io",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "sleap, pose tracking, pose estimation, behavior",
    "author": null,
    "author_email": "Liezl Maree <lmaree@salk.edu>, David Samy <davidasamy@gmail.com>, Talmo Pereira <talmo@salk.edu>",
    "download_url": "https://files.pythonhosted.org/packages/cb/80/b91b7ffd91faba5b18f26c79c540450702630ed09e1e84bba10a35c2646d/sleap_io-0.1.0.tar.gz",
    "platform": null,
    "description": "# sleap-io\n\n[![CI](https://github.com/talmolab/sleap-io/actions/workflows/ci.yml/badge.svg)](https://github.com/talmolab/sleap-io/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/talmolab/sleap-io/branch/main/graph/badge.svg?token=Sj8kIFl3pi)](https://codecov.io/gh/talmolab/sleap-io)\n[![Release](https://img.shields.io/github/v/release/talmolab/sleap-io?label=Latest)](https://github.com/talmolab/sleap-io/releases/)\n[![PyPI](https://img.shields.io/pypi/v/sleap-io?label=PyPI)](https://pypi.org/project/sleap-io)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sleap-io)\n\nStandalone utilities for working with animal pose tracking data.\n\nThis is intended to be a complement to the core [SLEAP](https://github.com/talmolab/sleap)\npackage that aims to provide functionality for interacting with pose tracking-related\ndata structures and file formats with minimal dependencies. This package *does not*\nhave any functionality related to labeling, training, or inference.\n\n## Installation\n```\npip install sleap-io\n```\n\nFor development, use one of the following syntaxes:\n```\nconda env create -f environment.yml\n```\n```\npip install -e .[dev]\n```\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md) for more information on development.\n\n## Usage\n\n### Load and save in different formats\n\n```py\nimport sleap_io as sio\n\n# Load from SLEAP file.\nlabels = sio.load_file(\"predictions.slp\")\n\n# Save to NWB file.\nsio.save_file(labels, \"predictions.nwb\")\n# Or:\n# labels.save(\"predictions.nwb\")\n```\n\n### Convert labels to raw arrays\n\n```py\nimport sleap_io as sio\n\nlabels = sio.load_slp(\"tests/data/slp/centered_pair_predictions.slp\")\n\n# Convert predictions to point coordinates in a single array.\ntrx = labels.numpy()\nn_frames, n_tracks, n_nodes, xy = trx.shape\nassert xy == 2\n\n# Convert to array with confidence scores appended.\ntrx_with_scores = labels.numpy(return_confidence=True)\nn_frames, n_tracks, n_nodes, xy_score = trx.shape \nassert xy_score == 3\n```\n\n### Read video data\n\n```py\nimport sleap_io as sio\n\nvideo = sio.load_video(\"test.mp4\")\nn_frames, height, width, channels = video.shape\n\nframe = video[0]\nheight, width, channels = frame.shape\n```\n\n### Create labels from raw data\n\n```py\nimport sleap_io as sio\nimport numpy as np\n\n# Create skeleton.\nskeleton = sio.Skeleton(\n    nodes=[\"head\", \"thorax\", \"abdomen\"],\n    edges=[(\"head\", \"thorax\"), (\"thorax\", \"abdomen\")]\n)\n\n# Create video.\nvideo = sio.load_video(\"test.mp4\")\n\n# Create instance.\ninstance = sio.Instance.from_numpy(\n    points=np.array([\n        [10.2, 20.4],\n        [5.8, 15.1],\n        [0.3, 10.6],\n    ]),\n    skeleton=skeleton\n)\n\n# Create labeled frame.\nlf = sio.LabeledFrame(video=video, frame_idx=0, instances=[instance])\n\n# Create labels.\nlabels = sio.Labels(videos=[video], skeletons=[skeleton], labeled_frames=[lf])\n\n# Save.\nlabels.save(\"labels.slp\")\n```\n\n## Support\nFor technical inquiries specific to this package, please [open an Issue](https://github.com/talmolab/sleap-io/issues)\nwith a description of your problem or request.\n\nFor general SLEAP usage, see the [main website](https://sleap.ai).\n\nOther questions? Reach out to `talmo@salk.edu`.\n\n## License\nThis package is distributed under a BSD 3-Clause License and can be used without\nrestrictions. See [`LICENSE`](LICENSE) for details.\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Standalone utilities for working with pose data from SLEAP and other tools.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://sleap.ai",
        "Repository": "https://github.com/talmolab/sleap-io"
    },
    "split_keywords": [
        "sleap",
        " pose tracking",
        " pose estimation",
        " behavior"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f2a6e6fe234c452fb9925162baecedbb36ff64f5e4f42e84f683ee6b3c1fb624",
                "md5": "8062f94b3ad31af03df4820fef7eb807",
                "sha256": "bf913c0bb69f77db0362d83405bc04f54e91791557a08ee258d36e0ddd068a27"
            },
            "downloads": -1,
            "filename": "sleap_io-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8062f94b3ad31af03df4820fef7eb807",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 48492,
            "upload_time": "2024-04-14T07:43:01",
            "upload_time_iso_8601": "2024-04-14T07:43:01.983986Z",
            "url": "https://files.pythonhosted.org/packages/f2/a6/e6fe234c452fb9925162baecedbb36ff64f5e4f42e84f683ee6b3c1fb624/sleap_io-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb80b91b7ffd91faba5b18f26c79c540450702630ed09e1e84bba10a35c2646d",
                "md5": "146b8f680e82c8ac2486940a410c4663",
                "sha256": "56e46e3a5926644412484931b35366fca3425039d97d31bd7b593e43302ae766"
            },
            "downloads": -1,
            "filename": "sleap_io-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "146b8f680e82c8ac2486940a410c4663",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 43521,
            "upload_time": "2024-04-14T07:43:03",
            "upload_time_iso_8601": "2024-04-14T07:43:03.991621Z",
            "url": "https://files.pythonhosted.org/packages/cb/80/b91b7ffd91faba5b18f26c79c540450702630ed09e1e84bba10a35c2646d/sleap_io-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-14 07:43:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "talmolab",
    "github_project": "sleap-io",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sleap-io"
}
        
Elapsed time: 0.23879s