Welcome to wristpy, a Python library designed for processing and analyzing wrist-worn accelerometer data. This library provides a set of tools for calibrating raw accelerometer data, calculating physical activity metrics (ENMO derived) and sleep metrics (angle-Z derived), finding non-wear periods, and detecing sleep periods (onset and wakeup times). Additionally, we provide access to other sensor dat 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 | ✅ |
Install this package via :
pip install wristpy
Or get the newest development version via:
pip install git+https://github.com/childmindresearch/wristpy
Here is a sample script that goes through the various functions that are built into wristpy.
#loading the prerequisite modules
import wristpy
from wristpy.core import computations
from wristpy.io.readers import readers
from wristpy.processing import metrics, analytics
#set the paths to the raw data and the desired output path
file_path = '/path/to/your/file.gt3x'
#load the acceleration data
test_data = readers.read_watch_data(file_path)
#calibrate the data
calibrator = calibration.Calibration()
calibrated_data = calibrator.run(test_data.acceleration)
#Compute some metrics and get epoch1 data
enmo = metrics.euclidean_norm_minus_one(calibrated_data)
anglez = metrics.angle_relative_to_horizontal(calibrated_data)
enmo_epoch1 = computations.moving_mean(enmo)
anglez_epoch1 = computations.moving_mean(anglez)
#Find sleep windows
sleep_detector_class = analytics.GGIRSleepDetection(anglez)
sleep_windows = sleep_detector_class.run_sleep_detection()
#Find non-wear periods
non_wear_array = metrics.detect_nonwear(calibrated_data, 900,4, 0.1,0.5)
#Get activity levels
activity_measurement = analytics.compute_physical_activty_categories(enmo_epoch1)