Extract sleep episodes from a CSPD-scored epoch table
Source:R/sleep_classify.R
extract_sleep_episodes.RdConverts the epoch-level state vector produced by detect_sleep_crespo()
into a per-episode tibble analogous to the Python SleepPipeline's
results.nights. Contiguous on-wrist sleep periods are delimited by
.nights_df(); per-epoch wake/sleep within each period is scored by
score_epochs_cole_kripke() to derive WASO, SOL, SOI, TST, EFF, and NW.
All time metrics are returned in minutes.
Arguments
- data
A tibble as returned by
detect_sleep_crespo(), containing columnsdatetime,ZCMn, andstate.- wake_thresh
integer(1). Minimum wake-bout length (epochs) used by.nights_df()to separate episode boundaries. Default60L.
Value
A tibble with one row per detected episode and columns bts
(POSIXct), gts (POSIXct), tbt, tst, sol, soi, waso
(minutes), nw (integer), eff (0-1), nap (logical, always FALSE
– classification into main/secondary happens in
classify_sleep_episodes()).