biopsykit.sleep.sleep_endpoints.sleep_endpoints module¶
Functions for computing sleep endpoints, i.e., parameters that characterize a recording during a sleep study.
- biopsykit.sleep.sleep_endpoints.sleep_endpoints.compute_sleep_endpoints(sleep_wake, bed_interval)[source]¶
Compute a set of sleep endpoints based on sleep/wake information and time spent in bed.
This functions computes the following sleep endpoints:
date
: date of recording if input data is time-aware,0
otherwise. NOTE: If the participant went to bed between 12 am and 6 am (i.e, the beginning ofbed_interval
between 12 am and 6 am)date
will be set to the day before (because this night is assumed to “belong” to the day before).sleep_onset
: Sleep Onset, i.e., time of falling asleep, in absolute timewake_onset
: Wake Onset, i.e., time of awakening, in absolute timetotal_sleep_duration
: Total duration spent sleeping, i.e., the duration between the beginning of the first sleep interval and the end of the last sleep interval, in minutesnet_sleep_duration
: Net duration spent sleeping, in minutesbed_interval_start
: Bed Interval Start, i.e., time when participant went to bed, in absolute timebed_interval_end
: Bed Interval End, i.e., time when participant left bed, in absolute timesleep_efficiency
: Sleep Efficiency, defined as the ratio between net sleep duration and total sleep duration in percentsleep_onset_latency
: Sleep Onset Latency, i.e., time in bed needed to fall asleep (difference between Sleep Onset and Bed Interval Start), in minutesgetup_latency
: Get Up Latency, i.e., time in bed after awakening until getting up (difference between Bed Interval End and Wake Onset), in minuteswake_after_sleep_onset
: Wake After Sleep Onset (WASO), i.e., total time awake after falling asleep (after Sleep Onset and before Wake Onset), in minutessleep_bouts
: List with start and end times of sleep boutswake_bouts
: List with start and end times of wake boutsnumber_wake_bouts
: Total number of wake bouts
- Parameters
sleep_wake (
DataFrame
) – dataframe with sleep/wake scoring of night. 1 is expected to indicate sleep, 0 to indicate wakebed_interval (array_like) – beginning and end of bed interval, i.e., the time spent in bed
- Returns
dictionary with computed sleep endpoints
- Return type
- biopsykit.sleep.sleep_endpoints.sleep_endpoints.endpoints_as_df(sleep_endpoints)[source]¶
Convert
SleepEndpointDict
intoSleepEndpointDataFrame
.- Parameters
sleep_endpoints (
SleepEndpointDict
) – dictionary with computed Sleep Endpoints- Returns
dataframe with computed Sleep Endpoints or
None
ifsleep_endpoints
isNone
- Return type