EEG Analysis Studio
Educational project · Not a medical diagnostic tool · Runs 100% offlineOffline Bonn EEG seizure detection: 178-sample segmentation (173.61 Hz), 10 time-domain stats, 11 Welch PSD features, and a 300-tree Random Forest.
Interactive EEG Signal & Seizure Detection Workspace
178-sample segs · 21 features · 300 treesLoading Bonn recordings…
173.61 Hz (Bonn standard) with no automatic resampling. Using a different sampling rate shifts all Welch PSD frequency bands (Delta–Gamma) and invalidates spectral predictions.
Requires at least 178 samples (one ~1.025 s segment at 173.61 Hz).
Spectral Analysis & 300-Tree Consensus (Selected Segment)
Welch Power Spectral Density (periodic Hann window, nperseg = 128, noverlap = 64, constant detrend, fs = 173.61 Hz) integrated via the trapezoidal rule across five canonical EEG bands.
EEG Band Power Breakdown
300-Tree Random Forest Output
21 Extracted Features (Selected Segment)
Exact 21-feature vector fed to the Random Forest in fixed order [0..20]: 10 time-domain statistics followed by 11 Welch spectral features, shown alongside trained Gini feature importances.
Group-Aware Cross-Validation & Honest Limits
Evaluated with 5-fold StratifiedGroupKFold (seed 42) across all 11,500 one-second segments from 500 Bonn recordings (20% seizure positive). All 23 segments from each recording stay on the same side of every fold.
Why Group-Aware Splitting Matters
With 20% positive segments, a trivial "always no seizure" classifier reaches 0.8000 accuracy with 0.0000 recall. Conversely, a plain random split places segments from the same recording in both train and test, inflating scores:
- Recording-level grouping only: Bonn files carry no patient/subject IDs, so splits are grouped by recording rather than person.
- In-sample demo artifact: the deployed 300-tree Random Forest was trained on all 11,500 Bonn segments; scores on the built-in recordings are in-sample.
- Single cross-validation seed: evaluation metrics come from one 5-fold split (seed 42); per-fold variation is shown above (F1 ranges from 0.8685 to 0.9835).
- Benchmark scope: Bonn University segments are short and artifact-free compared to clinical continuous EEG, and this educational model is not intended for clinical diagnosis.
Processing Pipeline & Scientific Grounding
- Signal Parsing & Segmentation: Numeric samples (173.61 Hz) are divided into non-overlapping 178-sample (~1.025 s) segments; trailing samples shorter than 178 points are dropped.
- Time-Domain Statistics (10 features):
mean, populationstd,min,max,ptp,rms, biasedskewand excesskurtosis,line_length, and mean-centeredzero_crossings. - Welch Band Power (11 features): Periodic Hann window (
nperseg = 128,noverlap = 64, constant detrend), trapezoidal PSD integration across Delta (0.5–4 Hz), Theta (4–8 Hz), Alpha (8–13 Hz), Beta (13–30 Hz), and Gamma (30–60 Hz) as both absolute and relative power, plusdominant_freq. - Float32-Matched Random Forest Inference: Features are cast via
Math.fround(matching scikit-learn's float32 tree split inputs) and evaluated across all 300 trees with full float64 thresholds.
Bonn EEG Five-Class Dataset Structure
| Set | Label ID | Description | Segments | Binary Target |
|---|---|---|---|---|
| S | 1 | Intracranial EEG during epileptic seizure (ictal) | 2,300 | 1 · Seizure |
| F | 2 | Intracranial EEG from epileptogenic zone (interictal) | 2,300 | 0 · Non-seizure |
| N | 3 | Intracranial EEG from opposite hippocampal formation (interictal) | 2,300 | 0 · Non-seizure |
| O | 4 | Surface EEG from healthy volunteers, eyes closed | 2,300 | 0 · Non-seizure |
| Z | 5 | Surface EEG from healthy volunteers, eyes open | 2,300 | 0 · Non-seizure |
← Biomedical AI Labbiomed-ml case study ↗ECG Analysis Studio →Heart Risk Studio →