From minute-level data with sleep/wake labels (label.sw 1 = sleep, 0 = wake),
extracts sleep/wake onsets, episode durations, circular SDs of onset times,
Sleep Regularity Index (SRI), cosinor parameters, day/night variance ratio,
and nonparametric metrics (RA, IS, IV, L5, M10). Returns one row per episode
with scalar metrics repeated per row (tidy format).
extract_sleep_metrics(df, min_sleep_episode_min = 180L)A data.frame with columns including:
Subject ID obtained from the stem of filename.
sleep or wake
datetime of sleep onset time and wake onset time
timestamps presented as minutes of the day since midnight
sleep duration or wake duration
Standard devation of sleep onset time (calculated by circular statistics)
Standard devation of sleep onset time (calculated by circular statistics)
Sleep regularity index
parameters obtained from the cosinor model
nonparametrics actigraphy metrics
data.frame with columns id, Date, Time, Activity, label.sw.
Minimum duration (minutes) to treat as a main sleep episode.
sleep_detection(), sleep_cos(), extract_nonparametric_metrics()