Skip to content

Commit 44e216e

Browse files
MMathisLabjeylau
andauthored
V0.0.1 -- hello world! (#4)
Co-authored-by: Jessy Lauer <[email protected]>
1 parent 8511407 commit 44e216e

28 files changed

+3268
-29
lines changed

.github/workflows/greetings.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Greetings
2+
3+
on: [pull_request, issues]
4+
5+
jobs:
6+
greeting:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
issues: write
10+
pull-requests: write
11+
steps:
12+
- uses: actions/first-interaction@v1
13+
with:
14+
repo-token: ${{ secrets.GITHUB_TOKEN }}
15+
issue-message: 'Welcome! Thank you for your contribution!'
16+
pr-message: 'Welcome! Thank you for your contribution!'
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, macos-11, windows-latest]
17+
python-version: [3.8, 3.9]
18+
include:
19+
- os: ubuntu-latest
20+
path: ~/.cache/pip
21+
- os: macos-11
22+
path: ~/Library/Caches/pip
23+
- os: windows-latest
24+
path: ~\AppData\Local\pip\Cache
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v2
29+
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip setuptools wheel
38+
python setup.py install
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
jobs:
16+
deploy:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: '3.x'
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install build
30+
- name: Build package
31+
run: python -m build
32+
- name: Publish package
33+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
34+
with:
35+
user: __token__
36+
password: ${{ secrets.PYPI_API_TOKEN }}

LICENSE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Copyright 2020-2022 by The Mathis Laboratory of Adaptive Motor Control, Mackenzie Mathis, & contributors. All rights reserved.
2+
This project and all its files are available for non-commercial use only. This software may not be used to harm any person or animal deliberately.
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 112 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,123 @@
66

77
#### A post-deeplabcut module for kinematic analysis
88

9-
### under construction ...
9+
This repo will continue to grow, but here are some helper functions to get you started. Note, the API is subject to change. You can run the functions on data files obtained from running inference with [DeepLabCut](http://deeplabcut.org/). Currently, this code requires python 3.8 onwards. We recommend using the [DEEPLABCUT conda file](https://deeplabcut.github.io/DeepLabCut/docs/installation.html), and then simply run `pip install dlc2kinematics` within your environment.
1010

11-
Currently this is not yet publicly available, but feel free to "watch" or "star" to be notified of updates.
1211

1312
## Quick start
1413

15-
`pip install dlc2kinematics`
14+
``` bash
15+
pip install dlc2kinematics
16+
```
17+
## Useage
1618

17-
## License
19+
``` python
20+
import dlc2kinematics
21+
```
1822

19-
DLC2Kinematics is freely available for non-commercial use, and may be redistributed under these conditions. Please, see the license for further details.
23+
Load data:
2024

21-
## Contact
25+
``` python
26+
df, bodyparts, scorer = dlc2kinematics.load_data(<path of the h5 file>)
27+
```
2228

23-
Mackenzie Mathis - [email protected]
29+
### Basic Operations
30+
31+
Compute velocity:
32+
33+
- For all bodyparts:
34+
``` python
35+
df_vel = dlc2kinematics.compute_velocity(df,bodyparts=['all'])
36+
```
37+
- For only few bodyparts:
38+
``` python
39+
df_vel = dlc2kinematics.compute_velocity(df,bodyparts=['nose','joystick'])
40+
```
41+
42+
Compute acceleration:
43+
44+
- For all bodyparts:
45+
``` python
46+
df_acc = dlc2kinematics.compute_acceleration(df,bodyparts=['all'])
47+
```
48+
- For only few bodyparts:
49+
``` python
50+
df_vel = dlc2kinematics.compute_acceleration(df,bodyparts=['nose','joystick'])
51+
```
52+
53+
Compute speed:
54+
55+
``` python
56+
df_speed = dlc2kinematics.compute_speed(df,bodyparts=['nose','joystick'])
57+
```
58+
59+
### Computations in joint coordinates
60+
61+
To compute joint angles, we first create a dictionary where keys are the joint angles and the corresponding values are the set of bodyparts:
62+
63+
``` python
64+
joint_dict= {}
65+
joints_dict['R-Elbow'] = ['R_shoulder', 'Right_elbow', 'Right_wrist']
66+
```
67+
68+
and compute the joint angles with
69+
70+
``` python
71+
joint_angles = dlc2kinematics.compute_joint_angles(df,joints_dict)
72+
```
73+
74+
Compute joint angular velocity with
75+
76+
``` python
77+
joint_vel = dlc2kinematics.compute_joint_velocity(joint_angles)
78+
```
79+
80+
Compute joint angular acceleration with
81+
82+
``` python
83+
joint_acc = dlc2kinematics.compute_joint_acceleration(joint_angles)
84+
```
85+
86+
Compute correlation of angular velocity
87+
88+
``` python
89+
corr = dlc2kinematics.compute_correlation(joint_vel, plot=True)
90+
```
91+
92+
Compute PCA of angular velocity with
93+
94+
``` python
95+
pca = dlc2kinematics.compute_pca(joint_vel, plot=True)
96+
```
97+
### PCA-based reconstruction of postures
98+
99+
Compute and plot PCA based on posture reconstruction with:
100+
101+
``` python
102+
dlc2kinematics.plot_3d_pca_reconstruction(df_vel, n_components=10, framenumber=500,
103+
bodyparts2plot=bodyparts2plot, bp_to_connect=bp_to_connect)
104+
```
105+
106+
### UMAP Embeddings
107+
``` python
108+
dlc2kinematics.compute_umap(df, key=['LeftForelimb', 'RightForelimb'], chunk_length=30, fit_transform=True, n_neighbors=30, n_components=3,metric="euclidean")
109+
```
110+
111+
## Contributing
112+
113+
- If you spot an issue or have a question, please open an [issue](https://github.com/AdaptiveMotorControlLab/dlc2kinematics/issues) with a suitable tag.
114+
- For [code contributions](https://github.com/AdaptiveMotorControlLab/dlc2kinematics/pulls):
115+
- please see the [contributing guide](docs/CONTRIBUTING.md).
116+
- Please reference all issues this PR addresses in the description text.
117+
- Before submitting your PR, ensure all code is formatted properly by running
118+
``` bash
119+
black .
120+
```
121+
in the root directory.
122+
- Assign a reviewer, typically [MMathisLab](https://github.com/MMathisLab).
123+
- sign CLA.
124+
125+
## Acknowledgements
126+
127+
This code is a collect of contributions from members of the Mathis Laboratory over the years. In particular (alphabetical):
128+
Michael Beauzile, Sebastien Hausmann, Jessy Lauer, Mackenzie Mathis, Tanmay Nath, Steffen Schneider.

dlc2kinematics/__init__.py

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,58 @@
11
"""
2-
DLC2Kinematics
3-
©M. Mathis Labs
2+
dlc2kinematics
3+
© M. Mathis Lab
4+
https://github.com/AdaptiveMotorControlLab/dlc2kinematics/
45
"""
56

6-
from dlc2kinamtics.version import __version__
7+
from dlc2kinematics.version import __version__, VERSION
8+
from dlc2kinematics.preprocess import load_data, smooth_trajectory
9+
from dlc2kinematics.mainfxns import (
10+
compute_velocity,
11+
compute_acceleration,
12+
compute_speed,
13+
extract_kinematic_synergies,
14+
compute_umap,
15+
)
16+
from dlc2kinematics.plotting import (
17+
plot_joint_angles,
18+
plot_velocity,
19+
pca_plot,
20+
plot_3d_pca_reconstruction,
21+
visualize_synergies,
22+
plot_umap,
23+
)
24+
from dlc2kinematics.utils import auxiliaryfunctions
25+
26+
from dlc2kinematics.joint_analysis import (
27+
load_joint_angles,
28+
compute_joint_angles,
29+
compute_joint_velocity,
30+
compute_joint_acceleration,
31+
compute_correlation,
32+
compute_pca,
33+
)
34+
from dlc2kinematics.quaternions import (
35+
compute_joint_quaternions,
36+
compute_joint_doubleangles,
37+
plot_joint_quaternions,
38+
compute_joint_quaternion_velocity,
39+
compute_joint_quaternion_acceleration,
40+
_load_quaternions,
41+
)
42+
43+
try:
44+
from dlc2kinematics.plotting import (
45+
plot_joint_angles,
46+
plot_velocity,
47+
pca_plot,
48+
plot_3d_pca_reconstruction,
49+
visualize_synergies,
50+
)
51+
from dlc2kinematics.visualization import (
52+
Visualizer3D,
53+
MinimalVisualizer3D,
54+
MultiVisualizer,
55+
Visualizer2D,
56+
)
57+
except:
58+
print("Could not import plotting and visualization functions.")

0 commit comments

Comments
 (0)