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 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.
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.
The main processing pipeline of the wristpy module can be described as follows:
actfast
, and a WatchData
object is created to store all sensor dataNone
, gradient
, ggir
.wear
or not wear
.Install this package from PyPI via :
pip install wristpy
wristpy /input/file/path.gt3x -o /save/path/file_name.csv -c gradient
wristpy /path/to/files/input_dir -o /path/to/files/output_dir -c gradient -O .csv
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 available 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
from wristpy.core import orchestrator
# Define input file path and output location
input_path = '/path/to/files/input_dir'
output_path = '/path/to/files/output_dir'
# Run the orchestrator
# Specify the output file type, support for saving as .csv and .parquet
results_dict = orchestrator.run(
input=input_path,
output=output_path,
calibrator='gradient', # Choose between 'ggir', 'gradient', or 'none'
output_filetype = '.csv'
)
#Data available in dictionry of results.
subject1 = results_dict['subject1']
enmo = subject1.enmo
anglez = subject1.anglez
physical_activity_levels = subject1.physical_activity_levels
nonwear_array = subject1.nonwear_epoch
sleep_windows = subject1.sleep_windows_epoch