.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/load_and_explore_poses.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_load_and_explore_poses.py: Load and explore pose tracks =============================== Load and explore an example dataset of pose tracks. .. GENERATED FROM PYTHON SOURCE LINES 8-10 Imports ------- .. GENERATED FROM PYTHON SOURCE LINES 10-15 .. code-block:: Python from movement import sample_data from movement.io import load_poses from movement.plots import plot_centroid_trajectory .. GENERATED FROM PYTHON SOURCE LINES 16-21 Define the file path -------------------- This should be a file output by one of our supported pose estimation frameworks (e.g., DeepLabCut, SLEAP), containing predicted pose tracks. For example, the path could be something like: .. GENERATED FROM PYTHON SOURCE LINES 21-25 .. code-block:: Python # uncomment and edit the following line to point to your own local file # file_path = "/path/to/my/data.h5" .. GENERATED FROM PYTHON SOURCE LINES 26-28 For the sake of this example, we will use the path to one of the sample datasets provided with ``movement``. .. GENERATED FROM PYTHON SOURCE LINES 28-34 .. code-block:: Python file_path = sample_data.fetch_dataset_paths( "SLEAP_three-mice_Aeon_proofread.analysis.h5" )["poses"] print(file_path) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/.movement/data/poses/SLEAP_three-mice_Aeon_proofread.analysis.h5 .. GENERATED FROM PYTHON SOURCE LINES 35-37 Load the data into movement --------------------------- .. GENERATED FROM PYTHON SOURCE LINES 37-41 .. code-block:: Python ds = load_poses.from_sleap_file(file_path, fps=50) print(ds) .. rst-class:: sphx-glr-script-out .. code-block:: none Size: 27kB Dimensions: (time: 601, space: 2, keypoints: 1, individuals: 3) Coordinates: * time (time) float64 5kB 0.0 0.02 0.04 0.06 ... 11.96 11.98 12.0 * space (space) Size: 5kB 770.3 1.062e+03 773.3 1.062e+03 773.3 ... 618.6 194.6 618.4 194.6 616.4 Coordinates: * time (time) float64 5kB 0.0 0.02 0.04 0.06 ... 11.96 11.98 12.0 * space (space) .. GENERATED FROM PYTHON SOURCE LINES 63-65 Similarly we could plot the same keypoint's x, y coordinates for all individuals: .. GENERATED FROM PYTHON SOURCE LINES 65-69 .. code-block:: Python da = position.sel(keypoints="centroid") da.plot.line(x="time", row="individuals", aspect=2, size=2.5) .. image-sg:: /examples/images/sphx_glr_load_and_explore_poses_002.png :alt: individuals = AEON3B_NTP, individuals = AEON3B_TP1, individuals = AEON3B_TP2 :srcset: /examples/images/sphx_glr_load_and_explore_poses_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 70-75 Trajectory plots ---------------- We are not limited to ``xarray``'s built-in plots. The ``movement.plots`` module provides some additional visualisations, like ``plot_centroid_trajectory()``. .. GENERATED FROM PYTHON SOURCE LINES 75-80 .. code-block:: Python mouse_name = "AEON3B_TP1" fig, ax = plot_centroid_trajectory(position, individual=mouse_name) fig.show() .. image-sg:: /examples/images/sphx_glr_load_and_explore_poses_003.png :alt: Trajectory :srcset: /examples/images/sphx_glr_load_and_explore_poses_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.727 seconds) .. _sphx_glr_download_examples_load_and_explore_poses.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/neuroinformatics-unit/movement/gh-pages?filepath=notebooks/examples/load_and_explore_poses.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: load_and_explore_poses.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: load_and_explore_poses.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: load_and_explore_poses.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_