|
PebbleOS v4.47.0-327-g7753e801d
|
Sleep classification from the wrist angle (van Hees et al., 2015). More...
Data Structures | |
| struct | pbl_vanhees_sample |
| Accelerometer sample, in mG. More... | |
Macros | |
| #define | PBL_VANHEES_SAMPLE_HZ 25 |
| Accelerometer sampling rate expected by the algorithm, in Hz. | |
| #define | PBL_VANHEES_ANGLE_THRESHOLD_DEG 5 |
| A larger angle difference between successive epochs is a posture change, in degrees. | |
| #define | PBL_VANHEES_TIME_THRESHOLD_M 5 |
| Minimum time without posture change of a sustained inactivity bout, in minutes. | |
| #define | PBL_VANHEES_LAG_M (PBL_VANHEES_TIME_THRESHOLD_M - 1) |
| Minutes between the end of a minute and its verdict. | |
Functions | |
| uint32_t | pbl_vanhees_state_size (void) |
| Get the size of the algorithm state. | |
| void | pbl_vanhees_init (struct pbl_vanhees *state) |
| Initialize the algorithm state. | |
| void | pbl_vanhees_analyze_samples (struct pbl_vanhees *state, const struct pbl_vanhees_sample *samples, uint32_t num_samples) |
| Analyze accelerometer samples. | |
| bool | pbl_vanhees_minute_update (struct pbl_vanhees *state, bool *inactive) |
| Classify the minute that ended PBL_VANHEES_LAG_M minutes ago. | |
Sleep classification from the wrist angle (van Hees et al., 2015).
The algorithm processes accelerometer samples at PBL_VANHEES_SAMPLE_HZ in 5 second epochs. Each epoch gives the angle of the Z axis (perpendicular to the skin) to the horizontal plane, computed from the per-axis median. A posture change is a difference of more than PBL_VANHEES_ANGLE_THRESHOLD_DEG between successive epochs, and a sustained inactivity bout is a period of at least PBL_VANHEES_TIME_THRESHOLD_M minutes without one.
It only classifies minutes: building sleep sessions out of them is left to the caller.
The caller owns the state, of size pbl_vanhees_state_size():
| #define PBL_VANHEES_ANGLE_THRESHOLD_DEG 5 |
A larger angle difference between successive epochs is a posture change, in degrees.
| #define PBL_VANHEES_LAG_M (PBL_VANHEES_TIME_THRESHOLD_M - 1) |
Minutes between the end of a minute and its verdict.
A minute at the very start of a bout is only known to be in one once the rest of the bout has been seen.
| #define PBL_VANHEES_SAMPLE_HZ 25 |
Accelerometer sampling rate expected by the algorithm, in Hz.
| #define PBL_VANHEES_TIME_THRESHOLD_M 5 |
Minimum time without posture change of a sustained inactivity bout, in minutes.
| void pbl_vanhees_analyze_samples | ( | struct pbl_vanhees * | state, |
| const struct pbl_vanhees_sample * | samples, | ||
| uint32_t | num_samples | ||
| ) |
Analyze accelerometer samples.
Samples are buffered until a full epoch is available.
| state | State passed to pbl_vanhees_init(). |
| samples | Samples, in mG, at PBL_VANHEES_SAMPLE_HZ. |
| num_samples | Number of samples in samples. |
| void pbl_vanhees_init | ( | struct pbl_vanhees * | state | ) |
Initialize the algorithm state.
| state | State, of pbl_vanhees_state_size() bytes. |
| bool pbl_vanhees_minute_update | ( | struct pbl_vanhees * | state, |
| bool * | inactive | ||
| ) |
Classify the minute that ended PBL_VANHEES_LAG_M minutes ago.
Called once a minute. A minute without samples discards the history.
| state | State passed to pbl_vanhees_init(). | |
| [out] | inactive | true if the whole minute lies in a sustained inactivity bout. |
inactive is then false). | uint32_t pbl_vanhees_state_size | ( | void | ) |
Get the size of the algorithm state.