You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
author = {Lobato-Rios, Victor and Ramalingasetty, Shravan Tata and Özdil, Pembe Gizem and Arreguit, Jonathan and Ijspeert, Auke Jan and Ramdya, Pavan},
13
+
month = may,
14
+
year = {2022},
15
+
pages = {620--627}
16
+
}
17
+
18
+
@software{Manceron_IKPy,
19
+
author = {Manceron, Pierre},
20
+
doi = {10.5281/zenodo.6551105},
21
+
license = {GPL-2.0},
22
+
title = {{IKPy}},
23
+
url = {https://github.com/Phylliade/ikpy}
24
+
}
25
+
26
+
27
+
@article{gunel:2019,
28
+
title = {{DeepFly3D}, a deep learning-based approach for {3D} limb and appendage tracking in tethered, adult {Drosophila}},
29
+
volume = {8},
30
+
issn = {2050-084X},
31
+
doi = {10.7554/eLife.48571},
32
+
language = {en},
33
+
urldate = {2022-09-09},
34
+
journal = {eLife},
35
+
author = {Günel, Semih and Rhodin, Helge and Morales, Daniel and Campagnolo, João and Ramdya, Pavan and Fua, Pascal},
36
+
month = oct,
37
+
year = {2019},
38
+
pages = {e48571}
39
+
}
40
+
41
+
@article{karashchuk:2021,
42
+
title = {Anipose: {A} toolkit for robust markerless {3D} pose estimation},
43
+
volume = {36},
44
+
issn = {22111247},
45
+
shorttitle = {Anipose},
46
+
doi = {10.1016/j.celrep.2021.109730},
47
+
language = {en},
48
+
number = {13},
49
+
urldate = {2022-09-09},
50
+
journal = {Cell Reports},
51
+
author = {Karashchuk, Pierre and Rupp, Katie L. and Dickinson, Evyn S. and Walling-Bell, Sarah and Sanders, Elischa and Azim, Eiman and Brunton, Bingni W. and Tuthill, John C.},
52
+
month = sep,
53
+
year = {2021},
54
+
pages = {109730}
55
+
}
56
+
57
+
@article{mathis_deeplabcut_2018,
58
+
title = {{DeepLabCut}: markerless pose estimation of user-defined body parts with deep learning},
59
+
volume = {21},
60
+
issn = {1097-6256, 1546-1726},
61
+
shorttitle = {{DeepLabCut}},
62
+
doi = {10.1038/s41593-018-0209-y},
63
+
language = {en},
64
+
number = {9},
65
+
urldate = {2022-09-09},
66
+
journal = {Nature Neuroscience},
67
+
author = {Mathis, Alexander and Mamidanna, Pranav and Cury, Kevin M. and Abe, Taiga and Murthy, Venkatesh N. and Mathis, Mackenzie Weygandt and Bethge, Matthias},
68
+
month = sep,
69
+
year = {2018},
70
+
pages = {1281--1289}
71
+
}
72
+
73
+
@article{pereira:2020,
74
+
title = {Quantifying behavior to understand the brain},
75
+
author = {Pereira, Talmo D and Shaevitz, Joshua W and Murthy, Mala},
76
+
journal = {Nature neuroscience},
77
+
volume = {23},
78
+
number = {12},
79
+
pages = {1537--1549},
80
+
year = {2020},
81
+
publisher = {Nature Publishing Group US New York}
82
+
}
83
+
84
+
@article{begon:2018,,
85
+
title = {Multibody kinematics optimization for the estimation of upper and lower limb human joint kinematics: a systematized methodological review},
86
+
author = {Begon, Micka{\"e}l and Andersen, Michael Skipper and Dumas, Rapha{\"e}l},
87
+
journal = {Journal of biomechanical engineering},
88
+
volume = {140},
89
+
number = {3},
90
+
pages = {030801},
91
+
year = {2018},
92
+
publisher = {American Society of Mechanical Engineers}
93
+
}
94
+
95
+
@article{delp:2007,
96
+
title = {OpenSim: open-source software to create and analyze dynamic simulations of movement},
97
+
author = {Delp, Scott L and Anderson, Frank C and Arnold, Allison S and Loan, Peter and Habib, Ayman and John, Chand T and Guendelman, Eran and Thelen, Darryl G},
98
+
journal = {IEEE transactions on biomedical engineering},
99
+
volume = {54},
100
+
number = {11},
101
+
pages = {1940--1950},
102
+
year = {2007},
103
+
publisher = {IEEE}
104
+
}
105
+
106
+
@inproceedings{aristidou:2018,
107
+
title = {Inverse kinematics techniques in computer graphics: A survey},
108
+
author = {Aristidou, Andreas and Lasenby, Joan and Chrysanthou, Yiorgos and Shamir, Ariel},
109
+
booktitle = {Computer graphics forum},
110
+
volume = {37},
111
+
number = {6},
112
+
pages = {35--58},
113
+
year = {2018},
114
+
organization = {Wiley Online Library}
115
+
}
116
+
117
+
118
+
@article{werling:2023,
119
+
title = {AddBiomechanics: Automating model scaling, inverse kinematics, and inverse dynamics from human motion data through sequential optimization},
120
+
author = {Werling, Keenon and Bianco, Nicholas A and Raitor, Michael and Stingel, Jon and Hicks, Jennifer L and Collins, Steven H and Delp, Scott L and Liu, C Karen},
121
+
journal = {Plos one},
122
+
volume = {18},
123
+
number = {11},
124
+
pages = {e0295152},
125
+
year = {2023},
126
+
publisher = {Public Library of Science San Francisco, CA USA}
127
+
}
128
+
129
+
130
+
@article{vaxenburg:2024,
131
+
title = {Whole-body simulation of realistic fruit fly locomotion with deep reinforcement learning},
132
+
doi = {10.1101/2024.03.11.584515},
133
+
language = {en},
134
+
urldate = {2024-03-15},
135
+
publisher = {bioRxiv},
136
+
author = {Vaxenburg, Roman and Siwanowicz, Igor and Merel, Josh and Robie, Alice A. and Morrow, Carmen and Novati, Guido and Stefanidi, Zinovia and Card, Gwyneth M. and Reiser, Michael B. and Botvinick, Matthew M. and Branson, Kristin M. and Tassa, Yuval and Turaga, Srinivas C.},
137
+
month = mar,
138
+
year = {2024}
139
+
}
140
+
141
+
@article{wang:2024,
142
+
title = {NeuroMechFly v2: simulating embodied sensorimotor control in adult Drosophila},
143
+
author = {Wang-Chen, Sibo and Stimpfling, Victor Alfred and Lam, Thomas Ka Chung and {\"O}zdil, Pembe Gizem and Genoud, Louise and Hurtak, Femke and Ramdya, Pavan},
144
+
journal = {Nature Methods},
145
+
pages = {1--10},
146
+
year = {2024},
147
+
publisher = {Nature Publishing Group US New York}
148
+
}
149
+
150
+
@article{pagnon:2022,
151
+
doi = {10.21105/joss.04362},
152
+
url = {https://doi.org/10.21105/joss.04362},
153
+
year = {2022},
154
+
publisher = {The Open Journal},
155
+
volume = {7},
156
+
number = {77},
157
+
pages = {4362},
158
+
author = {David Pagnon and Mathieu Domalain and Lionel Reveret},
159
+
title = {Pose2Sim: An open-source Python package for multiview markerless kinematics},
160
+
journal = {Journal of Open Source Software}
161
+
}
162
+
163
+
@inproceedings{todorov:2012,
164
+
title = {Mujoco: A physics engine for model-based control},
165
+
author = {Todorov, Emanuel and Erez, Tom and Tassa, Yuval},
166
+
booktitle = {2012 IEEE/RSJ international conference on intelligent robots and systems},
167
+
pages = {5026--5033},
168
+
year = {2012},
169
+
organization = {IEEE}
170
+
}
171
+
172
+
@article{
173
+
ozdil:2024,
174
+
author = {{\"O}zdil, Pembe Gizem and Arreguit, Jonathan and Scherrer, Clara and Ijspeert, Auke and Ramdya, Pavan},
175
+
title = {Centralized brain networks underlie body part coordination during grooming},
title: 'SeqIKPy: a Python package for inverse kinematics in insects'
3
+
tags:
4
+
- Python
5
+
- inverse kinematics
6
+
- motion analysis
7
+
- neuroscience
8
+
authors:
9
+
- name: Pembe Gizem Özdil
10
+
orcid: 0000-0003-4507-6642
11
+
affiliation: "1, 2"# (Multiple affiliations must be quoted)
12
+
- name: Chuanfang Ning
13
+
affiliation: 2
14
+
- name: Auke Ijspeert
15
+
orcid: 0000-0003-1417-9980
16
+
affiliation: 2
17
+
- name: Pavan Ramdya
18
+
orcid: 0000-0001-5425-4610
19
+
affiliation: 1
20
+
affiliations:
21
+
- name: Neuroengineering Laboratory, Brain Mind Institute, EPFL, Lausanne, Switzerland
22
+
index: 1
23
+
ror: 00hx57361
24
+
- name: Biorobotics Laboratory, Institute of Bioengineering, EPFL, Lausanne, Switzerland
25
+
index: 2
26
+
date: 21 January 2025
27
+
bibliography: paper.bib
28
+
---
29
+
30
+
# Summary
31
+
`SeqIKPy` is a Python package for inverse kinematics (IK) calculation in animal bodies with complex joint configurations. The name stands for Sequential Inverse Kinematics in Python, as our method computes joint angles sequentially by performing IK for each joint along a kinematic chain.
32
+
33
+
Our framework contains:
34
+
- Pose alignment: map tracked key point locations in 3D onto an animal body template.
35
+
- Inverse kinematics: calculate joint angles sequentially from 3D poses.
36
+
- Visualization: plot and animate the results in 3D.
37
+
38
+
`SeqIKPy` is aimed at researchers studying detailed joint motion in animals with complex, multiple degrees-of-freedom body appendages. We provide examples for the fruit fly, *Drosophila melanogaster*. However, each module can easily be extended to be used with another model organism; the only requirements are the 3D kinematics of the target animal and its corresponding kinematic chain. Our package requires minimal Python knowledge and we provide extensive tutorials at [https://nely-epfl.github.io/sequential-inverse-kinematics](https://nely-epfl.github.io/sequential-inverse-kinematics).
39
+
40
+
# Statement of need
41
+
42
+
Over the past decade, deep-learning based computer vision algorithms have transformed the analysis of behaviors in laboratory animals [@pereira:2020], including for the widely-used model organism, *Drosophila melanogaster*. Recently, researchers have developed deep learning-based 3D pose estimation tools [@gunel:2019; @karashchuk:2021] and detailed biomechanical models [@lobato-rios:2022; ; @vaxenburg:2024], creating a growing need for tools to obtain more detailed descriptions of how body parts move in joint space. These computed joint angles can be replayed in physics-based simulations to estimate unmeasured physical quantities like joint torques [@lobato-rios:2022].
43
+
44
+
Inverse Kinematics (IK) spans multiple domains including robotics, biomechanics, and character animation [@aristidou:2018]. In robotics, IK typically computes joint angles to achieve a desired end-effector position while respecting joint constraints. By contrast, in biomechanics, IK algorithms calculate joint angles to track all marker positions rather than only a single end-effector. This process is also known as multi-body kinematics optimization and is a well-established area in human biomechanics research [@delp:2007; @begon:2018; @pagnon:2022; @werling:2023].
45
+
46
+
However, multi-body kinematics optimization is still an emerging field in insect research. Existing methods fall on two extremes along a spectrum of complexity. Simple approaches have been employed to compute joint angles using the dot product of two consecutive body segment vectors [@lobato-rios:2022; @karashchuk:2021]. This often results in deviations from reference poses due to the lack of iterative corrections. On the other hand, more advanced gradient-based optimization methods have been developed to estimate joint angles in a biomechanical model of the fly [@vaxenburg:2024], using simulation-based Jacobians in physics-engines like MuJoCo [@todorov:2012]. Although these methods provide higher accuracy, they require complex setups that are not easily accessible to all researchers. Therefore, there is no stand-alone inverse kinematics software satisfying the trade-off between accuracy and complexity.
47
+
48
+
To address this gap, we have developed `SeqIKPy`, a fast and lightweight Python package for multi-body kinematics optimization in insects. Our package has two main stages: marker registration (aligning joint markers to a template in 3D) and inverse kinematics. The second stage draws upon the open-source IKPy [@Manceron_IKPy] library in a sequential manner. Through 3D visualizations, we demonstrate that our package can reliably reconstruct body kinematics for various fruit fly behaviors. Furthermore, recent studies have shown that the joint angles computed using `SeqIKPy` can accurately replicate animal behavior, both ground walking [@wang:2024] and grooming [@ozdil:2024], in physics-based simulations. Although our examples focus on the fly, our package's modular design allows for customization and extension to other animals with a similar body morphology.
49
+
50
+
# Overview
51
+
52
+
`SeqIKPy` assumes that the 3D pose estimation has the following orientation (\autoref{fig:pipeline}, left):
53
+
- x-axis: anterioposterior axis
54
+
- y-axis: mediolateral axis
55
+
- z-axis: dorsoventral axis
56
+
57
+
After setting this orientation, users can use the `AlignPose` class to map body keypoints to a template body model (\autoref{fig:pipeline}, middle). Despite being optional for inverse kinematics, this step has two benefits:
58
+
- It aligns measured kinematics to a standardized body template, facilitating replay of behaviors in body models (\autoref{fig:pipeline}, right).
59
+
- It reduces noise and variation in kinematics by standardizing body lengths.
60
+
61
+
We provide a default body template based on a CT scan of the fly [@lobato-rios:2022]. Users can also define custom templates manually or by importing SDF files. Utility functions are included to convert data into the required formats.
62
+
63
+
Next, the `KinematicChainSeq` class defines a pre-configured kinematic chain for fly legs. Users need a dictionary containing segment lengths and joint bounds (\autoref{fig:pipeline}, middle). Segment lengths can be derived from 3D kinematics, while joint bounds are optional. Using the defined kinematic chain, the `LegInvKin` class calculates joint angles sequentially for each leg. This process supports parallelization to perform IK on multiple legs simultaneously. Additionally, our package contains features for animation and visualization of data in 3D. For more technical details on the implementation, please refer to the methodology section at [https://nely-epfl.github.io/sequential-inverse-kinematics](https://nely-epfl.github.io/sequential-inverse-kinematics).
64
+
65
+
On a MacBook Pro with a 2.3 GHz Quad-Core Intel Core i7, the pipeline computes inverse kinematics for all six legs across 100 frames in 36 s when parallelized.
66
+
67
+

68
+
69
+
70
+
# Acknowledgements
71
+
72
+
We acknowledge the contributors and maintainers of the open-source software tools that SeqIKPy builds upon, including Python, NumPy, SciPy, Matplotlib, and IKPy [@Manceron_IKPy], among others. PGÖ acknowledges support from a Swiss Government Excellence Scholarship for Doctoral Studies and a Google PhD Fellowship. PR acknowledges support from an SNSF Project Grant (175667) and an SNSF Eccellenza Grant (181239).
0 commit comments