Tutorial
Automated sleep stage scoring at your fingertips. We walk you through an example in this tutorial.
Step 1: Select Recordings
SomnoBot uses a neural network that runs in your web browser on your computer to score human sleep with state-of-the-art accuracy. No data transfer to a server or other third party is required. The neural network was validated, published, and is open access.
-
Open the Sleep Scoring Webpage.
-
Click on "Select EDF file(s)" and select one or several of your EEG sleep recordings from your computer that you want SomnoBot to score (see figure 1, step 1).
- If you do not have an appropriate file at hand, you can download a recording from one of the publicly available data repositories, for instance this file from the SleepEDF dataset.
- We only support files in EDF format at this time. SomnoBot automatically scores human sleep based on electroencephalographic (EEG) recordings derived from scalp electrodes that were placed using the 10-20 system recommended by the American Academy of Sleep Medicine (AASM). We do not yet support the scoring of animal sleep or the scoring of intracranial recordings.
- Your EDF files are not shared with us or any other third party. Find out more here.
- Check the checkboxes of those files for which you want SomnoBot to score sleep (see figure 1, step 2).
- Optional: If you happen to know the lights off and lights on times for your recordings, you can enter them in the last two columns of the table (figure 1, step 3). If in doubt, don't change the prefilled values.
- lights off and lights on determine where SomnoBot starts and ends to score sleep in the recording. The first scored epoch starts with lights off.
- The automatically determined values for lights off and lights on correspond to the start and end times of the recording.
- By entering the actual lights off and on times, you can calculate more sleep statistics in step 4 of this tutorial.
Step 2: Select Channels
You need to select channels which will be used by SomnoBot to detect sleep stages. SomnoBot uses a neural network that is robust with respect to different channels and EEG montages. However, to achieve best scoring accuracies with SomnoBot, we recommend to select at least two EEG and one EOG channel (learn more about channel selection here).
- In the select channels panel, select at least two EEG and one EOG channel (see figure 2)
- The select channels panel will show only those channels that were recorded in all selected EDF files. If your EDF files do not share any channel, the channel selection panel will be empty.
- The more channels you select, the better SomnoBot will be able to score your recordings. However, more channels will increase compute time and memory requirements. We recommend to start with a small number of channels (e.g., three channels).
Step 3: Score Sleep and Download Scores
Automated sleep scoring can take several minutes per EDF file, depending on your computing hardware, the file sizes, and the number of selected channels. We recommend to close other applications and to free memory before starting the sleep staging process.
-
Click on "Classify Sleep Stages" to let SomnoBot score your sleep recordings (see figure 3).
-
Click on "Download Annotations" and "Download Metadata" to download the sleep scores and information (metadata) that can be useful when you need to describe the sleep scoring process for a scientific publication or thesis.
- SomnoBot will detect sleep stages regardless whether your recordings are strongly contaminated with artifacts or not. This is often very helpful, particularly for contaminated recordings. However, SomnoBot will yield sleep stages even for segments such as flatlines (e.g., when electrodes were not plugged in). This is expected behavior. We plan to detect artifacts in a future version of SomnoBot.
-
Inspect and download, if desired, hypnograms for the scored recordings.
- In case you selected several EDF files for scoring, you can visualize hypnograms for different EDF files using the select file for hypnogram panel.
Step 4: Calculate Sleep Statistics
Sleep statistics and other metrics can be calculated using your favorite tools. Here we demonstrate how you can calculate sleep statistics using a spreadsheet.
-
Open the file that you downloaded in the previous step.
-
Unzip the downloaded file to extract the txt file containing the sleep scores.
-
Each line of the txt file corresponds to an epoch of 30 seconds of the EEG recording.
-
The first column of the txt file contains the time point (in seconds) at which the epoch begins. Second 0 corresponds to the lights off time provided to SomnoBot when scoring sleep. If you did not change lights off/on times, SomnoBot will score the entire length of the recording. In this case, second 0 corresponds to the beginning of the recording.
-
The second column of the txt file contains the sleep scores. Both columns are separated by commas. Sleep scores are encoded as:
Sleep Score Corresponding Sleep Stage 0 Wake 5 REM 1 N1 2 N2 3 N3 -
-
Open and copy the spreadsheet we created for you here.
- Use the file menu to download the sheet or create a copy of the sheet that you can edit.
-
Copy the sleep scores from the annotation file into the sheet column titled "Sleep Data 01".
- Tip: You can easily extract the sleep scores from the txt file by opening the txt file in a spreadsheet.
-
Read the sleep statistics that were automatically calculated by the sheet.
Step 5 (optional): Assess Scoring Accuracy
SomnoBot uses a validated and published neural network to score human sleep with high accuracy. However, if you want to assess how SomnoBot scores compare to those of a human expert, we suggest the following.
-
Read and learn about sleep scoring accuracy of human experts and automated systems here.
-
Select one or several of your sleep recordings and score human sleep manually (or let another expert annotator score human sleep).
-
Use SomnoBot to determine sleep scores for your sleep recordings from step 3.
- Make sure that the epochs scored by SomnoBot are aligned to those scored by the human expert. The first epoch scored by SomnoBot begins at the lights off time you provided when selecting recordings (step 1).
-
Determine Cohen's Kappa between SomnoBot's scores and the manually determined scores. We provide a spreadsheet that can help you with calculating Cohen's Kappa.
-
Compare your Cohen's Kappa value with a distribution of Kappa values determined between pairs of expert scorers.
- By comparing your Cohen's Kappa value to this distribution, you can assess how close your and the SomnoBot's scores are to the average agreement expected between different human expert raters.