**3.1. Proposal for a filter to processing EEG signals using 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).


**Figure 6.** Process of decomposition and reconstruction of a signal.

**3. Methodology** 

epileptiform events.

frequencies tha include the noises (Figure 7).

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.

frequency components of the original signal, grouped by level of decomposition.

**3.1. Proposal for a filter to processing EEG signals using 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

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

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

**Figure 7.** Proposal for a Wavelet filter using only the details of the decomposed signal. This filter is proposed performing an addition operation between levels of detail to obtain a signal free from interference, like the baseline and low frequency oscillations, as well as high frequency interference, including the 60 Hz noise

#### **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).

Wavelet Filter to Attenuate the Background Activity and

High Frequencies in EEG Signals Applied in the Automatic Identification of Epileptiform Events 89

**Figure 9.** Examples of Wavelet filtering with some functions from table 5.

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

most appropriate functions for the filter proposed.

represented by Figure 10.

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.

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

**Figure 10.** Representation of the categories defined for the analysis of the Wavelet functions.

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

**Figure 8.** Representation of the selected events for the choice of the Wavelet function to be used in the filtering of signals.

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.


**Table 1.** Visualization of 10 Wavelet functions with highest energy values and their respective number of coefficients for the epileptiform events used.

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.

Wavelet Filter to Attenuate the Background Activity and High Frequencies in EEG Signals Applied in the Automatic Identification of Epileptiform Events 89

**Figure 9.** Examples of Wavelet filtering with some functions from table 5.

88 Practical Applications in Biomedical Engineering

filtering of signals.

The values obtained are shown in Table 1.

of coefficients for the epileptiform events used.

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).

**Figure 8.** Representation of the selected events for the choice of the Wavelet function to be used in the

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.

**Table 1.** Visualization of 10 Wavelet functions with highest energy values and their respective number

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.

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

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.

**Figure 10.** Representation of the categories defined for the analysis of the Wavelet functions.

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.

Wavelet Filter to Attenuate the Background Activity and

High Frequencies in EEG Signals Applied in the Automatic Identification of Epileptiform Events 91

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 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

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

Wavelet function Coefficients Energy [%] Correlation between the peaks

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.

this paper.

**4. Results** 

value.

**4.1. Evaluation of the selected wavelet functions** 

tables, which show the obtained values for each category analyzed.

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

rbio2.8 18 75.51 0.985988 coif2 12 63.90 0.985208 rbio2.6 14 70.53 0.984620 bior2.8 18 68.32 0.984608 bior2.6 14 64.56 0.984165 rbio6.8 18 73.29 0.984156 bior6.8 18 73.47 0.983519 sym8 16 71.83 0.982686 sym6 12 67.04 0.982597 sym4 8 59.07 0.982411 **Table 2.** Correlation between the peaks of the original events and the filtered events.

**Figure 11.** Analysis representation of the epochs of 1s signal and the event peak.

**Figure 12.** Demonstration of the Wavelet filter with the four obtained Wavelet functions, showing all epileptiform events after processing with the filter, contrasting with the original signals in the background.

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.
