sleap.io.convert

Contents

sleap.io.convert#

Command line utility for converting between various dataset formats.

Reads: * SLEAP dataset in .slp, .h5, .json, or .json.zip file * SLEAP “analysis” file in .h5 format * LEAP dataset in .mat file * DeepLabCut dataset in .yaml or .csv file * DeepPoseKit dataset in .h5 file * COCO keypoints dataset in .json file

Writes: * SLEAP dataset (defaults to .slp if no extension specified) * SLEAP “analysis” file (.h5)

You don’t need to specify the input format; this will be automatically detected.

If you don’t specify an output path, then by default we will convert to a .slp dataset file and save it at <input path>.slp.

Analysis HDF5:

If you want to export an “analysis” h5 file, use --format analysis. If no output path is specified, the default is <input path>.<video index>_<video filename>.analysis.h5.

The analysis HDF5 file has these datasets:

  • “track_occupancy” (shape: tracks * frames)

  • “tracks” (shape: frames * nodes * 2 * tracks)

  • “track_names” (shape: tracks)

  • “node_names” (shape: nodes)

  • “edge_names” (shape: nodes - 1)

  • “edge_inds” (shape: nodes - 1)

  • “point_scores” (shape: frames * nodes * tracks)

  • “instance_scores” (shape: frames * tracks)

  • “tracking_scores” (shape: frames * tracks)

Note: the datasets are stored column-major as expected by MATLAB. This means that if you’re working with the file in Python you may want to first transpose the datasets so they matche the shapes described above.

sleap.io.convert.main(args: list | None = None)[source]#

Entrypoint for sleap-convert CLI for converting .slp to different formats.

Parameters:

args – A list of arguments to be passed into sleap-convert.