This repository contains a MATLAB implementation of an online epileptic seizure prediction framework based on EEG phase synchronization and an evolving neuro-fuzzy model.
The project is associated with the following peer-reviewed paper:
Alaei, H. S., Khalilzadeh, M. A., & Gorji, A. (2019).
Optimal selection of SOP and SPH using fuzzy inference system for on-line epileptic seizure prediction based on EEG phase synchronization.
Australasian Physical & Engineering Sciences in Medicine, 42, 1049–1068.
https://doi.org/10.1007/s13246-019-00806-w
Epileptic seizures can occur unpredictably, which creates serious risks for people with drug-resistant epilepsy. A reliable seizure prediction system should not only identify an upcoming seizure accurately, but also provide a useful warning time while keeping the number of false alarms low.
This project implements an online seizure prediction model using:
- EEG phase synchronization features
- Mean phase coherence between EEG channel pairs
- Patient-specific feature selection
- Evolving Neuro-Fuzzy Model (ENFM)
- Seizure Prediction Horizon (SPH)
- Seizure Occurrence Period (SOP)
- Moving-average-based post-processing to reduce false alarms
The original study proposed a fuzzy inference system to select suitable SOP and SPH values for each patient. The aim was to provide a clinically meaningful warning interval while keeping the uncertainty period as short as possible.
The Seizure Prediction Horizon (SPH) is the time interval between an alarm and the beginning of the period in which a seizure is expected to occur.
A longer SPH can be useful because it gives the patient more time to take safety precautions.
The Seizure Occurrence Period (SOP) is the time window after the SPH during which the seizure is expected to happen.
A shorter SOP is preferable because it reduces uncertainty and may lower patient stress.
The Evolving Neuro-Fuzzy Model (ENFM) is an adaptive online learning model based on recursive fuzzy clustering. It can update its structure over time by adding or merging fuzzy rules as new samples arrive.
The general workflow is:
EEG recordings
↓
Sliding-window segmentation
↓
Frequency-band decomposition
↓
Phase synchronization calculation
↓
Mean phase coherence features
↓
Feature selection
↓
Online classification using ENFM
↓
Moving-average post-processing
↓
Seizure warning output
Epileptic-Seizure-Prediction/
│
├── README.md # Project documentation
├── main.m # Main script for running the seizure prediction example
├── ENFM.m # Evolving Neuro-Fuzzy Model implementation
├── X.mat # Selected phase synchronization features
├── Y.mat # Binary labels: seizure / non-seizure
├── Z.mat # Phase synchronization features from the non-evaluative segment
└── .gitattributes
The included .mat files provide pre-extracted feature-level data used by the MATLAB script.
| File | Description |
|---|---|
X.mat |
Selected EEG phase synchronization features |
Y.mat |
Binary labels for seizure and non-seizure states |
Z.mat |
Phase synchronization features from the non-evaluative segment |
main.m |
Loads the data, applies ENFM, and performs post-processing |
ENFM.m |
Implements the evolving neuro-fuzzy classifier |
The raw EEG preprocessing and full feature extraction pipeline are not fully included in this repository. The current version focuses mainly on the online prediction model using extracted features.
This project was implemented in MATLAB.
Recommended environment:
- MATLAB R2018a or later
- Basic MATLAB numerical computing functionality
- Clone the repository:
git clone https://github.com/Hesam-lab/Epileptic-Seizure-Prediction.git
cd Epileptic-Seizure-Prediction-
Open MATLAB.
-
Set the repository folder as the current working directory.
-
Run:
mainThe script loads the feature matrices and labels, applies the ENFM classifier, and performs post-processing to generate seizure prediction outputs.
In main.m, the main configurable parameters include:
sop = 10; % Seizure Occurrence Period in minutes
sph = 30; % Seizure Prediction Horizon in minutes
N = 16; % Length of each EEG time window in seconds
M = 3.2; % Length of overlap between windows in seconds
m = 2; % Fuzziness parameter for clustering
lambda = 1; % Forgetting factor in RLS update rule
th1 = 0.2; % Threshold for adding new clusters
th2 = 0.3; % Threshold for merging similar clusters
window = 15; % Moving-average filter length in minutesYou can change sop and sph to test different seizure prediction horizons and occurrence periods.
If you use this code or build upon this work, please cite:
@article{alaei2019optimal,
title={Optimal selection of SOP and SPH using fuzzy inference system for on-line epileptic seizure prediction based on EEG phase synchronization},
author={Shokouh Alaei, Hesam and Khalilzadeh, Mohammad Ali and Gorji, Ali},
journal={Australasian Physical \& Engineering Sciences in Medicine},
volume={42},
pages={1049--1068},
year={2019},
publisher={Springer},
doi={10.1007/s13246-019-00806-w}
}