Note
Click here to download the full example code
Get sleep statistics¶
Get sleep statictics such as sleep stages duration, duration of the hypnogram.
from visbrain.io import download_file, get_sleep_stats
Hypnogram data¶
Download a hypnogram example
path_to_hypno = download_file("s101_jbe.hyp", astype='example_data')
Out:
STATUS : 0.0% 0 / 45660
STATUS : 17.9% 8192 / 45660
STATUS : 35.9% 16384 / 45660
STATUS : 53.8% 24576 / 45660
STATUS : 71.8% 32768 / 45660
STATUS : 89.7% 40960 / 45660
STATUS : 100.0% 49152 / 45660
Get sleep statistics¶
Sleep statistics are going to be printed in the terminal and then saved in a my_stats.csv
get_sleep_stats(path_to_hypno, output_file='my_stats.csv')
Out:
SLEEP STATS
===========
TIB 360.1666666666667
TDT 359.98333333333335
Art 39.5
W 19.166666666666668
N1 12.0
N2 115.5
N3 114.5
REM 59.5
LatN1 4.0
LatN2 7.0
LatN3 9.0
LatREM 66.0
SPT 355.98333333333335
WASO 15.0
TST 340.98333333333335
SE 94.72
Units minutes
File /home/circleci/visbrain_data/example_data/s101_jbe.hyp
===========
CSV file saved to: my_stats.csv
Total running time of the script: ( 0 minutes 1.063 seconds)