Adaptive Filtering for Epileptic Event Detection in the EEG

The development of online seizure detection techniques as well as prediction methods are very critical. Patient quality of life could improve significantly if the beginning of a seizure could be predicted or detected early. This paper proposes a method to automatically detect epileptic seizures based on adaptive filters and signal averaging. The process was applied to 425 h of epileptic EEG records from CHB-MIT EEG database. The developed algorithm does not require any training since it is simple and involves low processing time. Therefore, it can be implemented in real time as well as offline. Three thresholds were evaluated and calculated as 10, 20 and 30 times the median value of ST(n). The threshold of 20 showed the best relation between SEN and SPE. In this case, these indexes reached average values, across all the patients, of 90.3% and 73.7% respectively. The proposed method has several strengths, for example: that no training is required due to the automatic adaptation to the threshold to each new EEG record. The algorithm could be implemented in real time. It is simple owing to its low processing time which makes it suitable for the analysis of long-term records and a large number of channels. The system could be implemented on electronic devices for warning purposes (of the seizure onset). It employs methods to process signals that were not used with epileptic seizure detection in EEG, such as in the case of adaptive predictive filters.


Introduction
The electroencephalogram (EEG) records all the electrical activity of the brain and therefore, EEG is used to evaluate the functioning of this complex organ. This record results in a set of waves with certain properties like frequency, amplitude and morphology. The frequency content differs among the different neurological rhythms while the amplitude of these waves can vary from a few micro-volts up to 200 μV [1]. Thus any electrical abnormality like epilepsy is reflected in the EEG.
It is estimated that approximately 1.5% of the world population suffers from epilepsy [2]. The epileptic activity begins when a focal energy discharge is generated in a small area of the brain [3]. This process is reflected in the EEG records through the presence of spikes known as an epileptic seizure. Hence, the EEG is the most non-invasive and easiest clinical tool to infer the onset of this process. This activity generated in a small area of the brain usually appears synchronously in the nearest areas [3]. Generally, the process is recorded in EEG as epileptic spikes in almost all channels. The characteristics of the EEG are different among the subjects, however during a seizure, these are very similar among epileptic patients [4]. More than 30% of people with epilepsy cannot control their seizures. Epileptic seizure prediction, referring to forecasting the occurrence of epileptic seizures, is one of the most important but challenging problems in biomedical sciences, around the world [5]. Figure 1 shows the five channels of an EEG recorded o during a patient seizure, the beginning and ending of it (red lines) are provided in the database. Note how the seizure appears in the five channels 1 Facultad de Ingeniería, Universidad Nacional de San Juan (UNSJ), San Juan, Argentina 2 Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET), Buenos Aires, Argentina almost simultaneously, at the same time interictal activity has different morphology between them.
The development of online seizure detection techniques as well as prediction methods are very critical. Patient quality of life could improve significantly if the beginning of a seizure could be predicted or detected early. Then, the development of safety systems to alert epileptic patients (or their caregivers) a priori to a crisis situation by: (1) aiding in avoidance or prevention of dangerous falls, (2) protecting from sharp blows to the head, or (3) controlling through devices which could release beneficial drugs. These kinds of systems are extremely useful for children with epilepsy to help them and their caretakers to benefit from a better quality of life.
Research on epileptic seizure automatic detection has progressed significantly recently due to the development of new technologies [6]. In the related bibliography, different signal processing techniques have been proposed for the automatic detection and prediction of epileptic seizures in EEG records. Some researchers analyzed only one EEG channel at a time [7], while others used multichannel analysis to evaluate the synchronization among them [5,8].
The synchronized epileptic activity in all the EEG channels could be used to enhance the seizure detection. Similarly, the signal averaging technique has been widely used in electrocardiography (ECG), specifically with QRS complexes to emphasize events [9], and has recently been applied to EEG signals by the authors [10][11][12].
Generally, adaptive filters (particularly predictive ones) have not been used to detect or predict the onset of epileptic seizures. These filters are usually implemented in the signal noise removal of the preprocessing stage. This paper proposes an algorithm based on adaptive filters and signal averaging to automatically detect, in real time, EEG seizure segments. The method exploits the synchronized epileptic activity in all the EEG channels to emphasize time and spectral characteristics therein. The use of the predictive adaptive filters to extract information in the signal processing stage for seizure detection represents a dramatic innovation.

Methods
This section describes the stages of the proposed method; in Fig. 2 a block diagram is shown. The multichannel EEG records are the input of the adaptive predictive filters which are configured in parallel (section A), then the filtered signals are averaging (section B). Finally, the obtained signal is compared, sample by sample within a threshold which is also calculated sample by sample (section C), when this threshold is overcome the onset of a seizure is detected. Then the algorithm emits a warning of this event.

Adaptive Filters
Adaptive filters are used for many applications and with different configurations. For this work, authors used the predictive filter configuration as shown in Fig. 3. This configuration is used to predict the input signal x(n) after n 0 time at time n + n 0 . The filter calculates the best approximation for a future value of x(n) based on the past data. Then, since the time signals do not change radically from sample to sample, it is possible to locally extrapolate the approximate value of the next sample from the N previous ones.
The predictive filter has a primary input signal d(n), a secondary input signal, corresponding to the delayed signal x'(n) and a linear filter H(z), which produces an output signal y(n), the latter is subtracted from d(n) to calculate the error signal e(n). The objective of an adaptive filter is to adapt the coefficients of the linear filter H(z), and hence its frequency response, to predict the primary signal.
The filter values are constructed by an adaptive process which finds the minimum cost function. These coefficients are adjusted to reduce the square difference between the output and the input as much as possible. When the filter reaches its stationary state, the coefficients of the Wiener filter are obtained. Meanwhile, the values will be modified in time according to the input signal [14].
The implementation of the adaptive filter intends to change the parameters of filter H(z). This will allow the frequency response to be changed and thus the next input of the first signal is predicted.
The adaptive process involves: filtering and adaptation. These processes are carried out through an optimization criterion. The adaptation process causes the adjustment of the filter parameters in order to minimize the error The steepest descent method was used to calculate the minimum error during the development of this work. Due to their natural stability and easy implementation, the FIR filters are suitable for this type of system. All the procedures that intervene in the adaptive filters and their foundations are detailed in [15].

Parallel Predictive Filters
Twenty-two predictive filters working in parallel were used; Fig. 4 shows their configuration. The filter order (L) and the adaptation coefficient (μ) were chosen appropriately so that the filter works without losing stability. The L was chosen as 1024, and the μ = 1 × 10 −10 . One sample is fed into the parallel filters at each n time. The EEG channels are labeled from i = 1 to 22.
The resulting y i (n) signal will be an approximation of the EEG record for a current value of the time series based on the past data of the actual EEG signal. The delay block is 10 s, which means that the current sample y i (n) is computed with the current (d i (n)) and the past EEG signal information (x i '(n)). This process makes it possible to separate relevant frequencies (seizure), from the irrelevant ones (background EEG). The signal y(n) will be an EEG signal which basically contains the seizure, see Fig. 4. Fig. 4 Parallel predictive filter configuration. Where x i (n) is the sample n of the i EEG channel, and the output sample n of each filter will be y i (n) Fig. 5 Example of the processing and detection of seizure in an EEG record segment (patient 5, segment 6). [13]. Red lines indicate the beginning and ending of the seizure in samples (106,752-136,193) Fig. 6 Example of detection of a seizure in an EEG record segment (patient 5, segment 6). CHB-MIT database [13] 1 3

Signal Averaging
The outputs y i (n) are averaged sample to sample among EEG channels. As previously mentioned, the epileptic seizure is reflected almost simultaneously in all EEG channels and consequently, it is possible to emphasize the characteristics of the seizures through channel averaging. The samples are averaged at each time n, resulting in a time series where the energy of the seizure is enhanced while the interictal EEG signal is cancelled or attenuated. The energy of the samples began to increase at the ictal moment. Figure 5 shows an example of this.
Then, the quadratic value of the average is calculated. This sequence is filtered with a low-pass filter for smoothing. As result of this process, a time series ST(n) is obtained. Figures 5 and 6 present an example of the processing of an EEG record segment with an epileptic seizure (Patient 5, segment 6). Figure 5 shows the EEG signals processing according to the diagram of the proposed method (Fig. 2). The first block shows the x i (n) as input signal to the adaptive filter, with red lines indicating the initiation and end of the seizure (only 4 channels are depicted). Then, the time series y i (n) obtained at the output of the predictive filters is observed. The last block exhibits the time series ST(n) obtained as the square value of the average of all y i (n). As result, the seizure is emphasized and the signal in the interictal record is attenuated.

Threshold Detection
In this stage each sample of the previous step is compared, one at a time, with a threshold of amplitude. The threshold is updated at each instant n. It is calculated as the median of a 20 s-length moving window of ST(n) at the moment n. Then, if the current sample exceeds the obtained threshold, the algorithm internally detects the possible onset of a seizure. The following samples are then evaluated; if the threshold overrun is maintained within the next 4 s, then the onset of a seizure is confirmed.
The threshold is empirically taken as 10, 20 and 30 times the median. These three threshold values were tested to compare the performance of the process. Then, in the result section the algorithm performance is evaluated with each one. In this stage, the algorithm does not require any previous training, since the threshold depends on the energy of each EEG record. This represents an advantage. Figure 6 shows an example of this process. Figure 6 displays the ST(n) and the proposed thresholds. Note how the thresholds are also updated sample by sample. In the example shown, the seizure was detected by the three proposed thresholds.

Results
This paper proffers a method to detect epileptic seizures in real time based on adaptive filters and signal averaging. The algorithm was tested on 425 EEG segments of 1 h duration each (99 segments with epileptic seizures).
With the aim of evaluating the performance of the process, some statistical parameters were calculated: true positives (TP), true Negatives (TN), false positives (FP) and false negatives (FN). In addition, the indexes of sensitivity (SEN = 100 × TP/(TP + FN)) and specificity (SPE = 100 × TN/(TN + FP)) were also calculated. These values were computed for each analyzed patient and for each threshold (10, 20 and 30). They are listed in Table 2. Table 2 shows the sensitivity and specificity values for each threshold. The results obtained show that the best relationship between both parameters (sensitivity and specificity) is achieved using 20 times the median of the samples calculated from ST(n). With this threshold average values of 90.29% for SEN and 73.7% for SPE are reached.

Discussion and Conclusions
A method based on parallel adaptive predictive filters, signal averaging and thresholds is proposed to detect seizures in EEG records. The process was applied to 425 EEG segments with 99 epileptic seizures.
Three thresholds were evaluated and calculated as 10, 20 and 30 times the median value of ST(n). The threshold of 20 showed the best relation between SEN and SPE. In this case, these indexes reached average values, across all the patients, of 90.3% and 73.7% respectively. The high SEN value indicates that the algorithm detects almost all the recorded seizures. On the contrary, the proposed system presents many FP detections for some patients, thus the SPE of such patients is low. Therefore, the average SPE reported in Table 2 is highly influenced by these patients. For example, p3 and p4 show an SPE of 41% and 22%, respectively. Excluding both patients from the analysis, the average SPE reaches 80% while the SEN varies just 0.2%. Furthermore, the majority of patients (p1, p5, p8, p12, p13, p16, p17, p18, p20 and p21) reached SPE levels higher than 80%.
The sensitivity and specificity of the algorithm could be improved for each patient according to EEG energy level during seizures and inter-ictal periods just by adjusting the threshold. For example, p4 (SPE = 22%) achieves 38.9% of SPE by using a mere threshold of 30 and holding SEN at 100% (see Table 2).
Rafiuddin et al. worked with parameters obtained from the wavelet transform. They developed a method which includes statistical features such as the interquartile range (IQR) and the mean absolute deviation (MAD). The method was evaluated on the same database used in our work and the results yielded an average accuracy of 96.5% [16]. Nasehi and Pourghassem, obtained a SEN = 98%, training a neural network for each patient [17]. Contrarily, Khan et al. and Kim et al. report SEN = 100%, and SEN = 94%, respectively, proposing patient-specific detectors [18,19]. In a previous study of our group, a patient non-specific method for off-line detection reached SEN = 87.5% and SPE = 99.9 [20].
Numerous clinical applications require the swift and accurate detection of a seizure onset. Although many epileptic seizures can be detected by the physical symptoms of the patients, some of them reveal no visible manifestations (such as tremors or spams) and they should be detected by the appearance of certain features in the EEG. Another important application may be to alert parents, caregivers or physicians of the onset of an epileptic seizure when the patient is alone. In such cases, it is very useful to warn the persons in charge of the patient so they can help him/her. Such warning can be sent by an alarm system or by a cellphone. Nowadays, implementation of this algorithm in a portable system would be relatively easy due to the new technologies developed in the recent years. Some examples include: dry-electrodes, new amplification systems (such as Texas Instruments ADS-1299) and lowconsumption microcomputer systems. When the onset of a seizure is detected an alarm sounds, a text message or both will be generated to alert this situation. Another important application is the automatic drug delivery system, used to avoid or to stop the seizure. By implementing the proposed algorithm this action would be performed "on demand" only when a seizure is in progress.
Due to the simplicity of the mathematical operations, the algorithm is of low computational cost. The data are processed sample to sample while entering the filter and the thresholds are updated in real time using the current and past values of the signal. So real time functioning of the proposed algorithm could be implemented in advanced electronic systems.
Then, it is suitable to develop portable devices that are useful for the aforementioned purposes. The whole system could be easily carried by a person in a band and the electrodes in a cap. It should be noted that people with epilepsy using the device could perform simple daily tasks with some peace of mind, without fear of getting hurt by an unforeseen seizure. In the same sense children could carry the device to school, to their gym/sport classes as well as at home when they sleep in their own beds. Since the system will alert the epileptic seizure onset this gives the patient more peace of mind, comfort and privacy.
The adaptive filters have generally been applied in the preprocessing stage of the EEG signal, with the aim of decreasing the noise components and increasing the signalto-noise ratio. According to the authors, adaptive filters have not been directly applied to the detection of seizures, as has been done in this research project. This turns out to be an important innovation in the use of adaptive filters for seizure detection.
A noteworthy observation is that the performance of the proposed process can be increased using other signal processing or classification methods instead of averaging or a threshold, respectively. For example, neural networks or support vector machine (SVM) can be used for classification. Nevertheless, the implementation of the adaptive filters makes a transformation in the EEG signal by allowing the extraction of new features in the field.
Finally, the proposed method has several strengths, for example: that no training is required due to the automatic adaptation to the threshold to each new EEG record. The algorithm could be implemented in real time. It is simple owing to its low processing time which makes it suitable for the analysis of long-term records and a large number of channels. The system could be implemented on electronic devices for warning purposes (of the seizure onset). It employs methods to process signals that were not used with epileptic seizure detection in EEG, such as in the case of adaptive predictive filters.