# Electrocardiogram (ECG)-based seizure detection using supervised machine-learning

Eva Diab, William Gacquer, Carole Nouboue, Derambure Philippe, Bertille Périn, Simone Chen, Julien de Jonckheere, William Szurhaj

► To cite this version:

Eva Diab, William Gacquer, Carole Nouboue, Derambure Philippe, Bertille Périn, et al., Electrocardiogram (ECG)-based seizure detection using supervised machine-learning. Neurophysiol Clin, 2025, Neurophysiol Clin, 55 (5), pp.103098. 10.1016/j.neucli.2025.103098. hal-05228452

HAL Id: hal-05228452

https://u-picardie.hal.science/hal-05228452v1

Submitted on 24 Sep 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Original article

# Electrocardiogram (ECG)-based seizure detection using supervised machine-learning

<figure><img src="image_2.png" /></figure>

Eva Diab<sup>a,e,*</sup> <sup>□</sup>, William Gacquer<sup>b,□</sup>, Carole Nouboue<sup>a</sup>, Derambure Philippe<sup>c</sup>, Bertille Périn<sup>a</sup>, Simone Chen<sup>a</sup>, Julien De Jonckheere<sup>d</sup>, William Szurhaj<sup>a,e</sup>

## ARTICLE INFO

**Keywords:**

Epilepsy

Seizures

Automated detection

Machine learning

Electrocardiogram

## ABSTRACT

**Background:** We conducted a pilot study utilizing automatic delineation of electrocardiogram (ECG) and machine learning that considered all components of the ECG complex for seizure detection. The primary outcome was to assess the feasibility of this method. The secondary outcome was to identify the most effective machine learning algorithm.

**Methods:** We screened ECG recordings from patients included in the EPICARD cohort who underwent video-electroencephalogram monitoring. A total of 47 seizures from 32 patients were selected. Epochs of 90 min surrounding the seizures were retained. Each ECG was converted into a sequence of heartbeats modeled as a P-Q-R-S-T succession. Derivative quantities measuring time variations between the inner and outer components of heartbeats were computed, designated as $δ_X$ and $ΔX$. Our algorithm monitored 3 to 60 successive heartbeats within a sliding window. An alarm was triggered when more than N heartbeats were classified as in-seizure (N between 3 and 20). Heartbeats were categorized as in-seizure by trained neurophysiologists. We used automated machine learning (auto-ML) platforms (Dataiku & Flaml) to assess six different algorithms: Random Forest, LightGBM, XGBoost, Decision Tree, K-Nearest Neighbors, and Extra Trees.

**Results:** The Extra Trees algorithm provided the best seizure detection performance regardless of the validation method used. Although longer-window models enhance detection sensitivity, they do so at the cost of delayed identification. A model analyzing 60 heartbeats with a trigger of 20 achieved 86 % sensitivity and 99.9 % specificity.

**Discussion:** Automatic delineation is reliable, however the false alarm rate remains high (1.5 per hour). Future work should focus on personalizing detection algorithms to improve this false alarm rate.

## Introduction

The mortality rate among people with epilepsy (PWE) is estimated to be 1.6 to 3 times higher than that of the general population [1]. The two leading causes of death in this population are accidental deaths related to seizures and Sudden Unexpected Death in Epilepsy (SUDEP). This situation could be partly mitigated by implementing an alarm system for assistance. Therefore, the development of a seizure detection system that can alert the need for assistance is crucial [2]. Such systems are also important for the detection of nocturnal or unrecognized seizures, as

patients document <50 % of their seizures, leading to suboptimal treatment [3]. For these reasons, it is important to develop an ambulatory seizure detection tool applicable to both convulsive and non-convulsive seizures, which can be worn day and night.

Currently, >20 products for seizure detection are on the market [4]. These tools utilize various methods, including accelerometry, electromyography, electrodermography, electrocardiography, and—considered the gold standard—electroencephalography (EEG). However, all these tools share a significant limitation: a high false positive rate, which restricts their practical application in the daily lives of patients.

<footnote><sup>a</sup> Department of Clinical Neurophysiology, Amiens University Hospital, UR 7516 CHIMERE, University of Picardie Jules Verne, France</footnote>

<footnote><sup>b</sup> Data scientist, Applications and Projects Department, Amiens University Medical Center, France</footnote>

<footnote><sup>c</sup> Department of Clinical Neurophysiology, Lille University Hospital, France</footnote>

<footnote><sup>d</sup> Lille University Hospital, France, INSERM CIC-IT 1403, Lille, France</footnote>

<footnote><sup>e</sup> UR 7516 CHIMERE research unit, University of Picardie Jules Verne, France</footnote>

<footnote>* Corresponding author at: Department of Clinical Neurophysiology, Amiens university hospital, France.</footnote>

<footnote>E-mail address: diab.eva@chu-amiens.fr (E. Diab).</footnote>
Electrocardiograms are relatively easy to record and less invasive for daily use. It is well established that seizures are associated with heart rate changes (i. e., tachycardia or even bradycardia), particularly during the ictal or pre-ictal phases, regardless of whether the seizure is convulsive or non-convulsive [5].

Heart rate variability (HRV) is also known to be altered during seizures [6]. HRV reflects the balance between the sympathetic and parasympathetic branches of the autonomic nervous system (ANS), and this biomarker has proven effective in detecting seizures. HRV-based seizure detection could detect 93.1 % of all seizures and 90.5 % of non-convulsive seizures in a selected population, with a low false alarm rate of 1.0 per 24 h [7]. However, this algorithm was applicable only to 53.5 % of the patients, referred to as "responders," meaning those whose first recorded seizure exhibited an ictal heart rate change of >50 beats/min during a 100 R-R interval. A subsequent prospective validation study, also conducted on responder patients, confirmed these findings [8]. In 2023, the same team utilized a logistic regression machine-learning classifier focusing exclusively on responders to classify seizures, achieving a reduced false alarm rate of 0.62 per 24 h at the expense of a decreased sensitivity of 78.2 % [9].

Moreover, a recent meta-analysis of existing HRV-seizure detection algorithms revealed that while autonomic function alterations may serve as a promising tool for seizure detection, they do not achieve acceptable performance levels: although most algorithms demonstrate high sensitivity, their false alarm rates remain excessively high [10]. Furthermore, existing studies often lack sufficient statistical details. Sensitivity is frequently reported, but specificity is not. Additionally, most ECG or HRV seizure detection algorithms are based on relatively simple decision trees or logistic regression. Recent advancements in machine learning techniques show promise for improved results. Findings also indicate that ictal ECG abnormalities are associated not only with classic sinus tachycardia but also with alterations in the ST segment and T waves [11].

By analyzing all ECG parameters in conjunction with machine learning methods, it may be possible to enhance the specificity of ECG-based seizure detection methods. We conducted a pilot supervised machine learning study for seizure detection that examines all components of the P-QRS-T complex, rather than relying solely on heart rate and HRV. Our approach involved the automatic delineation of ECG parameters and the testing of various machine learning methods. The primary outcome was to assess the feasibility of seizure detection through the automatic delineation of ECG parameters using machine learning techniques, while the secondary outcome sought to identify the most effective machine learning method for ECG-based seizure detection.

## Material and methods

The study population was drawn from the EPICARD cohort (RCT NCT03369522). Still ongoing, the EPICARD cohort includes prospectively PWE who as part of their pre-surgical assessment or diagnostic investigation benefit from long term video-EEG monitoring or stereo-electroencephalography (SEEG) in epilepsy monitoring units of Amiens University Hospital and Lille University Hospital in France. The study was approved by the French committee for the protection of persons (CPP): n°2017-A00114-49.

## *Recordings and data collection*

Surface EEG was recorded from electrodes placed on the scalp according to the international "10–20" system. Intracranial EEG was obtained from deep electrodes positioned based on a pre-surgical framework established during a multidisciplinary meeting. Continuous monitoring was performed to assess oxygen saturation, electromyography (EMG) activity, and ECG. ECG was recorded using two thoracic electrodes forming a single channel. A causal band-pass filter (0.5–40 Hz) was applied. All signals were acquired at a sampling frequency of

either 256 Hz or 512 Hz, utilizing SystemPlus Evolution software (Micromed, Italy) at the Lille center and NeuroWorks software (Natus Medical, USA, Middleton) at the Amiens center.

Twenty-four-hour video-EEG recordings were retrospectively analyzed and served as the gold standard. Two trained physicians (WS and ED/CN) annotated the onset and offset of each seizure, identifying either the electrophysiological markers (the beginning or end of epileptic discharges) or the clinical manifestations (the beginning or end of observable symptoms), whichever occurred first for the onset and last for the offset.

Initially, we screened the recordings of patients included in the EPICARD cohort at the time of this study. We excluded recordings from patients with the following conditions:

- Epileptic encephalopathy (in whom the ictal and interictal states are often difficult to distinguish)

- Recordings where the onset and offset of seizures could not be clearly delineated

- Functional dissociative seizures

- Patients with known rhythm disorders, such as atrioventricular blocks, sinoatrial exit blocks, or atrial fibrillation. Patients with known rhythm disorders were excluded because their atypical ECG patterns impair the reliability of morphological feature extraction.

Following this, signal quality was reviewed manually by a trained neurophysiologist using waveform visibility criteria. We evaluated the quality of the ECG during each seizure and excluded recordings with insufficient quality to accurately delineate the P, Q, R, S, and T waves. The duration of recordings typically lasted at least 48 h, whereas seizures generally last only a few minutes. Consequently, the duration of seizure events was significantly shorter than that of interictal periods. To balance the dataset and reduce computational demands, we focused on shorter time intervals surrounding each seizure, retaining approximately 90 peri-ictal minutes for each selected patient. Seizures could occur at the onset, middle, or end of the 90-minute epoch to prevent habituation of the algorithm.

## *Data preprocessing*

Our aim was to detect seizures using a simplified tabular model, where each row represents the characteristics of the current heartbeat without any time reference, along with those of the previous N heartbeats. Once the sampled dataset was created, we delineated the ECG complex, which involves the automatic identification of the P-wave, Q-wave, R-wave, S-wave, and T-wave. The Python Neurokit 2 module was utilized to mark the R-peak [12]. Subsequently, we employed the "peak" and discrete wavelet transform (DWT) functions from the Neurokit 2 framework to delineate each ECG complex [13]. For implementation details, refer to the Neurokit 2 documentation [14].

The "peak" method defines positions in time for each feature of the QRS complex, including the onset of the P-wave, the peaks of the P, Q, S, and T waves, and the offset of the T-wave. The DWT method additionally determines the offset of the P-wave and the onset of the T-wave.

This implementation uses the Daubechies-4 (db4) wavelet and a decomposition level of 3, which are typical choices for ECG analysis due to their effective time-frequency resolution properties. This configuration balances the need for detecting fast transitions (e. g., QRS complex) while still capturing slower wave features (e. g., P and T waves).

We verified that these two methods aligned with each other, which was typically the case (Figs. 1,2). The results of the automated delineations were visualized on an online platform (YATSA, developed by WG, CHU Amiens Picardie [15]). The additional features of P-offset and T-onset were not used in this analysis, as our objective was to compare the efficiency of the peak and DWT algorithms while reducing the dimensionality for machine learning.
<figure><img src="image_3.png" /><figcaption>**Fig. 1.** Delineation of the ECG visualized on YATSA application. A: Example of Peak and DWT delineation. B: Example of ECG delineation with artifacts. C: Example of full delineation on a patient 90 epoch, at the top the delineation of all the R peaks, below the average of the heart rate, in third position the quality of the ECG throughout the epoch, finally at the bottom the delineation of P,Q,R,S,T waves with respective colors.</figcaption></figure>

## Feature engineering

The ECG was modeled as a vector of successive P-QRS-T complexes, each complex “i” was characterized by:

* $P_i, Q_i, R_i, S_i, T_i$:

* The absolute time of P,Q,R,S,T elements found using the delineation algorithm mentioned above. These are needed to compute the below declared variables.

* In order to avoid time related bias induced by the time distribution of the seizure events any information about exact global timing is removed by deleting columns these Pi, Qi, Ri, Si, Ti columns from the final dataset.

* $\delta P_i, \delta Q_i, \delta S_i, \delta T_i$:

* The time interval of each P,Q,R,S,T components relative to R of the same QRS Complex. $\delta P_i = P_i - R_i$

* $\delta P_i$ and $\delta Q_i$ are negative. $\delta S_i$ and $\delta T_i$ are positive.

* These characteristics were directly computed from $P_i, Q_i, S_i, T_i$.

* $\Delta P_i, \Delta Q_i, \Delta R_i, \Delta S_i, \Delta T_i$:

* The time interval of each P,Q,R,S,T components relative to the same components from the previous detected heartbeat. $\Delta P_i = P_i - \Pi(n - 1)$

* These characteristics were directly computed from $P_i, Q_i, R_i, S_i, T_i$.

We applied a heartbeat-based sliding window approach to construct our dataset. Specifically, for each heartbeat (starting from the Nth one), we grouped it with the previous $N - 1$ heartbeats to form a single row. This creates a window of N consecutive heartbeats, allowing the model to consider short-term cardiac dynamics rather than relying on time-based segments.

Each of these rows includes a set of features derived from ECG waveform delineation and their derivatives—specifically, 9 features (4 delineation points + 5 derivatives) per heartbeat. As a result, each row contains $(4 + 5) \times N = 9 \times N$ features. For example, a window of 60 heartbeats results in 540 features.

In our study, window sizes ranged from 3 to 60 heartbeats. Each row represents a continuous segment of time during which a seizure may or may not occur. A seizure can start, end, or span entirely within a single row.
<figure><img src="image_4.png" /><figcaption>**Fig. 2.** Example of parameters derived from the ECG delineation δPᵢ, δQᵢ, δRᵢ, δSᵢ, δTᵢ represent the time interval of each P,Q,R,S,T components relative to R of the same QRS Complex.</figcaption></figure>

To associate each row with seizure activity, we defined a “seizure score” based on the number of heartbeats marked as ictal (in seizure) by expert neurophysiologists. This score is simply the count of seizure-positive heartbeats within the row.

During model evaluation, we tested several threshold values for this score—ranging from 1 to a maximum of 20—to determine at what point the model should trigger a seizure detection. A real-world system could raise an alert when the model output exceeds this threshold. Lower thresholds offer more real-time responsiveness but may increase the false alarm rate.

## Data analysis

Data were imported into automated machine learning (AutoML) frameworks (Dataiku, https://www.dataiku.com/ and FLAML, https://microsoft.github.io/FLAML/) . These frameworks, which offer similar machine learning algorithms, were used concurrently to evaluate the consistency of the results. Six different algorithms were tested: Random Forest, LightGBM, XGBoost, Decision Tree, K-Nearest Neighbors, and Extra Trees [16,17]. We chose these six algorithms because they are currently the most effective for tabular data.

Additionally, we tested two different validation methods. On the FLAML platform, we split our data into a training set (70 % of the data) and a validation set (30 % of the data). Since our dataset is significantly

<figure><img src="image_5.png" /><figcaption>**Fig. 3.** K FOLD cross validation.</figcaption></figure>
unbalanced—containing few heartbeats during seizures compared to those outside of seizures—we used stratification to rebalance the training and test split, ensuring proportional representation of seizure and non-seizure events in training/test sets. The dataset was shuffled before splitting it into training and validation sets. Patient-level separation was strictly enforced between training and testing to prevent data leakage or causality distortion.

On the Dataiku platform, we employed K-fold cross-validation (see Fig. 3). K-Fold involves dividing the data into K folds, where each fold is used as a testing set at some point. For example, if K is equal to 5, during the first iteration, the first fold is used to test the model while the rest are used for training. In the second iteration, the second fold is used as the testing set while the others serve as the training set. This process continues until each of the 5 folds has been used as the testing set. The K-fold technique, unlike a standard 70 %/30 % split for training and validation, allows each parameter to be part of both the training and validation phases. This creates K different random training sets that are more balanced and helps minimize the overfitting problem.

Characterization of the quality of our results was displayed according to the standards in machine learning methods:

* **Precision also known as positive predictive value (PPV)** is: proportion of correct ("positive") predictions among "positive" predictions.

* **Sensitivity also known as recall or true positive rate is:** proportion of correct "positive" predictions among "positive" records.

* **F1 score** is calculated as:

$$ \text{F1 score} = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}} $$

F1 score can range from 0 to 1, with 1 representing the model that classifies perfectly each observation into the correct class. Here we aim to develop a model with the best F1 score where each heartbeat is classified in or out of a seizure.

* **Specificity** also known as true negative rate is the proportion of correct "negative" prediction among "negative" records.

* **Area Under Curve (AUC)** shows the true positive rate versus the false positive rate resulting from different threshold values in the predictive model. The closer to 1 it is, the better it is.

It is admitted in the literature that F1-score as a product of Precision and Sensitivity is a better indicator of the model quality. It is particularly useful for imbalanced datasets, where one class is much more frequent than the other. An F1 score of 1.0 indicates perfect classification, meaning the model made no false positives or false negatives. This is rarely achievable in real-world datasets.

An F1 score between 0.9 and 1.0 is considered excellent. It reflects a model that is highly reliable, with minimal errors in both positive prediction and detection of actual positive cases.

An F1 score between 0.8 and 0.9 is regarded as very good. The model performs well and is suitable for most practical applications.

An F1 score between 0.7 and 0.8 is considered good. While there may be some trade-off between precision and recall, the model still demonstrates acceptable predictive performance [18].

## Results

Within the EPICARD cohort, 32 patients were selected on the quality of their ECG, and on the exclusion criteria, representing 47 seizures (Table 1). 21 patients contributed one seizure, 10 patients had two seizures each, and one patient had five seizures included in the dataset. The duration of seizures lasted from 23 s to 2 min 41 s. Our algorithm

<table><caption>**Table 1**
Dataset Population characteristics.</caption><thead><tr><th></th><th>N = 32</th></tr></thead><tbody><tr><td>Patients</td><td></td></tr><tr><td>Age in years, mean (range)</td><td>• 37<br>• (19-77)</td></tr><tr><td>Sex, No. (%)</td><td>• 14 (48.5 %)<br>• 18 (51.5 %)</td></tr><tr><td>• Female<br>• Male</td><td></td></tr><tr><td>Epilepsy Characteristics N = 32</td><td></td></tr><tr><td>Epilepsy type, No. (%)</td><td>• 1 (6.1 %)<br>• 31 (93.9 %)</td></tr><tr><td>• Focal</td><td>- 22 (67.7 %)<br>- 10 (32.3 %)</td></tr><tr><td>- Temporal<br>- Extra-temporal</td><td></td></tr><tr><td>Duration of epilepsy in years, mean (range)</td><td>• 24 (1-58)</td></tr><tr><td>Number of anti-seizure medications per patient, mean (range)</td><td>• 2.1 (1-5)</td></tr><tr><td>Seizure type, No. (%)</td><td>N = 47</td></tr><tr><td>• Convulsive<br>• Non convulsive</td><td>• 12 (21.8 %)<br>• 35 (78.2 %)</td></tr></tbody></table>

monitored 3 to 60 successive heartbeats in a sliding window, with a possible trigger from 3 to 20 heartbeats in-seizure, corresponding to 122 evaluated combinations. The best model was based on 60-beat windows and a detection threshold of 20 beats for identifying seizures. The results from K-Fold validation with 5, 10, and 50 splits, along with standard analysis methods, showed comparable performance, except in terms of sensitivity (Table 2). The sensitivity was 86 % with the standard analysis, while specificity reached an optimal 99.9 %. In contrast, K-Fold with 50 splits yielded the best sensitivity at 99 %, albeit with a slight decrease in specificity to 98 %. The area under the curve was excellent for all models studied, exceeding 0.9.

The Extra Trees algorithm (from Dataiku) demonstrated the best performance across all tested models: K-Fold 5, K-Fold 10, K-Fold 50, and standard validation. By extrapolating the false alarm rates (FAR) based on the best specificity (100 %) with a 60-beat window at a mean heart rate of approximately 60 beats per minute, we calculated fewer than 1.5 false alarms per hour. This same false alarm rate was consistent across all models.

In the various analyses conducted, including K-Fold with 5, 15, and 50 splits, as well as standard validation, no specific ECG parameters stood out more than others. The different parameters appeared to contribute equally to the algorithms. No significant performance differences were found between seizure type (convulsive versus non convulsive). Only 12 of 47 seizures were convulsive. Bayes Factor (BF₁₀ = 0.73) indicates insufficient evidence for a distinct effect in this subgroup [19].

## Discussion

We evaluated six distinct algorithms for seizure detection that leverage automatic delineation of ECG data: Random Forest, LightGBM, XGBoost, Decision Tree, K Nearest Neighbors, and Extra Trees. Among these, Extra Trees consistently demonstrated the best performance across all models. Notably, all ECG parameters contributed equally to the results, underscoring the importance of considering the entire electrocardiogram rather than focusing solely on segments like ST, RR,

<table><caption>**Table 2**
Results comparison between four methods with extra trees algorithm (K-Fold 5, K-Fold 15, K-Fold 50, 70/30 %).</caption><thead><tr><th></th><th>K-Fold 5</th><th>K-Fold 10</th><th>K-Fold 50</th><th>Standard 70/30</th></tr></thead><tbody><tr><td>Sensitivity</td><td>97 %</td><td>98 %</td><td>99 %</td><td>86 %</td></tr><tr><td>Specificity</td><td>97 %</td><td>97 %</td><td>98 %</td><td>100 %</td></tr><tr><td>Precision</td><td>97 %</td><td>96 %</td><td>95 %</td><td>98 %</td></tr><tr><td>F1-score</td><td>0.97</td><td>0.97</td><td>0.97</td><td>0.92</td></tr><tr><td>AUC</td><td>0.995</td><td>0.995</td><td>0.996</td><td>0.93</td></tr></tbody></table>
or QT.

In terms of validation method performance, K-fold cross-validation with 5, 10, and 50 splits yielded similar outcomes, with sensitivity and specificity exceeding 95 %. Notably, increasing the K-fold to 50 enhanced sensitivity to 99 %. In contrast, the standard validation method achieved a sensitivity of 86 % while maintaining a specificity of 100 %. Both models exhibited strong performance.

A significant finding of this study is the feasibility and utility of automatic ECG delineation for seizure detection. For the most extensive model, which operated on a 60-beat window, we generated as many as 600 parameters from the characteristics mentioned above. In comparison, the simplest model, which used only a 3-beat window, contained just 30 parameters. In our study, all ECG-derived features contributed relatively equally to the model's performance, with no single parameter clearly standing out. This observation suggests that many of the features may be correlated, potentially introducing redundancy into the dataset. Therefore, reducing the number of features through dimensionality reduction techniques or targeted feature selection may enhance model robustness and generalizability. In future work, it would be valuable to assess inter-feature correlation, rank features by importance or mutual information, and explore biologically informed reductions, such as focusing on components known to reflect ictal autonomic changes (e. g., T-wave or ST segment parameters). Such efforts could help refine the model and support its translation into a real-time, patient-adapted detection system. However, this high number of features poses a significant challenge. One of the main limitations of our study is the risk of overfitting, primarily due to the high dimensionality of the dataset relative to the small sample size. With only 47 annotated seizures from 32 patients, the model may inadvertently learn patterns specific to the training data rather than generalizable features. Although we employed stratified validation and K-Fold cross-validation to mitigate this risk, the potential for overfitting remains, particularly in more complex models. This concern is further supported by the strong performance in training and internal validation, which may not translate equally well to unseen data or external cohorts. Future work should aim to address this limitation by increasing the sample size, reducing the feature set through selection median values, and evaluating model performance on independent external datasets.

We intentionally focused on creating models based on relative feature time positions (δPi, δQi, δSi, δTi, ΔPi, ΔQi, ΔRi, ΔSi, ΔTi) without aggregating, averaging, or calculating the variance of these features. This will be the focus of a future study. To our knowledge, only one study [20] has employed ECG delineation using a technique based on QRS morphological modification over a broader 80-beat window. The specificity values in that study remain unknown, but a high false positive rate for convulsive seizures was noted, making extrapolation of the false alarm rate challenging. However, we infer, as the authors suggested, that it is likely high. A limitation of that study is its exclusive focus on QRS modifications, whereas T-wave changes at the end of the complex are recognized as significant biomarkers of cardiac instability during seizures. Modifications in T-waves have been reported in generalized seizures, such as increased T-wave alternans [21], and in focal seizures characterized by dispersion of the QT segment in temporal lobe epilepsy [22]. It is now well-established that T-wave alterations indicate repolarization instability associated with seizures and may serve as potential biomarkers for the epileptic heart [23]. Furthermore, in the aforementioned study, a 30-second seizure episode was required within the 80-beat window to facilitate detection.

By considering the entire electrocardiogram, we are moving closer to developing a real-time seizure detection tool that accounts for modifications across the P, Q, R, S, and T waves. This comprehensive analysis results in numerous parameters, thereby ensuring that we adequately consider both depolarization and repolarization changes. However, a significant limitation remains the high false alarm rate (FAR). Utilizing the optimal specificity of 99.9 %, and assuming a median heart rate of 60 beats per minute over a study window of sixty heartbeats, we can

estimate a FAR of 1.5 per hour—still excessively high and likely intrusive for patients in their daily lives.

We also observed the equal importance of all P-Q-R-S-T segments and their derivatives, as these variables contributed uniformly to our model. This finding is coherent with physiopathological concepts, suggesting similar importance for sinoatrial and atrioventricular conduction parameters.

Among the patients studied, 21 patients contributed one seizure, 10 patients had two seizures each, and one patient had five seizures included in the dataset. The duration of seizures lasted from 23 s to 2 min 41 s. These seizure-specific characteristics are particularly relevant, as the detection performance of the ECG-based algorithm may be influenced by seizure duration and type. Longer seizures or those involving prominent autonomic changes are more likely to produce detectable ECG alterations, whereas brief or subtle non-convulsive events may be more challenging to identify. Future analyses will aim to stratify performance according to seizure semiology and duration to better understand the algorithm's behavior across different clinical contexts.

This study is unique in that it represents the first comprehensive evaluation of the entire ECG complex rather than focusing solely on heart rate and heart rate variability (HRV) parameters. While our method does incorporate the RR interval, which is a component of HRV, further studies will focus on reducing the false alarm rate by adjusting the heartbeat threshold, expanding the time-scale window, or personalizing our algorithm. Several studies have shown that patient-tailored thresholds yield the best results in terms of sensitivity and specificity [24,8]. Additionally, unlike previous studies, our approach involved a training set followed by a validation set, enhancing its validity.

To ensure that our results reflect the capabilities of the machine learning model itself rather than artifacts of the dataset or validation strategy, we implemented two complementary validation protocols—standard train/test split and K-fold cross-validation with various fold sizes (5, 10, and 50) with consistent performance observed across all approaches. Importantly, patient-level data separation was enforced to prevent leakage. We also removed any global time information from our features, and the uniform contribution of all delineation-derived features suggests that model performance stems from comprehensive ECG morphology analysis rather than specific, potentially confounding, signal segments. Nonetheless, we recognize the importance of comparing this method directly with other seizure detection strategies, particularly HRV-based models, and plan to include such comparisons in future work.

ECG artifacts also present a limitation, but this challenge could potentially be mitigated through the use of implantable ECG devices. Even if implantable ECG devices may reduce signal artifacts and offer high-quality data, their invasive nature limits their feasibility for widespread use. In this regard, wearable technologies—particularly smartwatches and chest strap monitors—represent a far more scalable and real-world solution. Chest straps generally provide better ECG signal quality than wrist-worn devices due to their proximity to the heart and more stable skin contact, while for smartwatches, maintaining adequate strap tightness and contact is essential to reduce motion artifacts; in both cases, the use of conductive gel or hydrogel electrodes can further enhance signal quality by lowering skin-electrode impedance. Another promising direction to enhance performance would be to systematically compare heart rate variability (HRV)-based features with our current AutoML approach using ECG delineation. While HRV methods are known for their strong sensitivity, delineation-based models offer higher specificity. A combined or comparative analysis could reveal complementary strengths and guide the development of an optimal seizure detection strategy.

From a pathophysiological perspective, it appears relevant to integrate the detection of heart rate variability with alterations in the autonomic nervous system and changes in cardiac repolarization through delineation tools. The future direction of this field may well
reside in the multimodal integration of signals, including EEG, ECG with HRV, and EMG.

## Conclusion

This pilot study highlights the significant potential of utilizing all components of the P-QRS-T complex—not just heart rate variability (HRV)—for effective seizure detection. By employing a supervised machine learning algorithm, particularly the Extra Trees algorithm, we achieved an impressive sensitivity of 99 % and a specificity of 98 % within our study population, using a moving window of 60 heartbeats and incorporating 20 in-seizure heartbeats (with alarms activated approximately 20 s after the onset of a seizure). However, the high false alarm rate currently limits the practical application of this method in real-world settings. Optimizing the calculated features and integrating HRV methods with patient-tailored thresholds may be crucial steps toward developing a reliable ECG-based tool for the real-time detection of both convulsive and non-convulsive seizures. This study opens the door for further validation research to confirm these findings and paves the way for advancing seizure detection technologies in everyday clinical practice.

## Data availability statement

The data that support the findings of this study are available on reasonable request from the corresponding author. The data are not publicly available due to ethical restrictions.

## Ethical publication statement

We confirm that we have read the Journal's position on issues involved in ethical publication and affirm that this report is consistent with those guidelines.

## Declaration of competing interest

None of the authors has any conflict of interest to disclose.

## Acknowledgements

We thank the Hauts-de-France regional council for their support to the EPICARD project.

## References

[1] Chen T, Guestrin C. XGBoost: a scalable tree boosting system. In: Proc 22nd ACM SIGKDD Int Conf Knowl Discov Data Min; 2016. p. 785–94.

[2] Chinardet P, Gilles F, Cochet H, Chelly J, Quenot J-P, Jacq G, et al. Electrocardiographic changes at the early stage of status epilepticus: first insights from the ICTAL registry. Crit Care Med 2023;51:388–400.

[3] Deuschl G, Beghi E, Fazekas F, Varga T, Christoforidi KA, Sipido E, et al. The burden of neurological diseases in Europe: an analysis for the Global burden of disease study 2017. Lancet Public Health 2020;5:e551–67.

[4] Elger CE, Hoppe C. Diagnostic challenges in epilepsy: seizure under-reporting and seizure detection. Lancet Neurol 2018;17:279–88.

[5] F-Score. DeepAI 2019. https://deepai.org/machine-learning-glossary-and-term/s/f-score [accessed 13.09.23].

[6] Gacquer W. https://osf.io/453qs; 2024.

[7] Jeppesen J, Christensen J, Johansen P, Beniczky S. Personalized seizure detection using logistic regression machine learning based on wearable ECG-monitoring device. Seizure 2023;107:155–61.

[8] Jeppesen J, Fuglsang-Frederiksen A, Johansen P, Christensen J, Wüstenhagen S, Tankisi H, et al. Seizure detection using heart rate variability: a prospective validation study. Epilepsia 2020;61(Suppl 1):S41–6.

[9] Jeppesen J, Johansen P, Beniczky S. In response: heart rate differential method simple but inefficient method for seizure detection. Epilepsia 2019;60:2532.

[10] Jimenez-Perez G, Alcaine A, Camara O. Delineation of the electrocardiogram with a mixed-quality-annotations dataset using convolutional neural networks. Sci Rep 2021;11:863.

[11] Kass RE, Raftery AE. Bayes factors. J Am Stat Assoc 1995;90:773–95.

[12] Ke G, Meng Q, Finley T, Wang T, Chen W, Ma W, et al. LightGBM: a highly efficient gradient boosting decision tree. Adv Neural Inf Process Syst 2017;30.

[13] Makowski D, Pham T, Lau ZJ, Brammer JC, Lespinasse F, Pham H, et al. NeuroKit2: a Python toolbox for neurophysiological signal processing. Behav Res Methods 2021;53:1689–96.

[14] Nasef MS, Gaber AA, Abdelhamid YA, Bastawy I, Abdelhady ST. Wahid el din MM. Corrected QT interval and QT dispersion in temporal lobe epilepsy. Egypt J Neurol Psychiatry Neurosurg 2021;57:6.

[15] Shum J, Friedman D. Commercially available seizure detection devices: a systematic review. J Neurol Sci 2021;428:117611.

[16] Strzelczyk A, Adjei P, Scott CA, Bauer S, Rosenow F, Walker MC, et al. Postictal increase in T-wave alternans after generalized tonic-clonic seizures. Epilepsia 2011;52:2112–7.

[17] Surges R, O'Brien TJ, Walker MC, Sander JW. Epilepsy and the heart: literature review and clinical recommendations. Eur Heart J 2020;41:3914–20.

[18] Szurhaj W, Leclancher A, Nica A, Périn B, Derambure P, Convers P, et al. Cardiac autonomic dysfunction and risk of sudden unexpected death in epilepsy. Neurology 2021;96:e2619–26.

[19] Tomson T, Surges R, Delamont R, Haywood S, Hesdorffer DC. Who to target in sudden unexpected death in epilepsy prevention and how? Risk factors, biomarkers, and intervention study designs. Epilepsia 2016;57(Suppl 1):4–16.

[20] van der Lende M, Surges R, Sander JW, Thijs RD. Cardiac arrhythmias during or after epileptic seizures. J Neurol Neurosurg Psychiatry 2016;87:69–74.

[21] Van Elmpt WJC, Nijsen TME, Griep PAM, Arends JBAM. A model of heart rate changes to detect seizures in severe epilepsy. Seizure 2006;15:366–75.

[22] van Westrhenen A, De Cooman T, Lazeron RHC, Van Huffel S, Thijs RD. Ictal autonomic changes as a tool for seizure detection: a systematic review. Clin Auton Res 2019;29:161–81.

[23] Varon C, Jansen K, Lagae L, Van Huffel S. Can ECG monitoring identify seizures? J Electrocardiol 2015;48:1069–74.

[24] Verrier RL, Pang TD, Nearing BD, Schachter SC. The Epileptic Heart: concept and clinical evidence. Epilepsy Behav 2020;105:106946.