1 Introduction

Epilepsy is one of the most common neurological disorders [1]. It is mainly characterized by a perdurable predisposition to generate epileptic seizures and by the neurobiological, cognitive, psychological, and social consequences. This disorder is characterized by recurrent and unpredictable interruptions of normal brain function called epileptic seizures. An epileptic seizure is defined conceptually as a transient occurrence of signs and/or symptoms due to abnormal excessive or synchronous neuronal activity in the brain [2, 3]. Epilepsy has become the second-highest incidence of cerebrovascular diseases and about 1% of the world’s population suffers from epilepsy [4]. The condition affects all ages [5]. In the USA, more than 500 thousand patients are older than 65 years and more than 300 thousand patients are younger than 14. Despite the introduction of new antiepileptic drugs in the last decades, one-third of people with epilepsy continue to have seizures despite treatments [6]. Epileptic seizures are often thought to have a well-defined onset time determined by electroencephalogram (EEG) and or clinical signs (semiology). However, some patients suffering from epilepsy can feel the seizures coming before it is registered on EEG (prodrome which is an early symptom that indicates the onset), indicating that physiological changes happen in the pre-ictal period before the seizures arise [7]. In most cases, EEG monitoring which presents the gold standard in neurology for clinical monitoring of seizure activities is usually unavailable [8]. Moreover, monitoring the seizure activity based on the use of EEG signals is not always easy and accessible for several reasons and can be made only by highly trained neurologists, which is expensive and time consuming [9]. In addition, abrasive paste and electrolyte gel are sticky products that make hair scalp dirty and could be harmful [10]. Furthermore, specialists are wasting time trying to reduce the impedance of electrodes to an acceptable value where a countdown begins when the gel dries causing the disappearance of the transudative properties [11]. For that reason, electrocardiogram (ECG) is a very useful signal as it is routinely monitored, and compared to EEG, a trained specialist is not required for ECG recording. Besides, ECG signal has a higher signal-to-noise ratio than EEG signal [8].

Epileptic seizures (partial and generalized) affect behavior of autonomic function during all periods: preictal, ictal, and post-ictal. Moreover, the sympathetic nervous activity is activated by seizures, which leads to an increase in heart rate and blood pressure [12]. For that reason, several works tried to demonstrate and quantify the significant changes in ECG signal in the preictal period. A power spectrum analysis on six seizures taken from three patients (two females, one male) in [7] showed a significant increase in the curve of the reciprocal high frequency band (HF) (0.15–0.40 Hz) just around the onset time of epileptic seizure. The authors used ECG data from 25 to 30 min pre-seizure up to 30 to 300 s post-seizure of ECG. Moreover, a random season of 30 min ECG acquisition not within 4 h of seizures was used as a non-seizure control period. They did not report any significant changes for the frequency band features analyzed such as (LF) (0.04–0.15 Hz), the very low frequency (VHF) (0.40625–0.5 Hz), HF, the ratio LF/HF, and LF/(LF + HF). The authors in [13] investigated into ECG changes in the pre-ictal period. Four clustering techniques (K-means clustering, Agglomerative hierarchical clustering, Density-based spatial clustering (DBSCAN), and expectation–maximization (EM) clustering) were used in order to quantify changes in the pre-ictal period using three-features combination extracted from 32 Heart rate variability (HRV) features (linear and nonlinear). The latters were extracted from 120 min of signal preceding the seizures and time preceding the seizure prediction horizon (SPH) of 10 min. Using the clustering techniques, the author was able to distinguish 41% of the seizures and 90% of the patients. In addition, changes predicted in the intervals 40–0 min before seizures were more prominent than in other intervals with 47 seizures (53% of all the seizures studied). In the same study, for the interval of 80–40 min only 21 seizures, which account for 28% of all the seizures studied allowed to obtain predictions. Then, for the last finding interval 80–120 min, 25 seizures, which represent 24% of all the seizures studied were predicted. Furthermore, the authors reported that time-domain features RRmax, RRmin, and RRmean were the most relevant features. In terms of predictability, they found the following features: LF/HF, the number of adjacent RR intervals which differ by more than 50 ms divided by the total number of RR intervals (pNN50), the number of pairs of successive NN (R–R) intervals that differ by more than 50 ms (NN50), and recurrence quantification analysis (RQA) entropy (ENT). Other works on prediction of epileptic seizures were based only on ECG. In [14], the authors used a set of eight linear and nonlinear features which are: time interval between two successive R peaks (RRi), Mean of heart rate (Mean HR), LF, HF, LF/HF, Poincaré plot standard deviation perpendicular the line of identity (SD1), Poincaré plot standard deviation along the line of identity (SD2) and SD2/SD1 extracted from the data taken from a public database [15] which consists of 11 seizures taken from seven subjects. Besides, using the threshold technique, the authors reported a prediction sensitivity of 86.2%. In fact, a thresholding value was fixed for each patient. They also reported that features like mean HR, LF/HF, and SD2/SD significantly increased while the RRi significantly decreased. Moreover, most of the observed changes in the features occurred 15 min before the seizures. In [16], the authors studied the data taken from the public database [15]. In order to predict the epileptic seizure, the authors used a threshold technique and SVM using temporal and spectral features. The temporal features are the Hjorth features: activity, mobility and complexity whereas the spectral features are spectral entropy and means of absolute derivation. These authors reported that the threshold technique was better than the SVM classifier for epileptic seizure prediction and reported a prediction performance of 94.2% as accuracy, a sensitivity of 84.1% and a specificity of 94.5%.In [17] the authors studied 170 seizures taken from 16 patients where time and frequency domain features were computed. Adaptative threshold techniques were used and a threshold value was fixed for each patient separately. The proposed approach achieved a 75% sensitivity, a 0.21 false positive rate per hour (FP/h), a seizure occurrence period (SOP) of 4:30 and an intervention tile (IT) of 110 s. The authors also reported that between 30–15 min before seizure onset: the mean HR, RRi, LF/HF, and SD2/SD1 showed significant changes. In the approach proposed by [18], seizure prediction approach was proposed based on the use of an SVM classifier with Eigen decomposition HRV features based on covariance matrices. The authors used a total of 34 seizures taken from 12 patients (a total of 55.2 h of inter-ictal recording) and 123.6 h of ECG acquisitions taken from healthy subjects. The proposed approach predicted seizures onset from 5 min to the time just before the seizure with a 94.1% sensitivity, 0.49 false-positive per hour (FP/h) in patients with epilepsy and 0.19 in healthy subjects.

This work aimed to study changes in the ECG signal in the pre-ictal period to explore the feasibility of creating an automatic epileptic seizure prediction approach in which the result of the application of the statistical operator standard deviation (STD) on the computed HRV features is used as input for a thresholding technique in order to quantify the changes in the input pre-ictal ECG signal. The feasibility of our study was carried out using ECG acquisitions of a public and local databases consisting of 31 patients and a healthy public database consisting of forty patients.

2 Material and methods

2.1 Dataset

Siena Scalp EEG Database (version 1.0.0). To achieve our objective (establishing the feasibility of our methodology to quantify the epileptic seizures), we focused exclusively on ECG acquisitions of epileptic patients from a public database. The Siena Scalp EEG Database is free to use on the Physionet platform (https://physionet.org/content/siena-scalp-eeg/1.0.0/). The database consists of data acquired from 14 epileptic patients: nine males (aged 36–71) and five females (aged 20–58), within the Unit of Neurology and Neurophysiology at the University of Siena, Italy. The data contain synchronized EEG-ECG recordings of pathological patients acquired based on the use of EB Neuro and Natus Quantum LTM amplifiers, and reusable silver/gold cup electrodes. The electrodes used in the acquisition were arranged according to the international 10–20 system. During data acquisition, the patients were asked to stay in bed as much as possible, either asleep or awake [19]. All the data recorded were revised by expert clinicians according to the criteria of the International League Against Epilepsy. More information about the patients, seizures and signal duration are presented in Table 1.

Table 1 Siena scalp EEG database patients [17]

2.1.1 Post-ictal heart rate oscillations in partial epilepsy 1.0.0

The post-ictal database is available and free on the Physionet platform. The database consists of ten seizures recorded from seven female patients aged 31 to 48 years old. The duration of the recorded ECG signals varies from two to four hours with a sampling rate of 200 Hz, 12 bits per sample, and 5 mV. Besides, for each acquisition, the exact time of seizure onset and offset was specified by an expert [16].

2.1.2 Local data

The local database consists of 14 ECG acquisitions taken from 13 patients aged 8 and 42 years old. The experimental data were selected from the F-TRACT database of spontaneous video-SEEG seizures (research protocol INSERM IRB 14-140). The patients gave their consent to undergo invasive recordings and peripheral recordings as part of a pre-surgical evaluation of their drug-resistant epilepsy. The SEEG/ECG recordings were performed using a video-EEG monitoring system (Micromed, Treviso, Italy) that allowed for simultaneously recording up to 256 monopolar contacts. The sampling rate was either 256 or 512 Hz, with an acquisition band-pass filter between 0.1 and 90 Hz or between 0.1 and 200 Hz, respectively, depending on amplifier capacities at the date of recordings. The data were acquired using a referential montage with a reference electrode chosen in the white matter. The table below presents some details about the patient (age, gender, epilepsy type and lesion) [20] (Table 2).

Table 2 Local database description

2.1.3 Data manipulation

In order to study changes in the ECG signal in the pre-ictal phase, we took 1 h of ECG signal before seizures and 5 min after seizures. when the acquisition did not contain at least 1 h of signal before seizure, we used all the provided pre-ictal in our work. Moreover, we only used data from the patients where at least one readable ECG acquisition was available. In fact, the Siena scalp database was made only for epileptic EEG analysis. For that reason, some of the ECG acquisitions are unreadable due to the presence of a lot of noise, especially from 20 min before the seizure’s onset which allow the study of the variation of the input ECG signal in the pre-ictal period. The existence of such noises is due to either patient movements or bad connection of the ECG electrodes with patients' skin.

All functions and algorithms used in the current study were developed using open source python libraries such as MNE to read the signal acquisitions, NumPy for matrix manipulation and SciPy for the statistical analysis etc.

From the Siena scalp database, we were able to study only acquisitions from 11 patients after deleting all unreadable and very noisy ECG acquisitions. From the 11 patients, only 34 seizures were studied after getting rid of the unreadable acquisitions. In addition, patient PN16 was excluded from this study because both of his seizures were recorded during sleep. All seizures from the post-ictal database were used in our study.

Moreover, in order to improve our analysis, we also used inter-ictal segments taken from all the studied patients. We extracted 8 h of pre-ictal period from the post-ictal database, 29 h from the Siena scalp EEG database and 14 h from the local database. Heart rate takes some time after seizures to go back to the basic signal rate. The first five minutes after seizures are considered as post-ictal instabilities and we do not take them into consideration. In the present work, the inter-ictal period will be considered from at least 5 min after the onset. Besides, inter-ictal segments are considered before the one hour signal before the onset which is the pre-ictal segment. In addition, we only extracted inter-ictal segments with at least 20 min of continuous signal, so we could analyze all changes in the segments. Moreover, to maximize the number of segments of the inter-ictal period, the whole inter-ictal signal extracted was divided into sub-segments of 20 min length each to obtain 24 inter-ictal segments from the post-ictal database, 87 inter-ictal segments from the Siena scalp EEG database and 63 inter-ictal segments from the local database.

2.2 Pre-processing and feature extraction

In order to improve the R peaks detections, we applied multiple noises (such as the baseline wander, power-line interference, and electromyography noise) removal functions. For that reason, we used a notch filter followed by the application of two butterworth filters (high pass and low filters with order 2). Furthermore, our notch filter was used to remove the power-line interference with a 50 Hz cutoff (this cutoff should be 50/60 Hz). Then, the cutoff of the high-pass and the low-pass filters were set to 20 Hz and 10 Hz, respectively.

The next step in our approach was the detection of the R peaks series. For that reason, we used the QRS detection approach proposed in [21] which is based on the use of two moving average windows with a thresholding technique to detect the QRS complexes and extract the R-peak series from the input signal.

In order to demonstrate the variations of the ECG signal, we extracted time-domain analysis and nonlinear features that reflect dynamic changes of the input signal during the different stages of the signal: pre-ictal, seizure onset, and after seizure. Then, the time domain analysis features extracted were directly calculated from the time series of the extracted RRi. Next, we computed the number of the RRi distances extracted from the signal segment. The number of the RRi distance in the signal segment (NRRi) would directly reflect the dynamic changes (increase and decrease) of the heart rate.

In order to quantify unpredictability of a time series and complexity of mechanisms that regulate the HRV, a nonlinear metrics approximate entropy (ApEn) was computed. The ApEn was devised in order to quantify the regularity, correlation, and persistence in time series. At first, the ApEn was developed in order to analyze medical data, essentially heart rate [22]. This means a high ApEn values refer to the independence between the data signals (a low number of repeated patterns and randomness), and low ApEn values refer to a very persistent system (repetitive and predictive). In addition, a zero value of ApEn indicates a fully predictable series [23]. As for the Sample entropy, two variables will be needed to compute the ApEn, a factor noise factor \(r\) and a template’s length \(m\) (the different vector’s window length). Moreover, the higher the value of \(m\) and the smaller the value of \(r\) the sharper is the parameters description. Given a sequence of number \(u =\left\{u\left(1\right), u\left(2\right), \dots , u\left(N\right)\right\}\) with length\(N\), real positive value \(r\) and integer \(m\) where\(0 \le m \le N\). We define two blocks \(x\left( i \right) = \left\{ {u\left( i \right), u\left( {i + 1} \right), \ldots , u\left( {im {-} 1} \right)} \right\}\) and \(x\left( j \right) = \left\{ {u\left( j \right), u\left( {j + 1} \right), \ldots , u\left( {j + m - 1} \right)} \right\}\). Next, the distance of those two blocks is computed as follows:

$$ {\text{d}}\left[ {x\left( i \right), x\left( j \right)} \right] = {\text{Max}}_{k = 1, \ldots ,m} \left( {\left| {u\left( {i + k {-} 1} \right){-} u\left( {j + k {-} 1} \right)} \right|} \right) $$
(1)

Next, for all \(x(i)\) vectors where \(i \le N - m + 1\), a value for \({c }_{i}^{m}\left(i\right)\) is computed by comparing all \(x(j)\) vectors where \(j \le N-m+1\) to \(x(i)\) vector [24] as in the following equation:

$$ c _{i}^{m} \left( r \right) = {\text{number of}} j \le N - m + 1, \;{\text{such that}} {\text{d}}\left[ {x\left( i \right),x\left( j \right)} \right] \le r/ \left( {N - m + 1} \right) $$
(2)

Moreover, \({c }_{i}^{m}\left(r\right)\) is always positive where for all i values, \(x(i)\) is compared relatively to x(i) [24]. \({c}_{i}^{m}\) counts the number of consecutive blocks of length m within the resolution \(r\) which are similar to a given block computed as follows:

$$ \phi^{m} \left( r \right) = \frac{1}{N - m + 1}\mathop \sum \limits_{i = 1}^{N - m + 1} \log c_{i}^{m} \left( r \right) $$
(3)

Then, the ApEn can be computed as follows [23]

$$ {\text{ApEn}}\left( {m, r, N} \right) = \phi^{m} \left( r \right) - \phi^{m + 1} \left( r \right) $$
(4)

In order to have more information about the signal, a sliding window with an overlapping was used. Besides, to select the optimal sliding window and the overlapping window, we selected randomly ten acquisitions from different patients to test several variations of sliding windows starting from 30 s up to 300 s. Then, the overlapping windows starting from 10 s up to 60 s of ECG signal were tested to search for an optimum. Figure 1 shows an example of the use of the sliding window technique with an overlapping window where in this example, \({W}_{0}\) presents an overlapping window of 10 s.

Fig. 1
figure 1

Sliding window of 120 s with overlapping of 10 s

Finally, after testing several sliding and overlapping windows, a sliding window of 120 s with an overlapping of 10 s reflected the best combination to quantify the changes of the ApEn curves in the pre-ictal period.

2.3 Prediction

After computing the RRi, our approach consists in computing two linear and nonlinear features: NRRi and approximate entropy (ApEn) using a sliding window with an overlapping technique. Then, based on the results of computing both NRRi and ApEn features, the standard deviation (STD) was computed using a sliding window of six values. Mathematically, the STD is computed by the following equation [25].

$$ {\text{STD = }}\sqrt {\frac{{\sum {\left( {X_{i} - \overline{X} } \right)^{2} } }}{n - 1}} $$
(5)

where \(Xi\) presents the value at position \(i\), \(\overline{X }\) presents the means of all values in the sample, \(n\) is the number of the values in the sample.

Figure 2 shows the result of computing the ApEn feature of a one-hour pre-ictal period (the discontinuous red line represents the moment of the seizure) taken from patient PN09-3 from the Siena scalp EEG database. The same figure also demonstrates the result of computing the STD operator using ApEn feature. Figure 3 demonstrates the result of computing the NRRi feature and the STD-NRRi with the same acquisition used in Fig. 2.

Fig. 2
figure 2

The result of computing the ApEn and the STD-ApEn curves for the PN09-3 acquisition

Fig. 3
figure 3

The result of computing the NRRi and the STD-NRRI curves for the PN09-3 acquisition

In order to confirm a seizure alert, the STD calculation results calculated from these two features were combined. In addition, the threshold method was used on the STD results to ensure seizure prediction. The threshold value with the best prediction results was selected. In the present work, tests were applied on the pre-ictal and the inter-ictal segments to select the best threshold value where each patient was studied separately. Furthermore, a seizure alert is predicted if and only if the threshold exceeded both the STD curves of ApEn and NRRi.

3 Results and discussion

In order to measure the performance of our proposed approach, pre-ictal and inter-ictal data taken from both epileptic databases were tested. From the Siena scalp EEG database, we were able to extract 34 seizures taken from 11 patients studied. Moreover, none of the noisy or in-sleep acquisitions were taken into consideration. All the ten seizures from the post-ictal database were analyzed. In addition, we used 8 h of the inter-ictal signal taken from the post-ictal database and 29 h of inter-ictal signal taken from the Siena scalp EEG database. The whole inter-ictal signal extracted was divided into 20-min long sub-segments to obtain 24 inter-ictal segments from the post-ictal database, 87 segments from the Siena scalp EEG database and 63 inter-ictal segments from the local database.

In order to characterize epileptic seizure prediction, three criteria were introduced: sensitivity, specificity, and accuracy. Sensitivity reflects the probability of a positive detection whereas specificity reflects the probability of true detection of the non-seizure segment (inter-ictal segment):

True positive (TP): pre-ictal segment identified as a pre-ictal segment.

False-negative (FN): pre-ictal segment incorrectly identified as an inter-ictal segment.

False-positive (FP): inter-ictal segment identified as a pre-ictal segment.

True negative (TN): inter-ictal segment identified as an inter-ictal segment.

The three criteria proposed are computed as follows:

$$ {\text{Sensitivity}} = \frac{{{\text{TP}}}}{{{\text{TP}} + {\text{FN}}}}*100 $$
(6)
$$ {\text{Specificity}} = \frac{{{\text{TN}}}}{{{\text{TN}} + {\text{FP}}}}*100 $$
(7)
$$ {\text{Accuracy}} = \frac{{\left( {{\text{TP}} + {\text{TN}}} \right)}}{{\left( {{\text{TP}} + {\text{FP}} + {\text{TN}} + {\text{FN}}} \right)}}*100 $$
(8)

Based on the proposed three criteria, we compared our analysis with two other works that used the threshold technique to predict epileptic seizures. As all the analyses were extracted from the post-ictal database, we present in the following table our results:

As can be seen in Table 3, our proposed approach achieved a higher value of sensitivity and specificity compared to the other works. However, the proposed approach in [16] achieved a better accuracy than our approach. The authors in [14] did not mention accuracy. The proposed approach also showed a prediction latency much better than both approaches seen in the state of arts. However, none of the two works have specified the length of the pre-ictal and inter-ictal segment studied compared to our work. Besides, no information was mentioned about the number of inter-ictal segments used to measure the performance of their approaches.

Table 3 The comparison of the proposed approach performance with the approaches from the state of art using post-ictal database
Table 4 Comparison between the prediction delay of our work with the state of arts works using the post-ictal database

We also compared the prediction latency of the proposed approach with the other approaches seen in the state of arts as it can be seen in Table 4. In fact, in some acquisitions, we can see that there is not a huge difference between the prediction delay of our approach compared with [16] (both threshold and SVM results) such as for patient 1, patient 5. Otherwise, our approach predicted the epileptic seizure before 43.08 min, 22.32 min and before 46.5 min, 35.84 min for both seizures of patients 2 and 6, respectively.

Similarly, we tested the performance of the proposed approach on the local database as can be seen in Table 5. The proposed approach achieved a 100% sensitivity, a 97% specificity and 97.5% accuracy. The local database consists of acquisitions taken from 14 patients with different seizure types, which prove the feasibility of the proposed approach to predict epileptic seizures using ECG of different seizure types. Moreover, from 63 inter-ictal segments, only two false alerts were returned by our approach.

Table 5 The Performance of the proposed approach using the local database

Table 6 presents the delay prediction of the proposed approach using the local database data. All patients in this database are presented with only one seizure except patient 13. Our proposed approach could achieve a prediction delay starting from a few seconds before the seizure up to more than 15 min before the seizure.

Table 6 Prediction delay of the proposed approach using the local database

We also measured the performance of the proposed approach using the epileptic database Siena scalp EEG database as can be seen in Table 7. The Siena scalp database is composed of acquisitions with focal onset impaired awareness (IAS), focal onset without impaired awareness (WIAS), and bilateral seizures, where the majority of the acquisitions are IAS. For that reason, the performance of the proposed approach was measured firstly using only IAS acquisitions and then all the acquisitions extracted from the database.

Table 7 The performance of the proposed approach using the Siena scalp EEG database

As it can be seen In Table 7, using only the acquisitions with IAS seizure, our approach could achieve a 100% sensitivity, a 95% specificity and a 96.4% accuracy. However, using all the acquisitions (different seizure types) we achieved an 85% sensitivity, a 94% specificity, and a 91.5% accuracy. Unfortunately, we could not compare this performance with other approaches because, to the best of our knowledge, the present work is the first to study the effect of epileptic seizures on the ECG signal using the new public database Siena scalp.

Using only data taken from patients with the IAS seizures, from the 61 inter-ictal segments, our approach sent a false alert only on 3 inter-ictal segments which showed unexpected changes in both curves. In fact, apart from all patients with temporal epileptic seizures in the Siena scalp EEG database, patient PN14 was the only one to have WIAS and we could study only two seizures (the rest contain a lot of noise), and our approach predicted only one of the two seizures studied. Subject PN10 was the only patient in the database who had Bilateral epilepsy. Our approach could predict only five seizures from eight seizures studied. No more investigations could be made to assume why no seizure alert was triggered for those acquisitions taken from both PN10 and PN14 patients, which was due to a lack of patient data with the same type of seizures.

Figure 4 presents the prediction delay of the proposed approach using the Siena scalp EEG and the local database. The blue and orange points reflect the prediction delay for the Siena scalp EEG and the local databases, respectively. As it can be seen in these Fig. 4, the prediction delay varies from a few seconds before the seizure up to more than 15–20 min before the seizure depending on patients. In Addition, for almost all patients with more than one seizure acquisition, the prediction times of the different seizures were close to each other. Moreover, the green points reflect the mean prediction delay of the Siena scalp EEG database acquisitions, which reflects our high prediction delay achieved.

Fig. 4
figure 4

Presentation of the prediction delay for the Siena scalp EEG database and the local database

Table 8 presents the percentage of the predicted seizures by the time of prediction, either from 0 to 5 min, 5 to 10 min or predicted before the seizure by more than 10 min. As it can be seen, in the table, our approach could predict 58.7% and 57.2% of the seizure before more than 10 min for both post-ictal and local database, respectively. For the Siena database, our approach could predict only 40% of the seizures before 10 min from the onset.

Table 8 Percentage of the predicted seizure by the prediction time

Figure 5 shows an example of the STD operator calculation on a one-hour pre-ictal period and 10 min after the onset taken from epileptic patient 9 from the Siena scalp EEG database. This was aimed at studying the modifications before and after the onset. In this example, the red discontinuous line represents the moment of the seizure. The red cross in the figure shows when both curves exceed the threshold (presented by the blue discontinuous line) before the seizure at the same time interval, which triggers a seizure alert. As it can be seen, our approach could quantify and predict the seizure before 33.6 s for this acquisition.

Fig. 5
figure 5

The result of applying the proposed STD approach on patient PN09-3

In this work, we also proposed an automatic threshold technique for onset prediction. We believe that for normal patients, the variation of both features (ApEn and NRRi), especially the NRRi, which presents heart rate changes, varies around the value of the mean. For that reason, the proposed approach consists in using the mean of the STD computed from both ApEn and NRRi features. Moreover, based on the use of the computed STD curves, the automatic threshold approach proposed consists in using a five mindata segment with one minute overlapping. Next, for each segment, the threshold value is computed following list of equations:

$$ {\text{Thresh}} = {\text{Mean}} + \beta $$
(9)
  • Where \({\text{Mean}}\) represents the mean value of the input data segment.

  • \(\beta \) is a value computed from \({\text{Mean}}\) where the value of \(\beta \) will be in the range of values [0–\({\text{Mean}}\)], where the min value of \(\beta \) will equal to 0 and the max will be equal to the value of \({\text{Mean}}\)

  • For selecting the \(\beta \) value, a grid-search algorithm will be used to test all possible threshold values.

  • We first test all the possible values of \(\beta \) using only the inter-ictal period to find the values which will return the less false alerts. Then, the pre-ictal periods will be used to select the proper β value that will return the best performance (maximum onset prediction and the less false alerts results) to be selected.

  • The \(\beta \) value will be selected for each patient separately.

Table 9 presents the results of testing the performance of the automatic threshold prediction approach using the same three databases adopted by the manual threshold technique. In fact, acquisitions of less than 10 min in length will not be taken into consideration in this part of the work.

Table 9 The performance of the automatic threshold approach using local database

From the results presented in the tables above, the prediction approach using the manual threshold value selection gave a better result. In fact, the proposed automatic threshold technique is based on the mean of the two features computed. Even for the inter-ictal period, if the changes (peak) in both curves’ features was instant, and even if these changes are small compared to pre-ictal period, this kind of change is considered as a prediction by our proposed automatic approach (false alert). Another weak point in our proposed automatic threshold technique is the gradual increase of the value. If the values of both curves increase gradually in time, the threshold value will also increase gradually with the curves, which will lead to unpredicted seizure. For those reasons, a manual threshold selection technique gave better results. In the inverse, the manual threshold selection is not affected by those problems. Figure 6 shows an example of application of the automatic threshold approach on the pre-ictal period of the second acquisition of patient number 6 from the Siena Scalp EEG database. In fact, the period studied in this figure represents 1 h before the seizure and 10 min after. The discontinuous red line represents the moment of the seizure. The discontinuous green line represents the threshold value which varies in time. Moreover, the red cross in the figure shows when both curves exceed the threshold (they are above the threshold in the same moment) triggering a seizure alert. As it can be seen, our approach could quantify and predict the seizure before 27 min for this acquisition.

Fig. 6
figure 6

An example of applying the automatic threshold prediction approach on PN06-2 acquisition

For almost all the studied acquisitions, significant changes for both NRRi and ApEn features were seen in the pre-ictal period of the input ECG signal. In fact, a significant decrease was seen in the NRRi features, especially right before the seizure. This increase can be explained by the fact that about 82% of epileptic seizures are associated with ictal tachycardia which proceeds epileptic seizures [18]. In addition, the ApEn features showed significant change in the pre-ictal period, and a clear decrease was seen for almost all the patients right before the seizure, which can be associated with the increase in the sympathetic activity [18].

In this work, not only were ApEn and NRRi features studied but also several other features such as ApEn, sample, fuzzy, Shannon and spectral entropy to quantify the complexity of mechanisms that regulate HRV. Moreover, to study temporal changes in the HRV, we studied several features such as SDNN (the standard deviation of the RRi), RMSSD (the root mean square of successive differences between normal heartbeats), pNN50. However, not all features studied showed significant changes to be used in our approach and ensure a good quantification and prediction of the epileptic seizures except for NRRi and ApEn which showed a significant correlated change in the pre-ictal period and inter-ictal period. In this part of the paper, we describe some significant changes in the other features studied which can be used to predict epileptic seizures. Only acquisitions taken from the Siena scalp EEG database were studied whereas no information about localization, lateralization, or even the seizure types was given for the acquisitions taken from the post-Ictal database. Besides, the local database contains mixed acquisitions for adults and children, and we still do not know if the HRV will react in the same way for both categories.

A significant change in the sample and fuzzy entropy curves was seen starting approximately 30 min before the seizure for patients PN06, PN10 (bilateral seizure), and PN14 (starting from the discontinuous green line, where the red line presents the start of the seizure). However, for patient PN09, these changes occurred starting 15 min before the seizure. In the same way, for both fuzzy and sample entropy curves, a clearly significant decrease was seen either at the moments of the seizure or just after the seizure for all the studied acquisitions. This decrease was not seen for only the patient PN10-2 as can be seen in Figs. 7 and 8.

Fig. 7
figure 7

Fuzzy entropy curves of four different patients in the pre-ictal period (1 h before the seizure)

Fig. 8
figure 8

Sample entropy curves of four different patients in the pre-ictal period (1 h before the seizure)

Studying the SDNN feature in the pre-ictal period (1 h before the seizure) showed a slight decrease of the SDNN curve for patient PN06 starting 25 min before the seizure (in blue color), PN10 (bilateral seizure) showed a significant decrease between 30 to 8 min before the seizure while a significant change was seen for patient PN09, 14 min before the seizure. Moreover, a significant increase in the SDNN curve was seen starting from the moment of the seizure for patients PN06, PN09, and PN14 as can be seen in Fig. 9.

Fig. 9
figure 9

Extraction of time-domain analysis features SDNN using the four acquisitions studied

The proposed epileptic seizure prediction approach is based on the threshold technique. For that reason, we could not measure the performance of the proposed approach to differentiate between the pre-ictal period of epileptic patients and the ECG of healthy subjects. Therefore, we used a statistical operator in order to distinguish between features computed from epileptic and healthy patients. In our case, we are studying continuous data where we are searching to show all differences between studied data. Next, the idea is to use a mean-based algorithm because the variation of both features (ApEn and NRRi) especially the NRRi varies around the average for normal patients. We only have two groups of data and neither of them follows the normal distribution (gaussian distribution), so we need to use a non-parametric algorithm where we end up with the Mann–Whitney algorithm. In fact, the Mann–Whitney U test will be used to compare differences between these two independent groups which test our hypothesis that these two groups are extracted from a same population (p). Besides. Mann–Whitney U test can be applied even on a small number of data between 5–20 values and larger group of data (> 20). However, the performance of the Mann Whitney algorithm increases with more input data [26]. Moreover, after applying the Mann–Whitney algorithm, the statistical P value given by the Mann–Whitney algorithm for both features taken from both epileptic and healthy subjects is less than null hypothesis 0.05 which means that both distributions are not from the same category, especially for the NRRi feature distribution.

We also investigated the histogram-distribution of the data taken from both epileptic and healthy patients. In fact, we took all the epileptic data studied in this work and all the healthy patients’ acquisitions and we compared their data distribution. As can be seen in Figs. 10, 11, 12, 13, there is a significant difference between NRRi distribution taken from epileptic and healthy patients. The NNRi value range is from 80 to 160 but for the epileptic patients it ranges from less than 100 up to more than 250. Moreover, for healthy patients, the value distribution is spread out compared to the epileptic distribution which is concentrated in value intervals [125–150]. In the same way, as it can be seen in Figs. 10, 11, a huge difference can be seen when comparing the histogram distribution of the ApEn feature of epileptic and healthy subjects where the healthy distribution is more spread out compared to the epileptic distribution. Moreover, the epileptic distribution is more concentrated around the value 0.8 compared to the healthy distribution where the concentration of the values is more spread out in the range of [0.6–0.9].

Fig. 10
figure 10

The histogram of the ApEn entropy of healthy patients

Fig. 11
figure 11

The histogram of the ApEn entropy of epileptic patients

Fig. 12
figure 12

The histogram of the NRRi feature of healthy patients

Fig. 13
figure 13

The histogram of the NRRi feature for epileptic patients

In fact, further research needs to address the limitations of the proposed work which includes only a small number of subjects in the study. Moreover, all patients from the Siena scalp data base suffer from IAS seizures with only one patient with WIAS seizure and only one patient with bilateral seizure. For that reason, no investigations can be made on the effects of the seizure type on the ECG signal in the pre-ictal period. In addition, it would be more important to study pre-ictal and inter-ictal periods of ECG acquisitions taken under the same conditions to have more accurate results and contributions not from three separated databases. In addition, having the clinical details about patients’ medical history, more information about the patient's condition and video monitoring can lead to better explanations of the changes in the ECG signal and more confidence in the contributions made by the proposed methodology. We are planning to collect more data about both children and adults to have a deeper insight into the signal changes resulting from an epileptic seizure. Nevertheless, another investigation could be done on the effect of the epileptic seizures in the pre-ictal period based on the use of other frequency-domain features and nonlinear feature analysis based on the chaos theory to better understand the effect of the epileptic seizure on the ECG signal. Furthermore, the HRV-based epileptic seizures prediction approach could be proposed in order to quantify the results of our work and the works that proved the effectiveness of epileptic seizures on the ECG signal.

4 Conclusion

In this study, we proposed two new approaches to ensure the quantification of the significant changes in the pre-ictal period based on the use of the threshold technique on the STD curves. Moreover, the STD curves were computed using the time-domain analysis feature NRRi and the nonlinear feature ApEn to reflect the high increase and the irregularity of the ECG signal before epileptic seizures. Using the manual threshold approach on the IAS seizures taken from the Siena scalp EEG database, we achieved a 100% sensitivity, a 95% specificity, and a 96.4% accuracy. However, we achieved a 100% sensitivity, a 91% specificity and a 94% accuracy when using the acquisition from the Post-Ictal database. We achieved a 100% sensitivity, a 97% specificity and 97.5% a accuracy when using the acquisitions from the local database. Furthermore, the proposed approach predicted 58.7%, 57.2, 40% of the seizures more than 10 min before onset for the data taken from post-ictal, local and Siena Scalp EEG database, respectively. Using the automatic threshold technique, we could achieve a sensitivity, a specificity, and an accuracy of 85%, 81%, 82%, respectively, using the local database. However, we achieved a sensitivity of 75%, specificity of 85% and an accuracy of 82% when using the acquisitions from the Siena Scalp EEG database. Besides, using the post-ictal database, we achieved a 90% sensitivity, an 83% specificity and an 85% accuracy. As a future work, additional ECG acquisitions will be collected and used to improve the performance of the proposed approaches and give more credibility to the results obtained.