Skip to content

Commit e989880

Browse files
committed
Merge branch 'main' into paper/JOSS-submission
2 parents 5d64370 + 3bad88b commit e989880

14 files changed

Lines changed: 487 additions & 381 deletions

File tree

.github/workflows/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [ubuntu-latest, windows-latest, macos-latest]
16-
python_version: ['3.10', '3.11', '3.12']
16+
python_version: ['3.10', '3.11', '3.12', '3.13']
1717
resolution: [lowest-direct, highest]
1818
steps:
1919
- uses: actions/checkout@v4
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install dependencies on macOS
2828
if: runner.os == 'macOS'
2929
run: |
30-
brew install libomp
30+
brew install libomp gfortran
3131
3232
- name: Install dependencies
3333
run: |

README.md

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[![LGPL--2.1 License](https://img.shields.io/badge/license-LGPL--2.1-blue.svg)](https://github.com/childmindresearch/wristpy/blob/main/LICENSE)
1414
[![pages](https://img.shields.io/badge/api-docs-blue)](https://childmindresearch.github.io/wristpy)
1515

16-
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.
16+
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.
1717

1818
## Supported formats & devices
1919

@@ -31,13 +31,14 @@ The package currently supports the following formats:
3131

3232
The main processing pipeline of the wristpy module can be described as follows:
3333

34-
- **Data loading**: sensor data is loaded using [`actfast`](https://github.com/childmindresearch/actfast), and a `WatchData` object is created to store all sensor data
34+
- **Data loading**: sensor data is loaded using [`actfast`](https://github.com/childmindresearch/actfast), and a `WatchData` object is created to store all sensor data.
3535
- **Data calibration**: A post-manufacturer calibration step can be applied, to ensure that the acceleration sensor is measuring 1*g* force during periods of no motion. There are three possible options: `None`, `gradient`, `ggir`.
3636
- ***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.
37-
- **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).
38-
- **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`.
39-
- **Sleep Detection**: Using the HDCZ<sup>1</sup> and HSPT<sup>2</sup> 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.
40-
- **Physical activity levels**: Using the enmo data (aggregated 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 study<sup>3</sup>.
37+
- **Metrics Calculation**: Calculates various activity metrics on the calibrated data, namely ENMO (Euclidean norm, minus one), MAD (mean amplitude deviation) <sup>1</sup>, Actigraph activity counts<sup>2</sup>, MIMS (monitor-independent movement summary) unit <sup>3</sup>, and angle-Z (angle of acceleration relative to the *x-y* axis).
38+
- **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`. Additionally, we can use the temperature sensor, when avaia\lable, to augment the acceleration data. This is used in the CTA (combined temperature and acceleration) algorithm <sup>4</sup>, and in the `skdh` DETACH algorithm <sup>5</sup>. Furthermore, ensemble classification of non-wear periods is possible by providing a list (of any length) of non-wear algorithm options.
39+
- **Sleep Detection**: Using the HDCZ<sup>6</sup> and HSPT<sup>7</sup> 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.
40+
- **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 <sup>8-10</sup>.
41+
- **Data output**: The output results can be saved in `.csv` or `.parquet` data formats, with the run-time configuration parameters saved in a `.json` dictionary.
4142

4243

4344
## Installation
@@ -178,13 +179,38 @@ For more details on available options, see the [orchestrator documentation](http
178179

179180

180181
## References
181-
1. van Hees, V.T., Sabia, S., Jones, S.E. et al. Estimating sleep parameters
182+
1. Vähä-Ypyä H, Vasankari T, Husu P, Suni J, Sievänen H. A universal, accurate
183+
intensity-based classification of different physical activities using raw data
184+
of accelerometer. Clin Physiol Funct Imaging. 2015 Jan;35(1):64-70.
185+
doi: 10.1111/cpf.12127. Epub 2014 Jan 7. PMID: 24393233.
186+
2. A. Neishabouri et al., “Quantification of acceleration as activity counts
187+
in ActiGraph wearable,” Sci Rep, vol. 12, no. 1, Art. no. 1, Jul. 2022,
188+
doi: 10.1038/s41598-022-16003-x.
189+
3. John, D., Tang, Q., Albinali, F. and Intille, S., 2019. An Open-Source
190+
Monitor-Independent Movement Summary for Accelerometer Data Processing. Journal
191+
for the Measurement of Physical Behaviour, 2(4), pp.268-281.
192+
4. Zhou S, Hill RA, Morgan K, et al, Classification of accelerometer wear and
193+
non-wear events in seconds for monitoring free-living physical activityBMJ
194+
Open 2015; 5:e007447. doi: 10.1136/bmjopen-2014-007447.
195+
5. A. Vert et al., “Detecting accelerometer non-wear periods using change
196+
in acceleration combined with rate-of-change in temperature,” BMC Medical
197+
Research Methodology, vol. 22, no. 1, p. 147, May 2022,
198+
doi: 10.1186/s12874-022-01633-6.
199+
6. van Hees, V.T., Sabia, S., Jones, S.E. et al. Estimating sleep parameters
182200
using an accelerometer without sleep diary. Sci Rep 8, 12975 (2018).
183-
https://doi.org/10.1038/s41598-018-31266-z
184-
2. van Hees, V. T., et al. A Novel, Open Access Method to Assess Sleep
201+
https://doi.org/10.1038/s41598-018-31266-z.
202+
7. van Hees, V. T., et al. A Novel, Open Access Method to Assess Sleep
185203
Duration Using a Wrist-Worn Accelerometer. PLoS One 10, e0142533 (2015).
186-
https://doi.org/10.1371/journal.pone.0142533
187-
3. Hildebrand, M., et al. Age group comparability of raw accelerometer output
204+
https://doi.org/10.1371/journal.pone.0142533.
205+
8. Hildebrand, M., et al. Age group comparability of raw accelerometer output
188206
from wrist- and hip-worn monitors. Medicine and Science in
189207
Sports and Exercise, 46(9), 1816-1824 (2014).
190-
https://doi.org/10.1249/mss.0000000000000289
208+
https://doi.org/10.1249/mss.0000000000000289.
209+
9. Treuth MS, Schmitz K, Catellier DJ, McMurray RG, Murray DM, Almeida MJ,
210+
Going S, Norman JE, Pate R. Defining accelerometer thresholds for activity
211+
intensities in adolescent girls. Med Sci Sports Exerc. 2004 Jul;36(7):1259-66.
212+
PMID: 15235335; PMCID: PMC2423321.
213+
10. Aittasalo, M., Vähä-Ypyä, H., Vasankari, T. et al. Mean amplitude deviation
214+
calculated from raw acceleration data: a novel method for classifying the
215+
intensity of adolescents' physical activity irrespective of accelerometer brand.
216+
BMC Sports Sci Med Rehabil 7, 18 (2015). https://doi.org/10.1186/s13102-015-0010-0.

docs/filtered_sleep_windows.png

Lines changed: 2 additions & 2 deletions
Loading

docs/nonwear_example4.png

Lines changed: 2 additions & 2 deletions
Loading

docs/sleep_anglez_example1.png

Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)