yasa.Hypnogram.sleep_statistics#

Hypnogram.sleep_statistics()[source]#

Compute standard sleep statistics from a hypnogram.

This function supports a 2, 3, 4 or 5-stage hypnogram.

Returns:
statsdict

Summary sleep statistics.

Notes

All values except SE, SME, SFI and the percentage of each stage are expressed in minutes. YASA follows the AASM guidelines to calculate these parameters:

  • Time in Bed (TIB): total duration of the hypnogram.

  • Sleep Period Time (SPT): duration from first to last period of sleep.

  • Wake After Sleep Onset (WASO): duration of wake periods within SPT.

  • Total Sleep Time (TST): total sleep duration in SPT.

  • Sleep Onset Latency (SOL): Latency to first epoch of any sleep.

  • SOL 5min: Latency to 5 minutes of persistent sleep (any stage).

  • REM latency: latency to first REM sleep.

  • Sleep Efficiency (SE): TST / TIB * 100 (%).

  • Sleep Maintenance Efficiency (SME): TST / SPT * 100 (%).

  • Sleep Fragmentation Index: number of transitions from sleep to wake / hours of TST

  • Sleep stages amount and proportion of TST

Warning

Artefact and Unscored epochs are excluded from the calculation of the total sleep time (TST). TST is calculated as the sum of all REM and NREM sleep in SPT.

Warning

The definition of REM latency in the AASM scoring manual differs from the REM latency reported here. The former uses the time from first epoch of sleep, while YASA uses the time from the beginning of the recording. The AASM definition of the REM latency can be found with Lat_REM - SOL.

References

[Iber2007]

Iber (2007). The AASM manual for the scoring of sleep and associated events: rules, terminology and technical specifications. American Academy of Sleep Medicine.

[Silber2007]

Silber et al. (2007). The visual scoring of sleep in adults. Journal of Clinical Sleep Medicine, 3(2), 121-131.

Examples

Sleep statistics for a 2-stage hypnogram with a resolution of 15-seconds

>>> import pandas as pd
>>> from yasa import Hypnogram
>>> # Generate a fake hypnogram, where "S" = Sleep, "W" = Wake
>>> values = 10 * ["W"] + 40 * ["S"] + 5 * ["W"] + 40 * ["S"] + 9 * ["W"]
>>> hyp = Hypnogram(values, freq="15s", n_stages=2)
>>> pd.Series(hyp.sleep_statistics())
TIB         26.0000
SPT         21.2500
WASO         1.2500
TST         20.0000
SE          76.9231
SME         94.1176
SFI          1.5000
SOL          2.5000
SOL_5min     2.5000
WAKE         6.0000
dtype: float64

Sleep statistics for a 5-stage hypnogram

>>> from yasa import simulate_hypnogram
>>> # Generate a 8 hr (= 480 minutes) 5-stage hypnogram with a 30-seconds resolution
>>> hyp = simulate_hypnogram(tib=300, seed=42)
>>> pd.Series(hyp.sleep_statistics())
TIB        480.0000
SPT        477.5000
WASO        79.5000
TST        398.0000
SE          82.9167
SME         83.3508
SFI          0.7538
SOL          2.5000
SOL_5min     2.5000
Lat_REM     67.0000
WAKE        82.0000
N1          67.0000
N2         240.5000
N3          53.0000
REM         37.5000
%N1         16.8342
%N2         60.4271
%N3         13.3166
%REM         9.4221
dtype: float64