Skip to content

06. sleep score

Xin Niu edited this page Dec 20, 2024 · 9 revisions

Run run_sleepStageDetection.m to perform power spectrum analysis on macro channels and detect sleep stages (REM, non-REM, SWS) based on delta and spindle power. It is adapted from Maya's sleepScoringIEEG repository. The process is divided into the following main steps:

Remove interictal activities.

Interictal activity is a series of transient electrophysiological disturbances that occur in the brain between seizures. It's characterized by spikes, sharp waves, and high-frequency oscillations (HFOs). Interictal activity is a hallmark of focal epileptic disorders, such as mesial temporal lobe epilepsy (MTLE).

We adapt Maya's code to remove interictal activity before sleep scoring.

Channel selection with spectrogram.

In this step, a short-time Fourier transform (30-s window, no overlap, 0–40 Hz range, 0.2-Hz resolution is used to calculate the spectrum power of the macro signal and generates a spectrogram. The spectrogram is then used to identify the best channel for sleep stage detection. For enhanced visualization, a two-dimensional Gaussian filter with a standard deviation (σ) of 3 was applied to the data.

Key considerations for channel selection:

  • Prioritize frontal, cingulate, or parietal regions, as these are optimal for sleep scoring.
  • Focus on medially located contacts, which tend to have better spindle activity representation.
  • Look for channels with prominent spindle power, which are crucial for distinguishing sleep stages accurately.

Automated sleep scoring

For the selected channel, we averaged the power in the slow-wave (0.5–4 Hz) and spindle (9–16 Hz) frequency bands for each 30-s time point, resulting in two vectors representing slow-wave and spindle power. A two-component Gaussian mixture distribution to the slow wave-spindle joint vectors is fitted to represent synchronized NREM epochs versus desynchronized (REM/wakefulness) epochs. Then, calculate the posterior probability for each component given each time point and tag each time point according to the maximal posterior probability.

Call evaluateDelta.m to perform sleep scoring on the selected channels and produces figures that can be used to judge how well it performed.

Manual sleep scoring

Use manualValidationSleepScoring.m to fine-tune the scoring (remove/add epochs).