Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EEG-Based Seizure Detection Using Machine Learning

Seizure vs. non-seizure classification on the CHB-MIT scalp EEG dataset (subject chb01).
Pipeline: 4s windowing → bandpower features (Welch PSD) → Logistic Regression vs. Linear SVM, evaluated with time-ordered splits.

Key Takeaways

  • Linear SVM achieved better overall performance on the held-out future test set (Macro-F1 = 0.9012) with fewer false positives.
  • Because seizure windows are rare, we report Macro-F1 in addition to accuracy to reflect performance on the minority class.

Results (held-out test set)

  • Logistic Regression: Accuracy 0.9833, Macro-F1 0.8442
  • Linear SVM: Accuracy 0.9908, Macro-F1 0.9012

Visual Results

Confusion Matrices (Test Set)
Confusion Matrices

Test Performance Comparison (Accuracy + Macro-F1)
Performance Comparison


Dataset

  • Dataset: CHB-MIT Scalp EEG Database (subject chb01)
  • Source: Kaggle mirror of CHB-MIT pediatric EEG (see References)
  • Data in this repo: NOT included (EDF files are large). Please download separately.
  • Sampling rate: 256 Hz
  • Channels available: 23 EEG derivations per EDF file
  • Channel used (baseline): F7–T7 (Channel 2) to reduce computation (engineering simplification)
  • Files used (7 seizure-containing EDFs):
    chb01_03, chb01_04, chb01_15, chb01_16, chb01_18, chb01_21, chb01_26

Problem Setup

Sample unit: one 4-second EEG window (from the selected channel)
Label unit: one binary label per window

  • 1 = seizure (window overlaps an annotated seizure interval)
  • 0 = non-seizure

Feature Extraction (Bandpower)

For each 4-second window, we compute Welch Power Spectral Density (PSD) and convert the raw waveform into a small feature vector.

  • Features: band powers in standard EEG bands: delta, theta, alpha, beta
  • Feature dimension: 4 features per window
  • Implementation: see the notebook for details

In short: PSD → average/integrate power within each frequency band → features.


Models

  • Logistic Regression (L2)
  • Linear SVM (LinearSVC)

Both models use:

  • StandardScaler for feature standardization
  • TimeSeriesSplit (walk-forward CV) for hyperparameter tuning on the training portion only

Evaluation (No Leakage)

  • Train/Test split: time-ordered 80/20 (future is never used to predict the past)
  • Cross-validation: walk-forward TimeSeriesSplit on training data
  • Metrics: Accuracy, Macro-F1, Confusion Matrix

How to Reproduce

  1. Download the CHB-MIT dataset (EDF + summary file) from Kaggle/PhysioNet.

  2. Create a folder named chb01/ at the repo root, and put the EDF files inside:

    chb01/chb01_03.edf
    chb01/chb01_04.edf
    chb01/chb01_15.edf
    chb01/chb01_16.edf
    chb01/chb01_18.edf
    chb01/chb01_21.edf
    chb01/chb01_26.edf

  3. Install dependencies:

    • pip install -r requirements.txt
  4. Open EEG_SeizureDetection.ipynb

  5. Set DATA_DIR (default is Path("chb01")), then run all cells.


Repository Structure

  • EEG_SeizureDetection.ipynb — main notebook (full pipeline)
  • assets/ — figures (confusion matrices, comparison plot)

Limitations

  • Single subject only — trained and evaluated on chb01; results may not generalize to other patients without retraining.
  • Single channel — uses only F7–T7 (Channel 2). Multi-channel analysis would likely improve performance.
  • Simple features — only bandpower in four standard EEG bands. Does not include gamma band, spectral ratios, nonlinear features (e.g., sample entropy), or time-domain statistics beyond mean/std.
  • Linear models only — no nonlinear classifiers (Random Forest, XGBoost, CNN/LSTM) were explored.
  • No class imbalance handling — seizure windows are ~2% of the data, but no oversampling, undersampling, or class_weight adjustment was applied.
  • No EEG preprocessing — no bandpass filtering or artifact rejection prior to feature extraction.
  • Small positive sample size — only ~115 seizure windows total, which limits statistical reliability.

References

About

EEG seizure detection on CHB-MIT (chb01) with Welch bandpower features and time-ordered evaluation (walk-forward CV).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages