childmindresearch / wristpy

https://childmindresearch.github.io/wristpy/
GNU Lesser General Public License v2.1
2 stars 1 forks source link

Task: Implement GGIR "2023" Non-wear detection algorithm #35

Closed Asanto32 closed 1 month ago

Asanto32 commented 3 months ago

Description

Periods of non-wear in sensor data should be identified to avoid any negative impacts to further processing (daily statistics, sleep detection). This task will focus on implementing the GGIR "2023" non-wear detection algorithm. Non-wear time is detected on the basis of statistics derived from a rolling time window. A non-wear flag for a chunk of time is returned based on the non-wear score. The function takes in the calibrated acceleration Measurement and returns a new Measurement with the non-wear flag values.

A step in time is classified as non-wear if both of the following criteria are met for at least two out of the three accelerometer axes:

The size of the rolling time window and the size of the steps it takes in time are set to a default of 60 minutes (longsize_window) and 15 minutes (mediumsize_window), respectively. Note that longsize_window must be a multiple of mediumsize_window.

The criteria above is applied to the longsize_window to assign a non-wear score ([0 - 3]) to the entire longsize_window. We then step forward in time by mediumsize_window and repeat the process. As a result, each point in time is classified multiple times given that multiple steps of the rolling window classification will overlap. We retain the maximum non-wear score from these overlaps.

Finally, there is a pass to find isolated "1s" in the non-wear score, and set them to 2 (non-wear flag is true) if surrounded by >1 values. If the non-wear score for a chunk of time is >=2 the non-wear flag is set to 1.

Tasks

Freeform Notes

Implementation can be found here:

https://github.com/childmindresearch/wristpy/blob/e4475865de446eee6c9b4cbbbdfd038dc99a6fdf/src/wristpy/ggir/metrics_calc.py#L358