## 1. Introduction

Epilepsy is a chronic brain disease of unknown etiology, characterized by the occurrence of unprovoked epileptic seizures, causing brief disturbances in the normal activity of the brain [1]. In the epilepsy diagnosis process the visual analysis of Electroencephalographic signals (EEG) is still widely used by specialists. Its importance in diagnosis is due to the fact that you can get information about the patient's condition, recording the disturbance caused by epileptiform neuronal dysfunction, in the period that the patient is asymptomatic (without seizures) [2]. The EEG can also be used to help define the type of epileptic syndrome, provide information for planning of drug therapy and also to help in deciding the feasibility of surgery [3].The most common elements in EEG signals of epileptic patients and important in the diagnosis of epilepsy are the spikes and sharp waves. The primary morphological difference between these two types of events is the duration that each presents. The spikes have durations between 40 and 80ms. The sharp waves have a duration between 80 and 200ms [3-4].The process of reviewing the records of EEG is performed by trained and experienced specialists. However, this process is still a daunting task. The routine EEG records have durations between 20 and 40 minutes and are recorded from 21 to 32 channels, displayed in screen with 10 to 15 seconds each [3].Few computer systems for automatic review of EEG have practical application. Many of these tend to identify a relatively large number of non-epileptiform events as positive, resulting in little or no effective economy of time [5]. Among the various non-epileptiform paroxysms, which generate more false positives in the automated detection of epileptiform events stand out high frequency noise, the alpha waves and especially the eyelid blinks (Figure 1). These patterns often occur in the EEG signals and they have characteristics similar to spikes and sharp waves being confused with epileptiform events.

The low specificity of automated systems occurs due to variations in the EEG signals from patient to patient. This variation also occurs in the own patient due to different states of consciousness and behavior at the time of acquisition of these signals. Thus, it is difficult to establish a computational model of the epileptiformparoxysms, that can differentiate it from other activities present in the EEG.

The sensitivity of such systems can also be severely compromised by poor quality in the acquisition of an EEG signal. This is due to the large number of existing sources of artifacts. Despite this, most of the proposed automated systems fail to demonstrate they have achieved a rate of false positives per minute (FP / min) acceptable [5].

This work will contribute to the automating process of the epilepsy diagnosis with a digital filter proposal based on Wavelet Transform, checking its feasibility of use to process the EEG signals.

## 2. Material and methods

### 2.1. Bank of EEG signals

The bank of EEG signals is composed by records of 11 patients truly epileptic. The used signals present the following settings: referential montage with Pz as the reference electrode, 32 channels, 512 Hz of sample rate, band limited 0.3-70 Hz and notch filter of 60 Hz to eliminate interferences caused by the power line. For the experiments were selected 600 events between spikes and sharp waves.

### 2.2. Waveletmultiresolution analysis

The analysis in time-frequency domain by Wavelet Transform is performed by taking a Wavelet prototype function called Mother-Wavelet. This Mother-Wavelet suffers dilations and translations, forming the Daughter-Wavelets (1) [6-7].

where *ψ(t)* is the Mother-Wavelet and *ψ*_{a,b} is the Daughter-Wavelet, *a*^{-1/2} is the constant of energy normalization, *b* is the translation factor and *a* is the dilation factor.

The Continuous Wavelet Transform uses continuous parameters of time and scales [6]. Using discrete parameters to *a* and*b* (*a*≥1, *b*≥1) determines the Discrete Wavelet Transform (2).

where *k* and *i* are integers, *b*_{0} and *a*_{0} are the parameters of translation and dilation, respectively.

The Wavelet Multiresolution Analysis is based in the computational implementation of the Discrete Wavelet Transform. The algorithm decomposes a discrete signal using filter banks, [6-8]. The set of filters H[n] extract the average characteristics, defined as approximations of the signal *x* and added to a set of filters G[n] extract the features of high-frequency defined as details of the signal x[n] (Figure 2).

#### 2.2.1. Filtering EEG signals using the denoising method

The denoising method is a resource used in the decomposition process of the Wavelet Transform. This method is used to filter the signal through the manipulation of its coefficients in the Wavelet domain, before the reconstruction of the signal as shown in Figure 3.

Once the full decomposition process was done from a particular Wavelet function it is possible to alter any of the coefficients in the transformed signal before performing the inverse transform (Figure 4).

It can be possible to manipulate the coefficients in a variety of ways depending of the application [7]. For example, it is possible set groups or individual coefficients to zero from a specific scale (Figure 5[a]), increase or reduce the magnitude of them or even to choose some coefficients under or above a specific threshold (λ) and set its values to zero or other value (Figure 5[b]). Performing some of these ways it can be possible to use the Wavelet Transform with a digital filter.Further information see[7-10].To demonstrate the behavior of a signal processed by denoising method was used an event epileptiform decomposed into six levels, generating the levels A6 and D6, D5, D4, D3, D2, D1 (Figure 5[a]). For better visualization the original signals (in black) and the processed signals (in blue) were superimposed, as a way to contrast the changes made between them.In Figure 5[a] is presented the first form of filtering selecting a given level of decomposition. The level A6 was removed from the decomposed signal, setting zero values to the corresponding coefficients (begining of signal to the red mark). Eliminating this level of approximation, the lower frequency of the signal will also be eliminated after its reconstruction. The signal resulting from this process (blue) compared with the original signal (black) shows a reduction of low frequency oscillations, highlighting the peak of the epileptiformevent.In Figure 5[b] is presented the second form of filtering resulting from choice of a particular decision threshold (in this case four standard deviations). Removing the coefficients

between the thresholds (marked in red) and replacing their values by zero, the high frequencies of the signal also change. High frequencies are increasingly attenuated as the threshold increases, making this a low-pass filter. Removing the coefficients that exceed the defined threshold, the low frequencies of the signal will be attenuated, making this process a high-pass filter.The filter proposed here is based on the first form of filtering, where the unnecessary frequencies of the EEG signals are eliminated, manipulating specific decomposition levels of the signal, which will be better explained in the next section.

## 3. Methodology

### 3.1. Proposal for a filter to processing EEG signalsusing the wavelet transform

An interesting feature of the Wavelet Transform, observed through the experiments, is that this tool when used properly has the capability to act as a digital filter. Through Figure 6 can be observed the stages of decomposition and reconstruction of a signal. In this example, the signal is decomposed and reconstructed into 6 levels, generating an approximation level A6 and six levels of detail, D6, D5, D4, D3, D2 and D1. The decomposed signal contains all frequency components of the original signal, grouped by level of decomposition.

When a signal is reconstructed from a specific level of approximation or detail, only the frequencies that covers this level in particular will be used to generate this signal. In other words, we have specific bands of the original signal, fragmented in secondary reconstructed signals (A6, D6, D5, D4, D3, D2 and D1).Performing the sum between the reconstructed signals, the original signal is obtained. On the other hand, performing the difference between them, a signal without especific frequencies is obtained. Based on these considerations a digital filter was designed using the Wavelet Transform for preprocessing the EEG signals, which may be used in the localization and identification process of epileptiform events.

In the initial experiments with the epileptiform events the signals were decomposed and reconstructed into six levels, generating the level of approximation A6 and levels of detail D1 to D6. Each of detail levels was analyzed individually. Some peculiarities were observed as the morphology of the generated signal, the amplitude and repeatability of the detail level that produces the largest number of reconstructed signals, morphologically similar to the original signal. We observed a repeating pattern in the level of detail D4, D5 and D6, which coincide with the frequency band defined for the epileptiform events. The experiments showed that the low frequencies of the original signal were retained in the approximation A6 (0-4 Hz). The frequency range of the original signal, which are not of interest including the frequency of 60 Hz, were retained in detail D1 to D3 (256-32 Hz). These observations suggest that, when performing an addition operation between the reconstructed signals of the details D4, D5 and D6, we obtain a signal free of interference. This has been confirmed later with some experiments. The resulting signal from this process present only the frequencies between 4 and 32 Hz. This band of frequencies include the frequencies of the epileptiform events (from 5 to 25 Hz), so the signal generated has all the frequencies required for proper reconstruction of epileptiform events without the frequencies tha include the noises (Figure 7).

### 3.2. Choice of the wavelet function to use with the proposed filter

In this work the Wavelet Transform is employed as a digital filter. Thus, it was decided to make an inquiry to find the most appropriate Wavelet function for use with the filter, that contain few coefficients, and little distortion of the signal after filtering process.In initial experiments we used the energy of each Wavelet function as a criterion of choice. The function that had the highest average of accumulated energy and a reduced number of coefficients would be the chosen function. The experiment consisted of applying a set of epileptiform events in known Wavelet functions. We used the Wavelet function families: Daubechies, Symlets, Coiflets, Biortogonal and Reverse Biortogonal, totaling 65 functions. The set of signals contains 600 epileptiform events with different durations (Figure 8).

All epileptiform events were applied to each of the Wavelet functions selected for this study. It was calculated energy of each decomposed epileptiform event, which were accumulated and used for obtaining the energy average of each Wavelet function used. For the tests with the proposed filter were chosen 10 functions with the highest cumulative average energy. The values obtained are shown in Table 1.

Wavelet function | Coefficients | Energy [ % ] |

bior3.1 | 4 | 89.57 |

sym14 | 28 | 79.46 |

sym15 | 30 | 79.40 |

sym13 | 26 | 79.34 |

sym12 | 24 | 77.45 |

coif5 | 30 | 76.53 |

rbio3.9 | 20 | 76.49 |

rbio2.8 | 18 | 75.51 |

sym10 | 20 | 75.18 |

sym11 | 22 | 75.16 |

To test the obtained function was used a epoch of EEG signal, containing an epileptiform event, low frequency oscillations, high frequency and noise. This signal was applied in four functions from Table 5 and the filtered signals are presented in Figure 9.

The results showed that the low frequency oscillations and high frequency noise present in the original signal was attenuated, highlighting only the epileptiform events. However, depending on the Wavelet function used the event presents distinct forms due to the characteristics of each Wavelet function. Other experiments were conducted to find the Wavelet function that most preserve the morphology of epileptiform events after processing, but also attenuate satisfactorily the low frequency oscillations and high frequency noise. In order to evaluate these changes between the original signals and the filtered signals were computed the associated error with the alteration in the morphology of the signals processed by the Wavelet filtering through the correlation index and the root mean square error (RMSE) between each original epileptiform event and the filtered ones.

#### 3.2.1. Calculation of correlation and root mean square errors

For this experiment were analyzed the signal epoch of 1s, the epileptiform event (spike and slow-wave complex) and the isolated peak (spike only). These three types of signals are represented by Figure 10.

All of the events selected were applied in each of the Wavelet functions, where were calculated the RMSE and the correlations for each of the categories defined above. Figure 11 presents the procedure performed with the Wavelet functions selected for calculating the RMSE and the correlation between the original signals and the filtered ones. Only for illustrative purposes were used the functions DB4 and RBio2.8, which were identified as the most appropriate functions for the filter proposed.

After calculation of the RMSE and correlations were obtained three other Wavelet functions, which were considered appropriate for use with the proposed filter. These functions are Rbio2.8, Coif4 and DB4. These functions were chosen because they presented the highest values of correlation and the lowest RMSE in all of the experiments carried out by category. Figure 12 presents a demonstration of before and after the filtering, performed for each one of the obtained Wavelet functions. It can be observed that in each graph there is an overlap of the original signals envelopes (backward) and the envelopes of the filtered signals (forward), showing the behavior of each selected Wavelet function for the filter proposed in this paper.

## 4. Results

### 4.1. Evaluation of the selected wavelet functions

This section presents the results obtained with the evaluation of the Wavelet functions best suited for use with the proposed filter. The experiments consisted of applying the set of epileptiform events and calculate the correlations and RMSE between the individual peaks of the original and filtered epileptiform events, between original events and the filtered events and between the original epochs and filtered epochs. The results were grouped into tables, which show the obtained values for each category analyzed.

#### 4.1.1. Results obtained through the calculation of the correlations

Table 2 shows the results of the correlation between the peaks of the original events and the peaks of the filtered events, where the function RBio2.8 had the highest correlation value.

Table 3 shows the obtained values through the calculation of the correlations between the original events and filtered epileptiform events. The function DB4 showed the highest value for average correlation between the original events and the filtered events.

Table 4 presents the values obtained by calculating the average correlation between the epoch of the original signal and the epoch of the filtered signal. Again the function DB4 showed the highest correlation between the original signal and the filtered signal.

Through use of the correlation index as a measure of the distortion of the signals processed morphologies, it was the two Wavelet functions. The function RBio2.8 stood out because it had the highest correlation value in the evaluation of the peaks (spikes) of epileptiform events. The function DB4 obtained the highest values of correlation in the evaluation of the events (spike-wave), and in the evaluation of the epochs.

#### 4.1.2. Results obtained from the RMSE

Table 5 shows the RMSE values calculated between the peaks of the original epileptiform events and the peaks of the filtered epileptiform events. In this experiment the function that had the lowest error value was the function Coif4.

Table 6 presents the RMSE values obtained calculed between the original events (spike-wave) and the filtered events. The Wavelet function that had the lowest error value was the DB4.

Table 7 presents the values obtained with the analysis of the epochs of 1 sec of the original signals and the epochs of 1 sec of the filtered signals. The function that showed the lowest error was the function DB4.

The experiments showed the function DB4 proved to be the best choice for use with the filter, according to the values of correlation and RMSE. This function is indicated when there is the need to maintain the morphology of the whole epoch of the filtered signal. When there is the need to preserve only the peaks of the filtered signal the RBio2.8 and Coif4 are the Wavelet functions more suitable for this task. If is only necessary to attenuate the normal background activity of the EEG, without concern for preserving the morphology of the epoch the Wavelet function Bior3.1 is the most appropriate to do this. Because this particular function have few coefficients, their use in filtering the EEG signals offers superior performance to other functions presented. However, this function shows greater distortion of the signal after filtering than the others. Table 8 shows the values of correlation and RMSE for a epoch of 1 sec.

### 4.2. Evaluation of the proposed filter

In this section will be presented screen of the original EEG signals containing baseline fluctuations, high-frequency noise, low frequency oscillations and epileptiform events. All the signals were filtered using the function Db4.

#### 4.2.1. Experiments with the proposed filter applied in EEG Signals

Figure 13 presents a segment of EEG signal contaminated by muscle artifacts. Can be observed the low frequency fluctuations present in the original signal were attenuated in the filtered signal. The high frequencies generated by the muscles suffer little attenuation in relation to the original signal leaving only frequencies below 32 Hz.

Figure 14 shows a segment of the EEG signal which has large fluctuations of base line. It can be observed that the proposed filter attenuated the baseline oscillations and small oscillations of low frequencies apparent at the beginning of the original signal were also attenuated.

Figure 15 presents a segment of the EEG signal containing high frequency noise and the filtered signal by Wavelet filter.

Figure 16 presents a segment of EEG containing epileptiform events and small low-frequency oscillations. Can be observed that the low-frequency oscillations were attenuated highlighting the epileptiform events.

#### 4.2.2. Experiments with the proposed filter applied in screens of EEG signals

In the previous section have been shown figures containing segments of EEG signals, which were filtered by the proposed filter. This section presents individual screens of EEG signals containing the most different conditions found in the used records. These screens show noise of high and low frequencies, fluctuations of base line and some screens with epileptiform events. The screens were processed with the Wavelet function Db4, which was chosen for the proposed filter.Figure 17 presents a plot of EEG containing large fluctuations of base line. At the top right there is the presence of some epileptiform events, featuring a field of potential.

It can be observed that there was attenuation in the fluctuations of base line and other oscillations present in the original signal, highlighting the epileptiform events (Figure 18).

Figure 19 presents a plot of EEG containing many low-frequency oscillations, as well as high frequency noise.

Through the Figure 20 can be seen that the low frequency oscillations were attenuated, but some frequencies below 32 Hz remained in the processed signal.

The Figure 21 presents a screen containing epileptiform events in two different periods of time. Can be observed small low frequency oscillations in the higher channels that were attenuated.

In Figure 22 can be seen that the epileptiform events are more prominent in EEG signals, due to the fact the filter have attenuated all oscillations that were present in the signal.

Figure 23 presents a screen containing blinks, muscle artifacts, noise and high frequencies, and at the center of the screen some epileptiform events.

In Figure 24 it can be seen that the predominant blinks in the front channels and the muscle artefacts were attenuated and the epileptiform events were highlighted.

The Figure 25 presents a EEG screen contaminated by noise of 60 Hz, eyelid blink, some oscillations and at the center of the screen epileptiform events (black arrow) obviously masked due to noise.

In Figure 26 we can observe that the noise from the power supply has been attenuated, as well as the oscillations and eyelid blinks, showing the epileptiform events that previously did not appear.

## 5. Conclusion

This work presented a study about the capability of the Wavelet Transform to be used to develop a digital filter to attenuate the background activity in the EEG signals. Four Waveletfunctions were select from 65 evaluated.According to the experiments the Wavelet function Db4 proved to be the best function for the development of a digital filter in this application, according to researches performed by [9-12]. The function Db4 is indicated when there is the need to preserve the epoch of the filtered signal more like the original epoch. When there is the need to preserve the peaks of the epileptiform events the adequate function is the Rbio2.8. If the need is only to attenuate the background activity without the concern of preserves the morphology of the peaks in the epileptiform events the adequate function is the Bior3.1. Due to the fact of this function have reduced number of coefficients its application improves performance in filtering process.