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.
Epilepsy is one of the most common neurological disorders globally, characterized by recurring seizures and significantly impacting the quality of life. Despite advancements in diagnostic techniques, the mitigation of risks faced by epilepsy patients remains challenging due to the unpredictability of seizure events. An accurate forecast of seizure onset helps to reduce risks in epilepsy patients. In this paper, we propose EEG-FuseFormer, a transformer-based feature fusion framework for seizure-onset prediction that combines intermediate features extracted from Convolutional Neural Networks-Long Short-Term Memory (CNN-LSTM) and ResNet-18 networks. The CNN-LSTM architecture captures both spatial and temporal features directly from the raw signal, whereas the ResNet-18 extracts features from the Short-Time Fourier Transform (STFT) representation of the EEG signals. Fusion is carried out using a transformer encoder, and the final prediction is generated using fully connected dense layers. The CHB-MIT dataset was used to validate the proposed model. The results show that the proposed model achieves a mean recall of 98.85% and outperforms most of the state-of-the-art methods. This study evaluates the ability of the proposed feature fusion model to generalize in cross-patient testing scenarios. Fine-tuning pre-trained models on limited target patient data (target adaptation) within the cross-patient validation framework results in higher recall, precision, and F1-score metrics in comparison to the conventional cross-patient validation approach. Finally, the runtime-based computational complexity of the model is assessed across diverse hardware platforms to highlight the performance-complexity trade-off.
Vigneshwar Hariharan, Chithra Reghuvaran, Arlene John +4
National University of Singapore · University College Dublin · University of Twente +1
Deep learning for EEG-based seizure detection faces critical challenges: severe annotation scarcity and extreme class imbalance, where ictal events comprise less than 10% of clinical recordings. We present DiffEEG, a 9.6M-parameter self-supervised foundation model that addresses both limitations through denoising diffusion pre-training and reinforcement learning (RL)-based fine-tuning. Pre-trained on 1.3M unlabeled segments from the Temple University Hospital Seizure Corpus (TUHSZ), DiffEEG learns generic neural representations via a 1D U-Net with multi-head self-attention. For downstream adaptation, a reinforced decision layer employs policy gradient optimization to directly maximize F1-score, prioritizing sensitivity to rare seizure events over overall accuracy. Under strict patient-wise evaluation (279 patients, Leave-One-Fold-Out), DiffEEG achieves 61% accuracy and 59% F1 for 4-class seizure subtyping, and 81% accuracy with 85% weighted F1 for binary detection, maintaining clinically viable seizure recall (59%) despite extreme imbalance (6.7% prevalence). Segment-level evaluation establishes an upper bound of 97.6% accuracy, confirming strong architectural capacity. DiffEEG demonstrates that diffusion-based pre-training combined with metric-aware reinforcement learning enables clinically deployable seizure monitoring with minimal labeled data requirements.
Abdulkader Helwan, Lina Abou-Abbas, Hussein El Amouri +2
Department of Electrical and Computer Engineering, Lebanese American University, Byblos, Lebanon · Institute of Applied Artificial Intelligence, TÉLUQ University, Montreal, Canada
Neonatal seizures carry substantial risks of acute brain injury and long-term neurodevelopmental impairment, motivating the need for timely identification of impending seizure activity. While continuous electroencephalogram (EEG) monitoring remains the clinical gold standard, reliable patient-independent seizure prediction in neonates remains largely under-explored. We propose an interpretable multimodal framework that combines EEG and electrocardiogram (ECG) signals for neonatal seizure prediction. Our method uses mel-frequency cepstral coefficient (MFCC) representations processed by a lightweight (approx. 70k-parameter) convolutional neural network with squeeze-and-excitation attention. The framework was evaluated on the Helsinki neonatal EEG-ECG dataset and the Siena scalp EEG-ECG dataset. Under strict leave-one-patient-out (LOPO) evaluation, patient-independent prediction proved challenging (mean accuracy 58.5%, F1-score 60.3%), highlighting substantial inter-subject variability in neonatal EEG. However, fine-tuning the pretrained model with only five minutes of patient-specific data per class improved performance to 95.87% accuracy and 95.85% F1-score, demonstrating the feasibility of rapid patient-adaptive transfer learning. SHapley Additive exPlanations (SHAP) identified informative EEG channels that showed partial spatial agreement with clinically reported seizure origins. These findings suggest that fully patient-independent neonatal seizure prediction remains challenging, but that patient-adaptive fine-tuning with a small amount of data may provide a practical pathway toward personalized neonatal seizure prediction systems.
Sithmini Ranasingha, Agasthi Haputhanthri, Hansa Marasinghe +5
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