Skip to main content

Calculation of hip joint angles from wearable inertial sensors and optical motion capture.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykinematics-1.0.1.tar.gz (33.9 kB view details)

Uploaded Source

Built Distribution

pykinematics-1.0.1-py3-none-any.whl (52.9 kB view details)

Uploaded Python 3

File details

Details for the file pykinematics-1.0.1.tar.gz.

File metadata

  • Download URL: pykinematics-1.0.1.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pykinematics-1.0.1.tar.gz
Algorithm Hash digest
SHA256 71a3c9f3326b496f026d2525a57054151256acaad25ac12651963403e3f6472a
MD5 d2870cb3510fbf6690a71b932c66c0e9
BLAKE2b-256 fc40f5c4c17144bb583c029b763e4caa4c73cbab3832857f2376f69449aa1313

See more details on using hashes here.

File details

Details for the file pykinematics-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pykinematics-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 52.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for pykinematics-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 788cba5400f9212d1f128587cb6457e2be37ad313733ab260dc9608435d995d1
MD5 84bc3ecdf20c0cf44d988574c19d665d
BLAKE2b-256 60939ed0e3e5367206571cead88c65316319d3b4380363672bd34ae22f7caec3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page