{'fraction_non_alphanumeric': 0.035236449837277514, 'fraction_numerical': 0.012816907067379164, 'mean_word_length': 4.710025235145675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Epilepsy Seizure Detection: A Heavy Tail Approach

Epilepsy is a chronic brain disorder that affects the quality of life of many patients even when this disease is being controlled. If we want to improve those lives affected, we need to perform real-time epilepsy detection with constant monitoring of the electroencephalogram (EEG) signal. Typically, the statistical behavior of the EEG signals presents heavy-tail phenomena, therefore their analysis must be particular in order to define a strong framework based on statistical parameters to detect seizures. In this article, the heavy-tail characterization of EEG signals is studied, a simple real-time epilepsy detection using an alpha-stable estimator is proposed, and the false-positive rate is analyzed. The performance of the proposed estimator is compared to others previously reported in the literature, and we show that one of the signal parameters characterized as an alpha-stable distribution, serves as an indicator of epilepsy episodes more efficiently. Furthermore, the proposed algorithm presents low sensitivity to noise below the 3.8 dB.


I. INTRODUCTION
Epilepsy is a chronic neurological brain disorder, which affects more than 50 million people in the world throughout several years of the patient's life, [1]. Even if the patient is being treated for this disease, spontaneous seizures may occur. For this reason, an epilepsy patient involves constant monitoring, see [2] and [3]. Therefore, for treatment purposes, a system that detects seizures and sends alerts to hospitals and specialists in real time is critical. This detection system may assist medical professionals to analyze this information and perform the required actions to guarantee the well-being of the patient, [2]. However, seizure detection represents a challenge for researchers, as each new computational algorithm must provide faster and more accurate detection, as well as robustness to noise.
Currently, several biomedical monitoring approaches are available to detect an epileptic seizure. The most common procedures are based on the abnormalities in the The associate editor coordinating the review of this manuscript and approving it for publication was Berdakh Abibullaev . electroencephalogram (EEG) signal, [3]- [5]; moreover, other methods make use of techniques such as electromyography (EMG), accelerometry, motion sensing, electrodermal activity monitoring, audio/video recording, and combinations of two or more of these to improve seizure detection, [3] and [4]. Once the signal is collected, the success of the system depends on the design of the algorithm to analyze the information. Different models, such as the wavelet transform (WT) [6]- [10], Detrended Fluctuation Analysis (DFA) [5], [11], machine learning techniques [12]- [15], time-frequency analysis [16], canonical correlation analysis [17], [18], entropy of the EEG signal [19], or stochastic modeling [4], [20]- [22], are used to analyze signals. Their evaluation is based on detection rate, false alarm rate, positive predictive value, etc., [23].
Most of the EEG information analysis is carried out through visual inspection, thus the signal features are important to be modeled. The EEG signal characteristics have been modeled based on power-law spectrum in different scenarios, see [5] and [24]. In addition, in [25] an attempt to model EEG signals using a mixture of distributions is presented.
On the other hand, in [26] an experiment of the brain activity while the patient is playing videogames is designed. In [27] the EEG and EMG are recorded when the patient follows an avatar's motion. After that, in [28], a Convolutional Neural Network (CNN) is designed to screen depression using the EEG signal of the patient. Next, in [29], the Global Optimal Constructed ICA (GocICA) is considered for the neurorehabilitation and the movement intention detection of a person. At this point, it is important to note that those papers do not address epileptic seizures based on modeling. Reference [30] introduces an automated patient-specific classification for long-term electroencephalography extracting the epilepsy phenotypes. In [4], a Cauchy-based state-space model for detection of epileptic seizures is introduced. Nevertheless, the computational complexity of the algorithm is high, and as a result, detection tends to be off-line.
In this article, we follow a statistical approach and propose a novel algorithm to model EEG signals using parameters of alpha-stable distributions and determine the parameters that are sensitive to the presence of seizures in an EEG data set. We also introduce a real time epilepsy seizure detection technique. In addition to those aforementioned, this algorithm is feasible for implementation in portable devices and it has a reduced computational complexity. Furthermore, when the detector was evaluated in noisy environments, which is common in this sensing scenarios, good performance of the detection technique was achieved.
The remainder of this article is divided as follows: Section II introduces the model of the signal with the alpha-stable distribution. Section III presents the seizure detection using alpha-stable parameters. Section IV describes the detector, while Section V contains the main results. Section VI presents results on false positives and finally, section VII shows the conclusions and future work.

II. EEG SIGNAL MODELING BASED ON ALPHA-STABLE PARAMETERS
A random signal is considered to have a heavy tail when the tail of its distribution decays slower than that of the exponential distribution. It represents a high variability signal with numerous peaks during the process realization, [29]. Signals with heavy tail distributions can be located in different environments [31], such as in ocean engineering [32], meteorology science [33], human action behavior [34], or hydrology [35], among many others. Also, an EEG signal is generated by the superposition of millions of random variables in the form of synchronous electrical potentials induced by neurons, [36]. As the evoked potential of each neuron is individual, the potentials associated to such random variables are considered to be independently and identically distributed (IID). The electrical potential in neurons is transmitted in the form of peaks, causing the signal to have a heavy tail distribution, see [14], [37], and [38]. This means that observed voltages in these signals present more variation than a Gaussian process and it is common that values depart far away from the central or mean value. The generalized central limit theorem describes the superposition of independent random variables as Gaussian. Now, with independent heavy tail random variables, as in the case of the EEG signal modeling, it is suitable the use of alpha-stable distributions, [39].
The method to determine if a signal has a heavy tail is based on the behavior of the complementary cumulative distribution function (CCDF). The CCDF of an EEG signal is depicted in Fig. 1 together with the theoretical CCDF of three different models: Gaussian, exponential, and Pareto. It can be observed that the tail of the EEG signal has a similar decay as that of the Pareto distribution, which validates that the EEG signal has a heavy tail. The database analyzed in Fig. 1 was collected at the Children's Hospital Boston, and it consists of EEG recordings from pediatric subjects with seizure diagnosis. The patients were observed for several days with no medication to control epilepsy, [40]. For this EEG signal, the calculation of the alpha-stable parameters is highly demanding in regard to computational resources. Although the simulated characteristics result in a more realistic environment than that when the Gaussian method is used, [41]. The alpha-stable parameters can be expressed by the characteristic equation for random variable X, reported in [42]- [44] and [45] as where The full stable class S(x; α, β, γ , δ) is characterized by four parameters described in [39]. They consist of the index of stability parameter, α ∈ (0, 2]; the skewness or symmetry parameter, β ∈ [−1, 1]; the shift or dispersion parameter, γ ≥ 0; and the position or scale parameter, δ ∈ R. Different characteristics of the distributions result when parameters α and β change. For different values of α, i.e., when S(x; 2, β, γ , δ), S(x; 1, β, γ , δ), or S(x; 0.5, β, γ , δ), we get the Gaussian, Cauchy, or Levy distributions, respectively. When β changes, the symmetry of the distribution changes.
Nonetheless, a signal could have different characteristics that can be modeled if the alpha-stable parameters are changed. Here, we evaluate the alpha-stable parameters in an epileptic seizure which modifies the hyperactivity of neurons. Thus, the next section presents an analysis of the impulsive EEG signal.

III. EPILEPSY DETECTION
Alpha-stable parameters provide valuable information about the EEG signal which can lead to the detection of important diseases. For instance, when a patient has an epileptic seizure the distribution of the EEG signal presents some fluctuations, [46]. In [4], Support Vector Machines (SVM) are used to compare the distribution of the EEG signal with Gaussian and Cauchy distributions. In [47], the Automated aRTifacts handling in EEG (ARTE) method, which is based on wavelets is presented. In [48] the multiscale radial basis functions (MRBF) and a modified particle swarm optimization (MPSO) framework of the time-frequency feature extraction for epileptic EEG signals is shown. Nonetheless, these processes require a high computational cost.
In order to facilitate the calculation of the alpha-stable parameters, different estimators have been reported, see [39], [49], and [50]. Initially, Nolan Stable library for MATLAB is used to compute the parameters (x; α, β, γ , δ), [51]. For analysis purposes a particular set of EEG signals from the MIT database was considered [40], in which the amplitude of the signal without seizures is 50 µV, the amplitude of the signal with seizures is 600 µV, and the sampling frequency is 256 Hz. All the experiments were conducted using MATLAB. The method to obtain the parameters is described as follows: first, a 1-second length window of the signal is used in the computation of the alpha-stable parameters. After that, the window is shifted 0.36 seconds and the process is repeated. The outcome of the experiment is shown in Fig. 2. Fig. 2a shows an EEG signal with two epileptic seizures in seconds 250 and 1450. Figs. 2b, 2c, 2d, and 2e represent the α, β, γ , and δ parameters, respectively. It can be observed that the collected electric signal associated to EEG Fp1 and F7 electrodes derivation presents 2 seizure events, the first in the time interval (250, 350) and the second one between 1,450 and 1,500 seconds. Although large values are frequently found in these kinds of signals, sometimes they are due to patient movements or noise in the electrodes. These results show that α and β parameters are not sensitive to changes in the EEG signal. Parameter α is always varying within a range of values between 1.5 and 2, showing that the EEG signal has a finite average; but it does not provide relevant information to detect an epileptic seizure. In contrast, see Fig. 2d, the value of the amplitude of parameter γ increases by a factor of four or five when an epileptic seizure occurs, thus, providing useful information to accurately detect an epileptic seizure.
On the other hand, variance could be a good detector, [52], however in heavy tail scenarios, when the tail index is below a value of 1, the variance does not converge. Other approaches such as Entropy, [53], Lyapunov, [54], and nonlinear prediction [55] detectors are options for seizure detection. Fig. 3 compares the proposed Gamma Method, with the Entropy, and Lyapunov detectors. We can see in Fig. 3f that the Gamma method proposed is the most robust to noise with respect to other meth-ods reported in the literature. The methods evaluated in Figure 3 were tested in different scenarios: noiseless and noise observed EEG signals. It can be seen that the methods evaluated have a good performance for the case without noise. However, in the case of noisy signals, the Gamma method (proposed) is the one with the best performance, so it is more robust than the other methods reported.
Three of the most commonly used algorithms to estimate alpha-stable parameters are McCulloch, [39], Stablecull, [49] and [50], and Nolan, [51]. We conducted an experiment to identify the best algorithm to estimate the parameter γ in terms of computational complexity, and the McCulloch proved to be the most suitable when α > 1 and it matches with the α behaviors in observations, [36] and [51]. Fig. 4 shows the results of this comparison. Nolan algorithm presents good performance; however, it doesn't provide an open source code for future implementation in portable devices. In addition, open code such as McCulloch and Stablecull presents good results for EEG signal analysis. In this work the estimators that can be replicable, are compared based on the processing time, and it is shown in Table 1.  In the two cases of Table 1, the accuracy of the estimators is similar; therefore, the processing time was evaluated to determine the best estimator. The remaining results are based on the McCulloch estimator, which presents a good performance of processing time and an acceptable accuracy for EEG seizure detection purposes.
In addition, when the detector is evaluated in other data sets with seizures, we obtain similar results. Fig. 5 shows outcomes of the estimation of parameter γ for four different EEG signals with seizures and their corresponding estimation of the parameter γ . One can see that the parameter γ estimation is very sensitive to seizures in the EEG signal.

IV. DESCRIPTION OF SEIZURE DETECTOR
Since the parameter γ is sensitive to changes in the EEG signal for epileptic seizure events as shown in previous section, we propose an algorithm where the parameter γ is estimated first using the McCulloch estimator which relies on signal quantiles. Later, it is smoothed in order to improve the precision of detection. This smoothed version is then used in a detection stage to determine the number of seizures present in the EEG signal. The complete diagram of the system is presented in Fig. 6. This structure of the system uses the McCulloch algorithm and EEG signal from the MIT database, [40]. First, the system calculates the parameter γ , which is then smoothed out to reduce the influence of noise. Finally, in order to detect epileptic attacks, the signal is analyzed using the detector block. The description of every block is discussed next.

A. γ ESTIMATOR BLOCK
Initially, window length is set, and it is shifted 0.003 seconds. Then, the γ parameter is computed with McCulloch estimator. The experimentation window length was considered as a degree of freedom and we observed the best processing time when window length was of 0.16 seconds.

B. SMOOTHER SYSTEM BLOCK
In order to obtain a cleaner signal, the parameter γ must be smoothed-out. In this part, a window of the parameter γ is obtained. Then, the window is smoothed out using an averaging filter and shifted by 0.03 seconds and the process is repeated. The total processing time for this process is 0.089 seconds.

C. DETECTOR BLOCK
The last block of the algorithm consists of the detector, which considers two thresholds to avoid false positive and true negative detections. When consecutive estimated γ values increase significantly, first seizure threshold is set, this rise is taken as a reference for the rest of the signal. In practical terms when the parameter γ becomes five times the value of the previous sample, then an epileptic seizure is detected. After that, the system waits for the amplitude of the parameter γ to return to normal levels. If the amplitude of the parameter γ does not return to the normal amplitude, then the system cannot detect more seizures. This part is considered as the second threshold.

V. RESULTS
In this section, the signals from every block in the system previously shown in Fig. 6 are presented. In order to determine the best performance and reduce the processing time without losing accuracy, we analyzed different scenarios considering as degrees of freedom the window length of the estimator and the smoother system. Finally, the complete system performance is discussed in the last part of this section.

A. γ ESTIMATOR BLOCK
Three different window lengths are considered to analyze the EEG signal: 0.03, 0.39, and 1.95 seconds. After that, in all cases, it is set to 0.03 seconds. The results from the γ estimation are shown in Fig. 7. Fig. 5b and 5c show the amplitude of the parameter γ with an epileptic seizure, note that for windows of length 0.03 and 0.39 secs, it is at least 4 times larger than that without a seizure and up to 5 times larger. On the other hand, Fig. 5d shows that the amplitude of the parameter γ is 5 times larger than that without a seizure. As a result, we can define a threshold value of 5 for parameter γ ; meanwhile, the window length for the estimation of parameter γ is not important given that, in all three cases, the epileptic seizure is detected.
The evoked potential collected is associated to 1,800 seconds. Thus, in order to compare a feasible window  length, the overall trace is divided into bins of 0.03, 0.39, and 1.95 seconds. Table 2 compares the processing time of the proposed algorithm for different window lengths. It can be observed that the relationship between processing time and window length is not linear and note that the worst detection delay is viable for this health application.

B. SMOOTHER SYSTEM BLOCK RESULTS
After the gamma parameter is estimated it could be smoothed out in order to reduce the influence of noise. In this part, as in the previous section, a window of parameter γ is designed. During experimentations, we observe that a simple averaging filter improves the results. Thus, we considered for the smoother system block the mean values of 0.03, 0.19, and 0.39 seconds of γ estimations. The resulting signals from the smoother block are presented in Fig. 8. Fig. 8 shows that window size reduces the γ parameter estimation variation. However, the smoothing block depends on the Moving Average structure which affects the outcome presenting certain inertia. While large windows reduce the performance time, results are committed to the characteristics of the filter. The best results were obtained when windows were set at 0.03s.

C. DETECTOR BLOCK RESULTS
The number of epileptic seizures is detected by this block, it compares the smoothed γ parameter with a threshold (an increase of 5 times the typical value of γ ). The results from the experiments show that the system is accurate at detecting epileptic seizures. In addition, the processing time to scan the smoothed γ signal for a 30-minute experiment is 0.0041 seconds. Finally, the overall processing time of the complete system is 0.1725 seconds.

VI. FALSE POSITIVE RATE
In this section, the probability to detect a false positive by the proposed algorithm is presented. Theoretically, the detector considers an ideal EEG signal without noise. However, sensors, muscles, and the environment generate noise, which is mixed with the EEG signal. The relationship between noise and the EEG signal is presented in Figure 9. In Fig. 9, the EEG signal is represented by e(t) which, as mentioned above, is associated to a particular alpha-stable distribution S(α, β, γ , δ); n(t) is the noise of the different evoked potentials, and it is modeled by a Gaussian random variable N (µ, σ ), where σ is the standard deviation and µ is the mean value of the noise. Finally, s(t) is the observed EEG signal affected by noise. The signal s(t) is modeled as If the amplitude of n(t) is large, the detector is being affected by noise and as a consequence, it produces a false detection. Hence, in order to determine the noise sensitivity of the proposed algorithm, it is necessary to set the detection threshold appropriately in order to guarantee the detection of seizures by the algorithm. An epileptic seizure is detected when the gamma parameter is increased at least 5 times, this detection can be affected by background noise. The threshold was discussed in the section of the γ estimator block, and it is set to a value of 5, this threshold is defined by the following equationγ = 5γ True (4) where γ True is the parameter γ of the signal without noise, andγ is the estimated value of the observed signal s (t) that is affected by the noise amplitude. The estimation of the parameterγ is conducted using the McCulloch algorithm given by, see [39],γ whereŜ 0.75 andŜ 0.25 are the quantiles 75 and 25, respectively of the observed signal (Ŝ x such that P (S ≤ s) = x), the function θ(α,β) is defined in [39]. However, the seizure detection is associated with the increase ofγ , thus the value of θ can be considered as a constant. Note that e(t) and n(t) are independent sources; one of them is produced by the human body and the second by thermal voltage. The observed EEG signal s(t) is a combination of noise n (t) and actual value e(t); therefore, the PDF is given by with a characteristic equation s (ω) = e (ω) n (ω). Note that e (ω) does not have a closed form, and as a consequence neither does s (ω). In order to determine P (S ≤ s) , we approach the relation in (6) numerically. When the value of σ of the noise is higher, then γ True could have the same value asγ and the system will detect an epileptic seizure when it actually does not exist. For this reason, it is important to determine the maximum value where the algorithm detects seizures correctly. Thus, a numerical approximation was realized, and it is shown in Fig, 8.
In heavy tail scenarios, when 1 < α < 2, the central moment is infinite. Moreover, when 0 < α ≤ 1 the tail of the distribution presents a very slow decay and as a consequence, the mean and variance values are theoretically infinite. In Fig. 10, it can be observed that the system is more sensitive to false positive results when small values of α in VOLUME 8, 2020 EEG signal occur. Several methods consider the amplitude of the EEG signal for epileptic seizure detection. However, the noise affects the amplitude of the signal, which may result in the system detecting false positives. Additionally, other papers in the literature report higher computational processing requirements to detect seizures. In this article, we show that using quantiles is a fast and robust technique for seizure detection with low computational requirements, which results in a reduced computational processing and detection time. In the case of the proposed algorithm in this article, the main computational processing load takes place when sorting the information and obtaining the quantile values. This requires multiple comparisons and data exchange. On the other hand, other methods that have been proposed that we compared in this article, require complex mathematical functions or statistical calculations that could delay the outcome. Quantiles are directly proportional to the width of the pdf, which is less vulnerable to noise. Besides, the variance of noise is related to the power amplitude. Fig. 10 shows that if the value of alpha is growing, then parameter σ of the noise must be larger for the system to fail. In this case, the system could increase the false positive rate.
It is observed that false positives appear in some of the scenarios evaluated when the background noise is greater than 3.8dB, which is the equivalent to haveγ = 5γ . Thus, to avoid false detection in those cases caused by the background noise, and in order to be sufficiently sensitive, the threshold value is set to 5.

VII. CONCLUSION
In this article, an accurate algorithm to detect epileptic seizures is designed. The algorithm is less sensitive to noise and swifter than others reported in the literature.
The best performance to estimate the gamma parameter is obtained using the Nolan estimator. It was proven that the length of the window to calculate the gamma parameter is not important as in three different cases the detection was accurate. As an alternative, the McCulloch estimator, an open algorithm which encourages the implementation in portable devices, shows good results. For practical purposes, a good performance is obtained with a window-length of 1.95 seconds.
It was demonstrated numerically that the designed algorithm is robust to the influence of noise and has low computational processing. The algorithm uses quantiles, which makes it more robust to noise, thus increasing the accuracy of the detection. For those interested, the program codes and a flowchart of the main algorithm are in [56].