Skip to content

Commit

Permalink
fixed comments from draft pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
DhruvSkyy committed Dec 17, 2023
1 parent fcfefd7 commit 8509dbd
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs/source/api_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Input/Output
from_sleap_file
from_dlc_file
from_dlc_df
from_lp_file

.. currentmodule:: movement.io.save_poses
.. autosummary::
Expand Down
8 changes: 8 additions & 0 deletions docs/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ ds = load_poses.from_dlc_df(df, fps=30)
```
:::

:::{tab-item} Lightning Pose

Load from Lightning Pose (LP) files (`.csv`):
```python
ds = load_poses.from_lp_file("/path/to/file.analysis.csv", fps=30)
```
:::

::::

You can also try movement out on some sample data included in the package.
Expand Down
37 changes: 37 additions & 0 deletions docs/source/sg_execution_times.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

:orphan:

.. _sphx_glr_sg_execution_times:


Computation times
=================
**00:00.401** total execution time for 1 file **from all galleries**:

.. container::

.. raw:: html

<style scoped>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css" rel="stylesheet" />
</style>
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
<script type="text/javascript" class="init">
$(document).ready( function () {
$('table.sg-datatable').DataTable({order: [[1, 'desc']]});
} );
</script>

.. list-table::
:header-rows: 1
:class: table table-striped sg-datatable

* - Example
- Time
- Mem (MB)
* - :ref:`sphx_glr_examples_load_and_explore_poses.py` (``../../examples/load_and_explore_poses.py``)
- 00:00.401
- 0.0
28 changes: 10 additions & 18 deletions movement/io/load_poses.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def from_sleap_file(
def from_lp_file(
file_path: Union[Path, str], fps: Optional[float] = None
) -> xr.Dataset:
"""Load pose tracking data from a LightningPose output file
"""Load pose tracking data from a LightningPose (LP) output file
into an xarray Dataset.
Parameters
Expand All @@ -180,14 +180,10 @@ def from_lp_file(
xarray.Dataset
Dataset containing the pose tracks, confidence scores, and metadata.
See Also
--------
movement.io.load_poses.from_dlc_df : Load pose tracks from a DataFrame.
Examples
--------
>>> from movement.io import load_poses
>>> ds = load_poses.from_lp_file("path/to/file.h5", fps=30)
>>> ds = load_poses.from_lp_file("path/to/file.csv", fps=30)
"""

return _from_lp_or_dlc_file(
Expand Down Expand Up @@ -235,35 +231,31 @@ def _from_lp_or_dlc_file(
source_software: Literal["LightningPose", "DeepLabCut"],
fps: Optional[float] = None,
) -> xr.Dataset:
"""Loads pose tracking data from a DeepLabCut (DLC) output file or
a LightningPose file into an xarray Dataset.
"""Loads pose tracking data from a DeepLabCut (DLC) or
a LightningPose (LP) output file into an xarray Dataset.
Parameters
----------
file_path : pathlib.Path or str
Path to the file containing the DLC predicted poses, either in ".h5"
or ".csv" format.
source_software : {'LightningPose', 'DeepLabCut'}
fps : float, optional
The number of frames per second in the video. If None (default),
the `time` coordinates will be in frame numbers.
source_software : Can be either "DeepLabCut" or "LightningPose".
Returns
-------
xarray.Dataset
Dataset containing the pose tracks, confidence scores, and metadata.
See Also
--------
movement.io.load_poses.from_dlc_df : Load pose tracks from a DataFrame.
from_lp_file
"""

expected_suffix = [".csv"]
if source_software == "DeepLabCut":
expected_suffix.append(".h5")

file = ValidFile(
file_path,
expected_permission="r",
expected_suffix=[".csv", ".h5"],
file_path, expected_permission="r", expected_suffix=expected_suffix
)

# Load the DLC poses into a DataFrame
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def pytest_configure():
"SLEAP_three-mice_Aeon_proofread.predictions.slp",
"SLEAP_three-mice_Aeon_mixed-labels.analysis.h5",
"SLEAP_three-mice_Aeon_mixed-labels.predictions.slp",
"LP_mouse-face_AIND.predictions.csv",
"LP_mouse-twoview_AIND.predictions.csv",
]
}

Expand Down

0 comments on commit 8509dbd

Please sign in to comment.