Skip to main content

pykinematics

pykinematics is an open-source Python package for estimating hip kinematics using both novel Magnetic and Inertial Measurement Unit (MIMU) wearable sensors and existing Optical Motion Capture (OMC) algorithms. The novel MIMU algorithms have been validated against OMC, and include novel methods for estimating sensor-to-sensor relative orientation and sensor-to-segment alignment.

Documentation

Documentation including the below examples, and the API reference can be found at pykinematics documentation

Requirements

  • Python >=3.6
  • Numpy
  • Scipy
  • h5py*

pip should automatically collect any uninstalled dependencies.

* h5py is required to run the example code in /scripts/example_code.py, as the sample data provided (see Example Usage) is stored in the .hdf format. Pip will not catch and install h5py as it is not used by pykinematics, and must be installed manually to run the example code.

pip install h5py

or if using Anaconda

conda install -c anaconda h5py

Installation

pykinematics can be installed using pip:

pip install pykinematics

Alternatively, you can clone this repository and install from source.

pykinematics can be uninstalled by running

pip uninstall pykinematics

Running tests

Tests are implemented with pytest, and can be automatically run with:

pytest --pyargs pykinematics.tests

Optionally add -v to increase verbosity.

If you don't want to run the integration tests (methods tests), use the following:

python -m pykinematics.tests --no-integration

If you want to see coverage, the following can be run (assuming coverage is installed):

coverage run -m pytest --pyargs pykinematics.tests
# generate the report
coverage report
# generate a HTML report under ./build/index.html
coverage html

Example Usage

A full example script can be found in /scripts/example_code.py. This requires a sample data file, which can be downloaded from Sample Data

example_code.py contains a helper function to load the data into Python. Once the data is imported, the bulk of the processing is simple:

import pykinematics as pk

static_calibration_data, star_calibration_data, walk_fast_data = <loaded sample data>

# define some additional keyword arguments for optimizations and orientation estimation
filt_vals = {'Angular acceleration': (2, 12)}

ka_kwargs = {'opt_kwargs': {'method': 'trf', 'loss': 'arctan'}}
jc_kwargs = dict(method='SAC', mask_input=True, min_samples=1500, opt_kwargs=dict(loss='arctan'), mask_data='gyr')
orient_kwargs = dict(error_factor=5e-8, c=0.003, N=64, sigma_g=1e-3, sigma_a=6e-3)

mimu_estimator = pk.ImuAngles(gravity_value=9.8404, filter_values=filt_vals, joint_center_kwargs=jc_kwargs,
                              orientation_kwargs=orient_kwargs, knee_axis_kwargs=ka_kwargs)

# calibrate the estimator based on Static and Star Calibration tasks
mimu_estimator.calibrate(static_calibration_data, star_calibration_data)

# compute the hip joint angles for the Fast Walking on a treadmill
left_hip_angles, right_hip_angles = mimu_estimator.estimate(walk_fast_data, return_orientation=False)

Right hip angles from the sample data for walking fast:

Sample right hip angles

Metadata

Release files for pykinematics 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pykinematics 1.0.1
File Size Uploaded
pykinematics-1.0.1.tar.gz 33.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pykinematics 1.0.1
File Interpreter ABI Platform
pykinematics-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 86.8 kB

Release files / pykinematics-1.0.1.tar.gz

Download URL pykinematics-1.0.1.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
71a3c9f3326b496f026d2525a57054151256acaad25ac12651963403e3f6472a
BLAKE2b-256 checksum
How to use checksums
fc40f5c4c17144bb583c029b763e4caa4c73cbab3832857f2376f69449aa1313
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / pykinematics-1.0.1-py3-none-any.whl

Download URL pykinematics-1.0.1-py3-none-any.whl
Size 52.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
788cba5400f9212d1f128587cb6457e2be37ad313733ab260dc9608435d995d1
BLAKE2b-256 checksum
How to use checksums
60939ed0e3e5367206571cead88c65316319d3b4380363672bd34ae22f7caec3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page