wristpy: Fast, User-Friendly Python Processing of Wrist-worn Accelerometer Data
wristpy: Fast, User-Friendly Python Processing of Wrist-worn Accelerometer Data - Published in JOSS (2025)
Science Score: 93.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 16 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords from Contributors
Repository
A Python package for wrist-worn accelerometer data processing.
Basic Info
- Host: GitHub
- Owner: childmindresearch
- License: lgpl-2.1
- Language: Python
- Default Branch: main
- Homepage: https://childmindresearch.github.io/wristpy/
- Size: 8.18 MB
Statistics
- Stars: 15
- Watchers: 8
- Forks: 5
- Open Issues: 10
- Releases: 0
Metadata Files
README.md
wristpy
A Python package for wrist-worn accelerometer data processing.
Welcome to wristpy, a Python library designed for processing and analyzing wrist-worn accelerometer data. This library provides a set of tools for loading sensor information, calibrating raw accelerometer data, calculating various physical activity metrics, finding non-wear periods, and detecting sleep periods (onset and wakeup times). Additionally, we provide access to other sensor data that may be recorded by the watch, including; temperature, luminosity, capacitive sensing, battery voltage, and all metadata.
Supported formats & devices
The package currently supports the following formats:
| Format | Manufacturer | Device | Implementation status | | --- | --- | --- | --- | | GT3X | Actigraph | wGT3X-BT | ✅ | | BIN | GENEActiv | GENEActiv | ✅ |
Special Note
The idle_sleep_mode for Actigraph watches will lead to uneven sampling rates during periods of no motion (read about this here). Consequently, this causes issues when implementing wristpy's non-wear and sleep detection. As of this moment, we fill in the missing acceleration data with the assumption that the watch is perfectly idle in the face-up position (Acceleration vector = [0, 0, -1]). The data is filled in at the same sampling rate as the raw acceleration data. In the special circumstance when acceleration samples are not evenly spaced, the data is resampled to the highest effective sampling rate to ensure linearly sampled data.
Processing pipeline implementation
The main processing pipeline of the wristpy module can be described as follows:
- Data loading: sensor data is loaded using
actfast, and aWatchDataobject is created to store all sensor data. - Data calibration: A post-manufacturer calibration step can be applied, to ensure that the acceleration sensor is measuring 1g force during periods of no motion. There are three possible options:
None,gradient,ggir. - Data imputation In the special case when dealing with the Actigraph
idle_sleep_mode == enabled, the gaps in acceleration are filled in after calibration, to avoid biasing the calibration phase. - Metrics Calculation: Calculates various activity metrics on the calibrated data, namely ENMO (Euclidean norm, minus one), MAD (mean amplitude deviation) 1, Actigraph activity counts2, MIMS (monitor-independent movement summary) unit 3, and angle-Z (angle of acceleration relative to the x-y axis).
- Non-wear detection: We find periods of non-wear based on the acceleration data. Specifically, the standard deviation of the acceleration values in a given time window, along each axis, is used as a threshold to decide
wearornot wear. Additionally, we can use the temperature sensor, when available, to augment the acceleration data. This is used in the CTA (combined temperature and acceleration) algorithm 4, and in the DETACH algorithm 5. Furthermore, ensemble classification of non-wear periods is possible by providing a list (of any length) of non-wear algorithm options. - Sleep Detection: Using the HDCZ6 and HSPT7 algorithms to analyze changes in arm angle we are able to find periods of sleep. We find the sleep onset-wakeup times for all sleep windows detected. Any sleep periods that overlap with detected non-wear times are removed, and any remaining sleep periods shorter than 15 minutes (default value) are removed. Additionally, the SIB (sustained inactivity bouts) and the SPT (sleep period time) windows are provided as part of the output to aid in sleep metric post-processing.
- Physical activity levels: Using the chosen physical activity metric (aggregated into time bins, 5 second default) we compute activity levels into the following categories: [
inactive,light,moderate,vigorous]. The threshold values can be defined by the user, while the default values are chosen based on the specific activity metric and the values found in the literature 8-10. - Data output: The output results can be saved in
.csvor.parquetdata formats, with the run-time configuration parameters saved in a.jsondictionary.
Installation
Install the wristpy package from PyPI via:
sh
pip install wristpy
Quick start
wristpy provides three flexible interfaces: a command-line tool for direct execution, an importable Python library, and a Docker image for containerized deployment.
Using Wristpy through the command-line:
Run single files:
sh
wristpy /input/file/path.gt3x -o /save/path/file_name.csv -c gradient
Run entire directories:
sh
wristpy /path/to/files/input_dir -o /path/to/files/output_dir -c gradient -O .csv
For a full list of command line arguments:
sh
wristpy --help
Using Wristpy through a python script or notebook:
Running single files:
```Python
from wristpy.core import orchestrator
Define input file path and output location
Support for saving as .csv and .parquet
inputpath = '/path/to/your/file.gt3x' outputpath = '/path/to/save/file_name.csv'
Run the orchestrator
results = orchestrator.run( input=inputpath, output=outputpath, calibrator='gradient', # Choose between 'ggir', 'gradient', or 'none' )
Data available in results object
physicalactivitymetric = results.physicalactivitymetric anglez = results.anglez physicalactivitylevels = results.physicalactivitylevels nonweararray = results.nonwearstatus sleepwindows = results.sleepstatus sibperiods = results.sibperiods sptperiods = results.sptperiods
```
Running entire directories:
```Python
from wristpy.core import orchestrator
Define input file path and output location
inputpath = '/path/to/files/inputdir' outputpath = '/path/to/files/outputdir'
Run the orchestrator
Specify the output file type, support for saving as .csv and .parquet
resultsdict = orchestrator.run( input=inputpath, output=outputpath, calibrator='gradient', # Choose between 'ggir', 'gradient', or 'none' outputfiletype = '.csv' )
Data available in dictionary of results.
subject1 = results_dict['subject1']
physicalactivitymetric = subject1.physicalactivitymetric anglez = subject1.anglez physicalactivitylevels = subject1.physicalactivitylevels nonweararray = subject1.nonwearstatus sleepwindows = subject1.sleepstatus sibperiods = subject1.sibperiods sptperiods = subject1.sptperiods
```
Using Wristpy Through Docker
Install Docker: Ensure you have Docker installed on your system. Get Docker
Pull the Docker image:
bash docker pull cmidair/wristpy:mainRun the Docker image with your data:
bash docker run -it --rm \ -v "/local/path/to/data:/data" \ -v "/local/path/to/output:/output" \ cmidair/wristpy:mainReplace/local/path/to/datawith the path to your input data directory and/local/path/to/outputwith where you want results saved.
To run a single file, we simply need to modify the mounting structure for the docker call slightly:
bash
docker run -it --rm \
-v "/local/path/to/data/file.bin:/data/file.bin" \
-v "/local/path/to/output:/output" \
cmidair/wristpy:main
Customizing the Pipeline:
The Docker image supports multiple input variables to customize processing. You can set these by simply chaining these inputs as you would for the CLI input:
bash
docker run -it --rm \
-v "/local/path/to/data/file.bin:/data/file.bin" \
-v "/local/path/to/output:/output" \
cmidair/wristpy:main /data --output /output --epoch-length 5 --nonwear-algorithm ggir --nonwear-algorithm detach --thresholds 0.1 0.2 0.4
For more details on available options, see the orchestrator documentation.
References
- Vähä-Ypyä H, Vasankari T, Husu P, Suni J, Sievänen H. A universal, accurate intensity-based classification of different physical activities using raw data of accelerometer. Clin Physiol Funct Imaging. 2015 Jan;35(1):64-70. doi: 10.1111/cpf.12127. Epub 2014 Jan 7. PMID: 24393233.
- A. Neishabouri et al., “Quantification of acceleration as activity counts in ActiGraph wearable,” Sci Rep, vol. 12, no. 1, Art. no. 1, Jul. 2022, doi: 10.1038/s41598-022-16003-x.
- John, D., Tang, Q., Albinali, F. and Intille, S., 2019. An Open-Source Monitor-Independent Movement Summary for Accelerometer Data Processing. Journal for the Measurement of Physical Behaviour, 2(4), pp.268-281.
- Zhou S, Hill RA, Morgan K, et al, Classification of accelerometer wear and non-wear events in seconds for monitoring free-living physical activityBMJ Open 2015; 5:e007447. doi: 10.1136/bmjopen-2014-007447.
- A. Vert et al., “Detecting accelerometer non-wear periods using change in acceleration combined with rate-of-change in temperature,” BMC Medical Research Methodology, vol. 22, no. 1, p. 147, May 2022, doi: 10.1186/s12874-022-01633-6.
- van Hees, V.T., Sabia, S., Jones, S.E. et al. Estimating sleep parameters using an accelerometer without sleep diary. Sci Rep 8, 12975 (2018). https://doi.org/10.1038/s41598-018-31266-z.
- van Hees, V. T., et al. A Novel, Open Access Method to Assess Sleep Duration Using a Wrist-Worn Accelerometer. PLoS One 10, e0142533 (2015). https://doi.org/10.1371/journal.pone.0142533.
- Hildebrand, M., et al. Age group comparability of raw accelerometer output from wrist- and hip-worn monitors. Medicine and Science in Sports and Exercise, 46(9), 1816-1824 (2014). https://doi.org/10.1249/mss.0000000000000289.
- Treuth MS, Schmitz K, Catellier DJ, McMurray RG, Murray DM, Almeida MJ, Going S, Norman JE, Pate R. Defining accelerometer thresholds for activity intensities in adolescent girls. Med Sci Sports Exerc. 2004 Jul;36(7):1259-66. PMID: 15235335; PMCID: PMC2423321.
- Aittasalo, M., Vähä-Ypyä, H., Vasankari, T. et al. Mean amplitude deviation calculated from raw acceleration data: a novel method for classifying the intensity of adolescents' physical activity irrespective of accelerometer brand. BMC Sports Sci Med Rehabil 7, 18 (2015). https://doi.org/10.1186/s13102-015-0010-0.
Owner
- Name: Child Mind Institute — Research Teams
- Login: childmindresearch
- Kind: organization
- Email: gregory.kiar@childmind.org
- Repositories: 62
- Profile: https://github.com/childmindresearch
GitHub organization for the Child Mind Institute Research Teams
JOSS Publication
wristpy: Fast, User-Friendly Python Processing of Wrist-worn Accelerometer Data
Authors
Child Mind Institute, New York, United States of America
Child Mind Institute, New York, United States of America
Child Mind Institute, New York, United States of America
Child Mind Institute, New York, United States of America
Child Mind Institute, New York, United States of America, Center for Biomedical Imaging and Neuromodulation, Nathan Kline Institute, Orangeburg, NY, United States of America, Department of Psychiatry, NYU Grossman School of Medicine, New York, NY, United States of America
Tags
accelerometer physical activity sleep detection wearable sensorsGitHub Events
Total
- Create event: 82
- Release event: 4
- Issues event: 62
- Watch event: 11
- Delete event: 74
- Issue comment event: 112
- Push event: 577
- Pull request event: 153
- Pull request review event: 175
- Pull request review comment event: 158
Last Year
- Create event: 79
- Release event: 4
- Issues event: 55
- Watch event: 10
- Delete event: 71
- Issue comment event: 103
- Push event: 551
- Pull request event: 142
- Pull request review comment event: 152
- Pull request review event: 165
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| frey-perez | 1****z@u****m | 118 |
| Adam Santorelli | 1****2@u****m | 49 |
| dependabot[bot] | 4****]@u****m | 7 |
| Florian Rupprecht | f****r@g****m | 6 |
| Reinder Vos de Wael | r****l@g****m | 5 |
| Florian Rupprecht | 3****0@u****m | 4 |
| Reinder Vos de Wael | r****l@c****g | 4 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 5 months ago
All Time
- Total issues: 77
- Total pull requests: 157
- Average time to close issues: 2 months
- Average time to close pull requests: 15 days
- Total issue authors: 7
- Total pull request authors: 12
- Average comments per issue: 0.62
- Average comments per pull request: 1.09
- Merged pull requests: 59
- Bot issues: 1
- Bot pull requests: 60
Past Year
- Issues: 35
- Pull requests: 97
- Average time to close issues: 2 months
- Average time to close pull requests: 11 days
- Issue authors: 7
- Pull request authors: 8
- Average comments per issue: 0.31
- Average comments per pull request: 0.87
- Merged pull requests: 33
- Bot issues: 1
- Bot pull requests: 40
Top Authors
Issue Authors
- Asanto32 (46)
- ReinderVosDeWael (18)
- frey-perez (8)
- reindervdw-cmi (2)
- Sam54000 (1)
- tigretigre (1)
- dependabot[bot] (1)
Pull Request Authors
- dependabot[bot] (58)
- Asanto32 (45)
- frey-perez (29)
- ReinderVosDeWael (9)
- nx10 (5)
- reindervdw-cmi (4)
- pre-commit-ci[bot] (2)
- johnyang101 (1)
- clane9 (1)
- tigretigre (1)
- brutusyhy (1)
- monochandan (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- JamesIves/github-pages-deploy-action v4 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- chartboost/ruff-action v1 composite
- codecov/codecov-action v4 composite
- cfgv 3.4.0
- colorama 0.4.6
- coverage 7.4.1
- distlib 0.3.8
- filelock 3.13.1
- identify 2.5.33
- iniconfig 2.0.0
- jinja2 3.1.3
- markupsafe 2.1.4
- mypy 1.8.0
- mypy-extensions 1.0.0
- nodeenv 1.8.0
- numpy 1.26.3
- packaging 23.2
- pandas 2.2.0
- pdoc 14.4.0
- platformdirs 4.2.0
- pluggy 1.4.0
- polars 0.20.6
- pre-commit 3.6.0
- pygments 2.17.2
- pygt3x 0.5.2
- pytest 8.0.0
- pytest-cov 4.1.0
- python-dateutil 2.8.2
- pytz 2023.4
- pyyaml 6.0.1
- ruff 0.1.15
- setuptools 69.0.3
- six 1.16.0
- typing-extensions 4.9.0
- tzdata 2023.4
- virtualenv 20.25.0
- mypy ^1.7.1 develop
- pre-commit ^3.5.0 develop
- pytest ^8.0.0 develop
- pytest-cov ^4.1.0 develop
- ruff ^0.1.14 develop
- pdoc ^14.4.0 docs
- polars ^0.20.6
- pygt3x ^0.5.2
- python ~3.11
