Skip to main content

wristpy is a Python package designed for processing and analyzing wrist-worn accelerometer data.

Project description

DOI

wristpy

A Python package for wrist-worn accelerometer data processing.

Build codecov Ruff stability-experimental LGPL--2.1 License pages

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 physical activity metrics (ENMO derived) and sleep metrics (angle-Z derived), 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, the authors of this package do not take any steps to impute data during these time gaps and would caution to not use data collected with this mode enabled. Of course, users can make use of the readers within wristpy for their own analysis with this type of 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 a WatchData object 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.
  • Metrics Calculation: Calculates various metrics on the calibrated data, namely ENMO (euclidean norm , minus one) 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 wear or not wear.
  • Sleep Detection: Using the HDCZ1 and HSPT2 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.
  • Physical activity levels: Using the enmo data (aggreagated into epoch 1 time bins, 5 second default) we compute activity levels into the following categories: inactivity, light activity, moderate activity, vigorous activity. The default threshold values have been chosen based on the values presented in the Hildenbrand 2014 study3.

Installation

Install this package from PyPI via :

pip install wristpy

Quick start

Using Wristpy through the command-line:

wristpy /input/file/path.gt3x -o /save/path/file_name.csv -c gradient

Using Wristpy through a python script or notebook:

from wristpy.core import orchestrator

# Define input file path and output location
# Support for saving as .csv and .parquet
input_path = '/path/to/your/file.gt3x'
output_path = '/path/to/save/file_name.csv'

# Run the orchestrator
results = orchestrator.run(
    input=input_path,
    output=output_path,
    calibrator='gradient',  # Choose between 'ggir', 'gradient', or 'none'
)

#Data availble in results object
enmo = results.enmo
anglez = results.anglez
physical_activity_levels = results.physical_activity_levels
nonwear_array = results.nonwear_epoch
sleep_windows = results.sleep_windows_epoch

References

  1. 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
  2. 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
  3. 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

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

wristpy-0.1.0.tar.gz (35.7 kB view details)

Uploaded Source

Built Distribution

wristpy-0.1.0-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file wristpy-0.1.0.tar.gz.

File metadata

  • Download URL: wristpy-0.1.0.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for wristpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f9a378212cedd48d745dde414bb8d4e6bd75a06d693220b1b7e1ae7bc4a5ec94
MD5 2d9f2a34c9d55d9ad5b8bc7a0bc8ee57
BLAKE2b-256 eee52c59ff89b60517a8c8dd66bc81bcee49fc28b1db782cbec4ee54080f26c9

See more details on using hashes here.

Provenance

File details

Details for the file wristpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wristpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 39.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for wristpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 568c48456424e7d6c32496026823e99d7674212d79d919bfebc413609bef4cdc
MD5 b1156cd0ceecdc145909e7e519368ff8
BLAKE2b-256 6743f0e5e6579f82ebf6e07d351b349e7e1110cce1febe66f9f55e55fcd25f45

See more details on using hashes here.

Provenance

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