Derives standard sleep architecture summary statistics from a staged hypnogram. All metrics are resolution-agnostic: the function computes every metric that is possible given the available staging levels and silently omits metrics that require stages not present in the hypnogram (e.g. REM latency requires a full AASM hypnogram).
Arguments
- hypnogram
A tibble returned by
read_hypnogram(), or any tibble with at minimum columnsepoch(integer) andstage(factor).- epoch_sec
Epoch duration in seconds. Default
30.- lights_off, lights_on
Optional
POSIXcttimestamps for lights-off and lights-on. When supplied, TIB (time in bed) and SE (sleep efficiency) are computed relative to the recording period; otherwise the first and last sleep epoch bound the period.
Value
A one-row tibble with columns:
- tst_min
Total sleep time (minutes).
- tib_min
Time in bed (minutes).
NAiflights_off/lights_onnot supplied.- se_pct
Sleep efficiency (percent).
NAif TIB unavailable.- sol_min
Sleep onset latency (minutes).
- waso_min
Wake after sleep onset (minutes).
- rem_lat_min
REM latency (minutes).
NAfor coarse hypnograms.- sws_lat_min
SWS (N3) latency (minutes).
NAfor coarse hypnograms.- pct_n1,pct_n2,pct_n3,pct_rem
Stage percentages of TST.
NAfor stages absent in the hypnogram.- pct_sleep,pct_quiet_sleep
Stage percentages for coarse hypnograms.
NAfor full AASM hypnograms.- staging_resolution
"aasm"or"coarse".
Examples
if (FALSE) { # \dontrun{
hyp <- read_hypnogram("night_001.csv")
compute_sleep_architecture(hyp)
} # }