Learn R Programming

CircaCP (version 0.1.2)

extract_sleep_metrics: Extract metrics related to sleep and circadian rhythm after using CircaCP algorithm

Description

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).

Usage

extract_sleep_metrics(df, min_sleep_episode_min = 180L)

Value

A data.frame with columns including:

id

Subject ID obtained from the stem of filename.

period_type

sleep or wake

timestamp

datetime of sleep onset time and wake onset time

clock_min

timestamps presented as minutes of the day since midnight

duration_hours

sleep duration or wake duration

SleepTimeSD_hours

Standard devation of sleep onset time (calculated by circular statistics)

WakeTimeSD_hours

Standard devation of sleep onset time (calculated by circular statistics)

SRI

Sleep regularity index

Mesor, Amplitude, Acrophase

parameters obtained from the cosinor model

RA, IS, IV, L5_mean, L5_start_min, M10_mean, M10_start_min

nonparametrics actigraphy metrics

Arguments

df

data.frame with columns id, Date, Time, Activity, label.sw.

min_sleep_episode_min

Minimum duration (minutes) to treat as a main sleep episode.

See Also

sleep_detection(), sleep_cos(), extract_nonparametric_metrics()