Skip to content
No description, website, or topics provided.
HTML Python TeX
Branch: master
Clone or download
Latest commit f72970b Nov 6, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs update docs Nov 1, 2019
gaitpy update requirements Oct 30, 2019
paper Merge pull request #20 from arfon/patch-4 Nov 3, 2019
.gitignore Create .gitignore Oct 4, 2019
.travis.yml unit testing updates Oct 24, 2019 Upload files Aug 26, 2019
LICENSE Initial commit Aug 26, 2019 Update - add missing file gaitpy/demo/demo_gait_features.csv Oct 7, 2019 Update Nov 5, 2019
requirements.txt update requirements Oct 30, 2019 Update Nov 4, 2019


Read and process raw vertical accelerometry data from a sensor on the lower back during gait; calculate clinical gait characteristics.


Build Status


GaitPy provides python functions to read accelerometry data from a single lumbar-mounted sensor and estimate clinical characteristics of gait.

  • Device location: lower back/lumbar
  • Sensing modality: Accelerometer
  • Sensor data: Vertical acceleration
  • Minimum sampling rate: 50Hz




GaitPy is compatible with python v3.6 on MacOSX, Windows, and Linux.

Installation via pip:

pip install gaitpy

You can also install it from source:

git clone
cd gaitpy
python install

Basic usage

GaitPy consists of the following 3 functions:

  1. classify_bouts: If your data consists of gait and non-gait data, run the classify_bouts function to first classify bouts of gait. If your data is solely during gait, this function is not necessary to use.
  2. extract_features: Extract initial contact (IC) and final contact (FC) events from your data and estimate various temporal and spatial gait features.
  3. plot_contacts: Plot the resulting bout detections and IC/FC events alongside your raw accelerometer signal.

GaitPy accepts a csv file or pandas dataframe that includes a column containing unix timestamps and a column containing vertical acceleration from a lumbar-mounted sensor. GaitPy makes three assumptions by default:

  1. Timestamps and vertical acceleration columns are labeled 'timestamps' and 'y' respectively, however this can be changed using the 'v_acc_col_name' and 'ts_col_name' arguments respectively.
  2. Timestamps are in Unix milliseconds and data is in meters per second squared, however this can be be changed using the 'ts_units' and 'v_acc_units' arguments respectively.
  3. Baseline vertical acceleration data is -9.8m/s^2 or -1g. If your baseline data is +9.8m/s^2 or +1g, set the 'flip' argument to True.

Additionally, the sample rate of your device (at least 50Hz) and height of the subject must be provided.

More details about the inputs and ouputs of each of these functions can be found in the documentation and Czech et al. 2019.status

from gaitpy.gait import Gaitpy

raw_data = 'raw-data-path or pandas dataframe'
sample_rate = 128 # hertz
subject_height = 170 # centimeters

#### Create an instance of Gaitpy ####
gaitpy = Gaitpy(raw_data,                           # Raw data consisting of vertical acceleration from lumbar location and unix timestamps
                sample_rate,                        # Sample rate of raw data (in Hertz)
                v_acc_col_name='y',                 # Vertical acceleration column name
                ts_col_name='timestamps',           # Timestamp column name
                v_acc_units='m/s^2',                # Units of vertical acceleration
                ts_units='ms',                      # Units of timestamps
                flip=False)                         # If baseline data is at +1g or +9.8m/s^2, set flip=True

#### Classify bouts of gait - Optional (use if your data consists of gait and non-gait periods)####
gait_bouts = gaitpy.classify_bouts(result_file='/my/folder/classified_gait.h5')     # File to save results to (None by default)

#### Extract gait characteristics ####
gait_features = gaitpy.extract_features(subject_height,                               # Subject height
                                        subject_height_units='centimeter',            # Units of subject height
                                        result_file='/my/folder/gait_features.csv',   # File to save results to (None by default)
                                        classified_gait=gait_bouts)                   # Pandas Dataframe or .h5 file results of classify_bouts function (None by default)

#### Plot results of gait feature extraction ####
gaitpy.plot_contacts(gait_features,                                     # Pandas Dataframe or .csv file results of extract_features function
                     result_file='/my/folder/plot_contacts.html)',      # File to save results to (None by default)
                     show_plot=True)                                    # Specify whether to display plot upon completion (True by default)

Running the demo

The demo file provided lets you to test whether GaitPy outputs the expected results on your system.

You may run the demo directly from a terminal window:

cd gaitpy/demo

You may also run the demo via a python interpreter. In a terminal window start python by typing:


In the interpreter window you can then import and run the demo with the following two commands:

from gaitpy.demo import demo

The demo script will prompt you to type in a results directory. Following the run, results will be saved in the provided results directory (less than 250kB of data will be saved). Running the demo should take less than a minute, though this may vary depending on your machine.


The Digital Medicine & Translational Imaging group at Pfizer, Inc supported the development of this package.


GaitPy is under the MIT license

You can’t perform that action at this time.