sleap-io


Namesleap-io JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryStandalone utilities for working with pose data from SLEAP and other tools.
upload_time2024-11-04 22:54:24
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/97/96/658d0beb74704e73cb91a6a76515d5ca2bd7f5402e047a31543d9c3c9e4e/sleap_io-0.2.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.2.0",
    "project_urls": {
        "Homepage": "https://io.sleap.ai",
        "Repository": "https://github.com/talmolab/sleap-io"
    },
    "split_keywords": [
        "sleap",
        " pose tracking",
        " pose estimation",
        " behavior"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "27947660a1681936c884032c6930bc6a0c9ffee77433b90d3e17f4b3b064418e",
                "md5": "6776f86f15d6f409435dde9591ab256a",
                "sha256": "e4b3028a30d52891d4260daf89e30901eb28c8c23afea4e62df0bda2ab4c9766"
            },
            "downloads": -1,
            "filename": "sleap_io-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6776f86f15d6f409435dde9591ab256a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 92850,
            "upload_time": "2024-11-04T22:54:23",
            "upload_time_iso_8601": "2024-11-04T22:54:23.583180Z",
            "url": "https://files.pythonhosted.org/packages/27/94/7660a1681936c884032c6930bc6a0c9ffee77433b90d3e17f4b3b064418e/sleap_io-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9796658d0beb74704e73cb91a6a76515d5ca2bd7f5402e047a31543d9c3c9e4e",
                "md5": "1e574e08010261b577a63332934b15c3",
                "sha256": "102ab096a3ec70d1e8a7f9da1f60807510084fac65dfee6f1e295638781084da"
            },
            "downloads": -1,
            "filename": "sleap_io-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1e574e08010261b577a63332934b15c3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 80037,
            "upload_time": "2024-11-04T22:54:24",
            "upload_time_iso_8601": "2024-11-04T22:54:24.605457Z",
            "url": "https://files.pythonhosted.org/packages/97/96/658d0beb74704e73cb91a6a76515d5ca2bd7f5402e047a31543d9c3c9e4e/sleap_io-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-04 22:54:24",
    "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: 4.97795s