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 standard deviation of the accelerations is less than accelerometer brand specific reference values, which for most brands is 13.0 mg
The range of accelerations is less than 50 mg.
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
[x] Implement a function to obtain the non-wear score for a specific windowsize
[x] Group acceleration into short_epoch_length
[x] Apply the sliding window architecture and run the non-wear score function to find the non-wear score for each mediumsize_window along each axis
[x] Identify isolated 1s in the non-wear score. If the surrounding values are > 1
[x] Set the non-wear flag to 1 when the non-wear score is => 2
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 thatlongsize_window
must be a multiple ofmediumsize_window
.The criteria above is applied to the
longsize_window
to assign a non-wear score ([0 - 3]) to the entirelongsize_window
. We then step forward in time bymediumsize_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
windowsize
mediumsize_window
along each axisFreeform Notes
Implementation can be found here:
https://github.com/childmindresearch/wristpy/blob/e4475865de446eee6c9b4cbbbdfd038dc99a6fdf/src/wristpy/ggir/metrics_calc.py#L358