← Sleep Commons
bdsp-core · open source on GitHub

Sleep & EEG analysis code

The algorithms behind the Commons — 85 open-source tools for analyzing sleep and EEG data, from automated staging and spike detection to brain-age and outcome models. Every one links to its code, and many to the dataset it was built on.

Seizures & IIIC patterns

12

Detecting and quantifying seizures and rhythmic or periodic patterns in continuous EEG.

★ Featured

Morgoth

morgoth

Deep-learning detection of seizures and rhythmic/periodic (IIIC) patterns in continuous EEG, with event- and recording-level probabilities.

Python Code →
★ Featured

SPaRCNet (IIIC)

IIIC-SPaRCNet

Expert-level classification of seizures and rhythmic/periodic patterns during EEG interpretation.

MATLAB Code →

2HELPS2B

2helps2b-seizure-risk

The 2HELPS2B EEG-based seizure-risk score.

MATLAB Data Code →

Baby Morgoth

baby_morgoth

Six-class IIIC classification for neonatal and pediatric EEG, transfer-learned from Morgoth 2.

Python Code →

cEEG Seizure Risk

cceeg-multistate-seizure-risk

Time-dependent risk of seizures in critically ill patients on continuous EEG.

DDESVSFS (PNES screening)

ddesvsfs-pnes-screening

Screening epileptic versus functional (psychogenic non-epileptic) seizures.

MATLAB Data Code →

Epileptiform Activity & Discharge Outcome

epileptiform-activity-discharge-outcome

Effects of epileptiform activity on discharge outcome.

Python Data Code →

Epileptiform Burden & Outcomes

epileptiform-burden-outcomes

Automated epileptiform-burden annotation and its association with outcomes.

MATLAB Data Code →

IIIC Frequency Analysis

IIIC-Frequency-Analysis

Quantifies frequency, spatial extent, location and evolution of rhythmic and periodic EEG patterns.

MATLAB Code →

IIIC Interrater Reliability

IIIC-IRR

Reproduces our analysis of how consistently experts identify seizures and periodic/rhythmic patterns.

MATLAB Code →

Morgoth 2

morgoth2

Second-generation Morgoth IIIC detector, with improved models and training.

Python Code →

Rapid IIIC Labeling GUI

Rapid_IIIC_Labeling_GUI

Interface for rapid expert labeling of IIIC segments across one or many EEGs.

MATLAB Code →

Spikes & epileptiform discharges

9

Finding and characterizing interictal epileptiform discharges.

★ Featured

SpikeNet

SpikeNet1

Expert-level automated detection of interictal epileptiform discharges (spikes) in EEG.

Python Code →

CDAC Spike Detector

cdac_google

ResNet spike-detection pipeline trained with soft labels and 10-fold cross-validation.

Python Code →

IFCN-6 Spike GUI

IFCN6

Graphical interface for annotating spikes against the IFCN-6 criteria.

MATLAB Code →

Interpretable IED Criteria

interpretable-ied-criteria

Interpretable quantitative criteria for evaluating interictal epileptiform discharges.

MATLAB Data Code →

NeuroBrowser

neurobrowser

Mark one example waveform (e.g. a spike) and rapidly find every similar waveform across an EEG.

Python Code →

Noise in Diagnosing Epilepsy

Noise_in_Diagnosing_Epilepsy

Reproduces our study of noise and variability in the diagnosis of epilepsy.

Jupyter Notebook Code →

Persyst Spike Export

Persyst_Spike_Detection

Turns Persyst .sd4 spike-detection files from MGH long-term EEG into per-recording CSV annotations.

MATLAB Code →

Sharp Transients IRR

sharp-transients-irr

Interrater-reliability analysis for sharp transients and IEDs.

Python Code →

SpikeNet 2

SpikeNet2

Expert-level detection of epilepsy markers in EEG on both short and long timescales.

Jupyter Notebook Code →

Critical care & acute brain dysfunction

14

Coma, cardiac arrest, hemorrhage, delirium, encephalopathy and neurotoxicity.

★ Featured

NESI

NESI

A continuous EEG-derived measure of acute brain dysfunction, with trained model weights.

Python Code →

Burst-Suppression Segmentation

Burst-Suppression-Segmentation

Automatic detection of suppression periods in critically ill ICU patients.

MATLAB Code →

cEEG in Cardiac Arrest

ceeg-multimodal-cardiac-arrest

Continuous EEG added to multimodal outcome prediction after hypoxic-ischemic injury.

MATLAB Data Code →

Coma EEG Prognostics

hie-eeg-prognostics-1000

Prognostic EEG patterns in post-cardiac-arrest coma, in a 1,000-patient cohort.

Jupyter Notebook Data Code →

E-CAM-S

E-CAM-S

The EEG Confusion Assessment Method Severity score for physiological delirium grading.

Jupyter Notebook Code →

E-ICANS

E-ICANS

Learning-to-rank pipeline for automated ICANS severity from EEG.

Python Code →

Encephalopathy Grading IRR

EGG-IRR-1.0

Interrater reliability of EEG-based encephalopathy grading.

MATLAB Code →

GRDA / N3 Encephalopathy Model

GRDA-N3-encephaloapthy-model

Thalamocortical modeling of encephalopathic slowing and generalized rhythmic delta activity.

Python Code →

Hypothermia EEG

Hypothermia-EEG

Reproduces our analysis of EEG in comatose post-cardiac-arrest patients under hypothermia.

MATLAB Code →

I-CARE (deep learning)

icare-dl

Deep neural networks predicting neurological outcome in comatose patients after cardiac arrest.

MATLAB Code →

ICANS Forecasting

ICANS-forecasting-after-CAR-T-cell-therapy

Forecasting ICANS neurotoxicity after CAR-T cell therapy from EEG.

MATLAB Code →

SAH DCI Prediction

SAH_DCI_Prediction_EEG

Automated prediction of delayed cerebral ischemia after subarachnoid hemorrhage from EEG.

MATLAB Code →

VE-CAM-S

VE-CAM-S

Delirium-severity score from visual EEG features.

Python Code →

VE-ICANS

VE-ICANS

Visual-EEG-feature score for the severity of CAR-T neurotoxicity (ICANS).

Python Code →

Sleep staging & events

12

Automated sleep staging, arousal and event detection — from full PSG or a single signal.

★ Featured

CAISR

CAISR-App

Complete AI-based Sleep Report: automated staging, arousals, respiration and limb movements, as a downloadable app.

Python Code →

AirGo Sleep Staging

AirGo_SleepStaging

Sleep staging from the AirGo wearable respiration sensor.

Jupyter Notebook Code →

CAISR 2

CAISR2

Next-generation CAISR sleep-analysis models.

Python Code →

Ordinal Sleep Depth

Ordinal-Sleep-Depth

Scores sleep depth from EEG as a continuous signal rather than discrete stages.

Python Code →

Outcome-Oriented Staging

outcome-oriented-sleep-staging

Sleep staging optimized for clinical outcomes rather than epoch-level concordance with human scorers.

Python Code →

PANDA

PANDA-Sleep

Pediatric Arousal Neural Detection Architecture — deep-learning arousal detection across childhood and adolescence.

Python Code →

Pediatric SleepNet

BCH-SleepStaging

Multimodal (EEG+EOG+EMG) deep-learning sleep staging across childhood, from infants to adolescents.

Python Code →

PhysioNet 2018 (winner)

Physionet2018_Challenge_Submission

Winning entry for the PhysioNet 2018 'You Snooze You Win' arousal-detection challenge.

Python Code →

Sleep Staging (2000 patients)

sleep_staging_2000pts

Deep-learning sleep staging trained and validated on 2,000 patients.

Python Code →

SleepBreathing-DL

SleepBreathing-DL

Multi-task model classifying sleep stages, apneas and arousals from a single respiratory signal.

Python Code →

Staging + Scorability

sleep_staging_tl_scorability

Transfer learning coupled with scorability models to refine sleep-staging accuracy.

Python Code →

Staging from ECG & Respiration

ecg_respiration_sleep_staging

Sleep staging from ECG and respiration alone, without EEG.

Python Code →

Sleep, brain age & cognition

17

Brain age, brain-health scores, spindles, and cognitive and clinical outcomes from sleep.

★ Featured

Philosopher's Stone

philosophers-stone

Maps one channel of overnight sleep EEG to a 1024-D brain-health latent space and a Brain Health Score for cognition, disease risk and mortality.

Python Code →
★ Featured

Sleep-EEG Brain Age (BAI)

SleepEEGBasedBrainAge

The sleep-EEG Brain Age Index, now shipped in the Luna package.

Python Code →

Brain Age & Dementia

bai-dementia

Reproducibility package: sleep-EEG brain age across diagnostic groups in ~9,800 polysomnograms.

Python Code →

Brain Age (KoGES)

brain_age_koges

Sleep-EEG brain age in the Korean Genome and Epidemiology Study cohort.

Jupyter Notebook Code →

Dementia from Sleep

dementia-detection-from-sleep

Detecting dementia from overnight sleep EEG.

Jupyter Notebook Code →

Meditation & Brain Age

meditation-sleep-brain-age

Sleep-EEG brain age applied to a meditation cohort.

Python Code →

Note-NLP Sleep Phenotyping

prophet-sleep

Note-NLP sleep phenotyping over the de-identified BDSP OMOP database, targeting the ARPA-H/SHDC variable spec.

Python Code →

Optimal Spindle Detection

optimal-spindle-detection-cognition

Optimal spindle-detection parameters for predicting cognition.

Python Data Code →

Philosopher's Stone 2

philosophers-stone-2

Second-generation, multimodal brain-health model built on overnight sleep physiology.

Python Code →

PSG Outcome Prediction

psg-outcome-prediction

Predicting health outcomes from polysomnography-derived features.

Python Code →

Sleep & Cognition

sleep_cognition

Predicting cognitive function from sleep EEG with deep learning.

Jupyter Notebook Code →

Sleep EEG & MRI

sleep_eeg_mri

Linking overnight sleep EEG to structural brain MRI.

Jupyter Notebook Code →

Sleep EEG, MRI & Cognition

mri-cognition-eeg-wei2024

Sleep EEG, brain MRI and cognition (Wei et al., 2024, SLEEP).

Jupyter Notebook Code →

Sleep Outcome Prediction

sleep-outcome-prediction

Reproduce PSG-based health-risk predictions, and score a new sleep recording.

Python Code →

Sleep Phenomics Automation

sleep-phenomics-automation

Automated sleep-phenomics feature pipeline.

Python Code →

SPiN

spin

Spindle–Oscillation Physiomarkers of Neurohealth — umbrella for SPiN datasets and analyses.

Python Code →

Spindle Optimization

spindle_optimization

Exploring spindle-detection parameters with interactive parallel-coordinate plots.

Python Code →

Breathing & cardiac in sleep

4

Respiration, apnea, loop gain and heart-rate-variability analysis.

★ Featured

Breathing Stability Index

breathing-stability-index

The Breathing Stability Index, with a Python API and an EDF/HDF5 command-line tool (SLEEP 2026).

Python Code →

Auto PSG Respiration

Auto_PSG_Respiration

Automating respiration analysis for polysomnography.

Jupyter Notebook Code →

Breathing Self-Similarity

self_similarity

Self-similarity of breathing for high-loop-gain and central-apnea analysis.

Python Code →

HRV Tools

hrv-tools

ECG, RR-interval and heart-rate-variability toolkit.

Python Code →

Viewers, atlases & teaching

9

Interactive EEG and PSG viewers, spectrogram atlases, and clinician-training tools.

★ Featured

EEG Spectrogram Atlas

eeg-spectrogram-atlas

A Primer on EEG Spectrograms — an interactive teaching atlas.

MATLAB Data Code →
★ Featured

Sleep YODA

sleep-yoda

PSG viewer and sleep-analysis platform with staging, respiratory and report views.

HTML Code →

Coma EEG Viewer (Lund)

coma-eeg-lund-viewer

Viewer for coma EEG recordings (Lund collaboration).

JavaScript Code →

CORTEX

cortex

An adaptive Bayesian test of how well a clinician reads an EEG — it asks the most informative question next and stops once skill is certain.

Python Code →

GULAG Lifespan EEG Atlas

gulag-eeg-atlas

A comprehensive lifespan EEG atlas with interactive clips and four-panel qEEG spectrograms.

Python Code →

Morgoth Viewer

morgoth-viewer

EEG review application for continuous recordings processed by the Morgoth deep-learning pipeline.

Python Code →

Morgoth Viewer (Stanford)

morgoth-stanford

Stanford deployment of the Morgoth EEG viewer.

Python Code →

Myelin

Myelin

AI-enabled cohort-generation and discovery tool.

Python Code →

Timeline Viewer

timeline-viewer

Timeline viewer for long-term EEG and events.

JavaScript Code →

Models, features & signal tools

8

Feature pipelines, embeddings, foundation models and signal I/O utilities.

★ Featured

BDSP Sleep Features

bdsp-sleep-features

Broad, versioned polysomnography feature computation for ARPA-H REST and the SHDC.

Python Code →

edfio

edfio

Convenience functions to write EDF files from Python.

Python Code →

EEG Multitask Embedding

eeg_multitask_embedding

Learns a single shared EEG embedding by training on several EEG-labeling tasks at once.

Python Code →

Multitaper as Kernel Smoothing

spectral-smoothing-vs-multitaper

Multitaper spectral estimation as kernel smoothing of a tapered periodogram — proof, Python code and figures.

TeX Code →

Omega

Omega

A transformer model for clinical EEG, with a decoder for interpreting its embeddings.

Jupyter Notebook Code →

PSG Conversion

bdsp-psg-conversion

Convert PSG session H5s into TS-Zarr, sleep-feature JSON, OMOP rows and Parquet.

Python Code →

Sleep Research I/O

sleep_research_io

Format sleep biosignals into a common H5 format; used for ICU-Sleep and SleepLab data.

Jupyter Notebook Code →

TEEGLLTEEG

TEEGLLTEEG

Train and run TEEGLLTEEG, a text↔EEG language-modeling approach.

Python Code →