Skip to content

Commit

Permalink
Write SLP files (#55)
Browse files Browse the repository at this point in the history
* Add convenience attribute to HDF5Video to check for embedded images

* Do BGR -> RGB conversion in OpenCV backend

* Remove unused kwarg filter

* Add videos metadata writing for SLP files

* Add tracks writing

* Tweak HDF5 utils to create files if non-existent.

* Add symmetry conveniences and flipping helper.

* Add metadata and skeletons writing

* More symmetries test coverage

* Initial implementation of point/instance/frame writing

* Tests

* Fix structured array construction

* Add full labels writing

* Add high level API

* Update fixture to use relative instead of absolute path to video

* Add more docs on the revised fixture
  • Loading branch information
talmo authored Jul 25, 2023
1 parent ae61fb9 commit df1cff4
Show file tree
Hide file tree
Showing 11 changed files with 541 additions and 22 deletions.
1 change: 1 addition & 0 deletions sleap_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from sleap_io.model.labels import Labels
from sleap_io.io.main import (
load_slp,
save_slp,
load_nwb,
save_nwb,
load_labelstudio,
Expand Down
10 changes: 10 additions & 0 deletions sleap_io/io/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ def load_slp(filename: str) -> Labels:
return slp.read_labels(filename)


def save_slp(labels: Labels, filename: str):
"""Save a SLEAP dataset to a `.slp` file.
Args:
labels: A SLEAP `Labels` object (see `load_slp`).
filename: Path to save labels to ending with `.slp`.
"""
return slp.write_labels(filename, labels)


def load_nwb(filename: str) -> Labels:
"""Load an NWB dataset as a SLEAP `Labels` object.
Expand Down
Loading

0 comments on commit df1cff4

Please sign in to comment.