Epileptic Seizure Prediction Using Patient-Adaptive Transformer Networks
Authors: Mohamed Mahdi, Asma Baghdadi
Organizations: Information and Communication Engineering Department National Engineering School of Tunis Tunis El Manar University · REGIM-Lab, University of Sfax, National Engineering School of Sfax (ENIS), BP 1173, Sfax, 3038, Tunisia
Epileptic seizure prediction from electroencephalographic (EEG) recordings remains challenging due to strong inter-patient variability and the complex temporal structure of neural signals. This paper presents a patient-adaptive transformer framework for short-horizon seizure forecasting. The proposed approach employs a two-stage training strategy: self-supervised pretraining is first used to learn general EEG temporal representations through autoregressive sequence modeling, followed by patient-specific fine-tuning for binary prediction of seizure onset within a 30-second horizon. To enable transformer-based sequence learning, multichannel EEG signals are processed using noise-aware preprocessing and discretized into tokenized temporal sequences. Experiments conducted on subjects from the TUH EEG dataset demonstrate that the proposed method achieves validation accuracies above 90% and F1 scores exceeding 0.80 across evaluated patients, supporting the effectiveness of combining self-supervised representation learning with patient-specific adaptation for individualized seizure prediction.
Figures & tables
Fig. 1 : Overall architecture of the proposed patient-specific seizure prediction framework. The pipeline consists of four main stages: (1) Noise-aware preprocessing using adaptive FFT-based filtering, (2) EEG tokenization with z-score normalization and quantization into 512 discrete levels, (3) Self-supervised GPT pre-training using next-token prediction with dual loss, and (4) Patient-specific supervised fine-tuning for 30-second horizon seizure prediction.
Hyperparameter
Value
Quantization Levels (L)
512
Block Size
512 samples
Normalization
Z-score
Clipping Factor (k)
5
Token per Sample
1
Embedding Dimension
128
TABLE I : Hyperparameters for Tokenization and Sequence Modeling
Hyperparameter
Value
Segment Duration
30 s
Prediction Horizon
30 s
Sampling Rate
250 Hz
Sequence Length
7,500 samples
Batch Size
16
Gradient Accumulation
4 steps
TABLE II : Fine-Tuning Hyperparameters
Patient aaaaaaac
Sessions
Recording Hours
Seizures
Segments
Pre-ictal %
Sampling Freq (Hz)
Channels
s001_2002
2
0.15
2
29
89.66
250
33
s002_2002
1
0.07
1
14
92.86
250
33
s004_2002
2
0.26
0
56
0.0
250
33
s005_2002
4
0.35
0
71
0.0
250
33
TABLE III : Dataset summary for patient aaaaaaac
patient aaaaabnn
Sessions
Recording Hours
Seizures
Segments
Pre-ictal %
Sampling Freq (Hz)
Channels
s001_2004
1
0.33
0
75
0.0
250
33
s002_2004
6
0.35
4
68
54.41
250
128
s003_2004
2
0.25
0
53
0.0
250
32
s004_2004
4
0.35
0
70
0.0
250
32
TABLE IV : Dataset summary for patient aaaaabnn
Patient aaaaadpj
Sessions
Recording Hours
Seizures
Segments
Pre-ictal %
Sampling Freq (Hz)
Channels
s003_2006
1
0.37
0
84
0.0
250
41
s005_2006
6
0.42
7
81
27.16
250
32
TABLE V : Dataset summary for patient aaaaadpj
Fig. 2 : Training convergence — Training and validation loss/accuracy curves for three patient-specific fine-tuning runs. Both pretraining and fine-tuning were run for 5,000 steps; gradient accumulation and mixed precision were used to maximize effective batch size.
Patient
Train Acc
Val Acc
Precision
Recall
F1
FAR (h -1 )
Pdelay (s)
Sens. (%)
aaaaaaac
1.0000
0.9706
1.0000
0.8333
0.9091
0.00
6.89
100.0
aaaaabnn
1.0000
0.9444
0.8750
0.7778
0.8235
0.00
12.55
100.0
aaaaadpj
1.0000
0.9394
0.7500
1.0000
0.8571
13.82
30.00
100.0
TABLE VI : Patient-specific seizure prediction performance
Fig. 3 : Representative alarm timeline and confidence curve – Top: binary alarms (red) vs non-alarm (green) over time with ground-truth seizure windows highlighted in orange. Bottom: model seizure probability (confidence) over the same recording. Vertical axis shows probability in [0,1]; dashed line indicates decision threshold.
Department of Electrical and Computer Engineering, Lebanese American University, Byblos, Lebanon · Institute of Applied Artificial Intelligence, TÉLUQ University, Montreal, Canada
Department of Electronic and Telecommunication Engineering, University of Moratuwa, Sri Lanka · Department of Electrical and Computer Engineering, University of British Columbia, Canada · Department of Biomedical Engineering, University of Melbourne, Australia +1