View source: R/apply_tudor_locke.R
apply_tudor_locke | R Documentation |
The Tudor-Locke algorithm detects periods of time in bed and, for each period, computes sleep quality metrics such as total minutes in bed, total sleep time, number and average length of awakenings, movement and fragmentation index.
apply_tudor_locke( agdb, n_bedtime_start = 5, n_wake_time_end = 10, min_sleep_period = 160, max_sleep_period = 1440, min_nonzero_epochs = 0 )
agdb |
A |
n_bedtime_start |
Bedtime definition, in minutes. The default is 5. |
n_wake_time_end |
Wake time definition, in minutes. The default is 10. |
min_sleep_period |
Minimum sleep period length, in minutes. The default is 160. |
max_sleep_period |
Maximum sleep period length, in minutes. The default is 1440 (24 hours). |
min_nonzero_epochs |
Minimum number of epochs with non-zero activity. The default is 0. |
Once each one-minute epoch is labeled as asleep (S) or awake (W), we can use the Tudor-Locke algorithm to detect periods of bedtime and sleep time. By definition, sleep time < bedtime since one can be in bed and not sleeping.
Bedtime is (the first minute of) n_bedtime_start
consecutive
epochs/minutes labeled asleep (S). Similarly, wake time is
(the first minute of) of n_wake_time_end
consecutive
epochs/minutes labeled awake (W), after a period of sleep.
The block of time between bedtime and wake time is one sleep
period, if the time elapsed is at least min_sleep_period
minutes. There can be multiple sleep periods in 24 hours but a
sleep period cannot be longer than max_sleep_period
minutes.
For each sleep period, the algorithm calculates several measures of sleep quality such as time asleep and time awake, number and average length of awakenings, and movement and fragmentation indices.
This implementation of the Tudor-Locke algorithm detects all the sleep periods that ActiLife detects and, in some cases, it detects additional sleep periods. There are (at least) two such cases:
ActiLife filters out some sleep periods with exactly
min_nonzero_epochs
nonzero epochs. Alternatively, ActiLife
computes the number of nonzero epochs in a sleep period differently
and sometimes underestimates nonzero_epochs
compared to
apply_tudor_locke()
.
ActiLife filters out sleep periods that end when the activity
data ends, i.e., when the out_bed_time
is also the final
timestamp in the agdb
table.
A summary tibble
of the detected sleep periods.
If the activity data is grouped, then sleep periods are detected
separately for each group.
The first minute of the bedtime.
The first minute of wake time.
The first minute that the algorithm scores "asleep".
The time elapsed between bedtime and sleep onset. By the definition of Tudor-Locke, latency is 0.
The number of sleep minutes divided by the bedtime minutes.
The duration of the sleep period, in minutes.
The sum of activity counts for the entire sleep period.
The number of minutes scored as "asleep" during the sleep period.
The number of minutes scored as "awake", minus the sleep latency, during the sleep period.
The number of awakening episodes.
The average length, in minutes, of all awakening episodes.
Proportion of awake time out of the total time in bed, in percentages.
Proportion of one-minute sleep bouts out of the number of sleep bouts of any length, in percentages.
The sum of the movement and fragmentation indices.
The number of epochs with activity > 0 (nonzero epochs).
C Tudor-Locke, TV Barreira, JM Schuna Jr, EF Mire and PT Katzmarzyk. Fully automated waist-worn accelerometer algorithm for detecting children's sleep-period time separate from 24-h physical activity or sedentary behaviors. Applied Physiology, Nutrition, and Metabolism, 39(1):53–57, 2014.
ActiLife 6 User's Manual by the ActiGraph Software Department. 04/03/2012.
apply_sadeh()
, apply_cole_kripke()
library("dplyr") library("lubridate") data("gtxplus1day") # Detect sleep periods using Sadeh as the sleep/awake algorithm # and Tudor-Locke as the sleep period algorithm agdb <- gtxplus1day %>% collapse_epochs(60) %>% filter(day(timestamp) == 28) periods_sleep <- agdb %>% apply_sadeh() %>% apply_tudor_locke(min_sleep_period = 60) periods_sleep # Group and summarize by an extra varible (hour < 6 or not), which # splits one long sleep period in two agdb <- agdb %>% mutate(hour_lt6 = hour(timestamp) < 6) %>% group_by(hour_lt6) periods_sleep <- agdb %>% apply_sadeh() %>% apply_tudor_locke(min_sleep_period = 60) periods_sleep
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.