talmolab / sleap

A deep learning framework for multi-animal pose tracking.
https://sleap.ai
Other
436 stars 97 forks source link

Add option to export to CSV via `sleap-convert` and API #1713

Closed eberrigan closed 7 months ago

eberrigan commented 8 months ago

It would be convenient to be able to export predictions stored in .SLP files to .CSV (see linked discussion).

Enhancement plan

  1. Add csv as an option for the --format flag in the sleap-convert CLI here:

https://github.com/talmolab/sleap/blob/2d24296c2149402c7ee07601e4d0272fdd308441/sleap/io/convert.py#L67-L75

  1. If csv format is requested, use csv=True in the sleap-convert CLI entrypoint function:

https://github.com/talmolab/sleap/blob/2d24296c2149402c7ee07601e4d0272fdd308441/sleap/io/convert.py#L165-L172

  1. The CSV writing is already handled through the IO format backends, so we can just route it through by adding csv as an option in the actual analysis exporting writer:

https://github.com/talmolab/sleap/blob/2d24296c2149402c7ee07601e4d0272fdd308441/sleap/io/convert.py#L177-L181

Discussed in https://github.com/talmolab/sleap/discussions/1629

Originally posted by **talmo** December 7, 2023 In #1438, we added a feature to export tracks to CSV format from the GUI. It would be great to be able to do that via the `sleap-export` CLI and the `Labels.export()` API. For `sleap-export`, we just need to add CSV as a target format and pass in `csv=True` in the [export call here](https://github.com/talmolab/sleap/blob/2d24296c2149402c7ee07601e4d0272fdd308441/sleap/io/convert.py#L165-L171). For `Labels.export()`, we probably want to [extend what's going on here](https://github.com/talmolab/sleap/blob/2d24296c2149402c7ee07601e4d0272fdd308441/sleap/io/dataset.py#L2035-L2056). We should also be sure to support the new functionality being added in #1624. Relevant: #1627
roaldarbol commented 3 months ago

Any idea when you're cutting a new release? This feature would be great to have without having to build from source. :-)

talmo commented 3 months ago

Soon™ :)