Biomédica
Desarrollo de una aplicación de análisis de señales de EEG a través de una convolución de una ondícula Morlet compleja: resultados preliminares.
Development of an EEG signal analysis application through a convolution of a complex Morlet wavelet: preliminary results
Desarrollo de una aplicación de análisis de señales de EEG a través de una convolución de una ondícula Morlet compleja: resultados preliminares.
ReCIBE. Revista electrónica de Computación, Informática, Biomédica y Electrónica, vol. 8, núm. 2, pp. 1-19, 2019
Universidad de Guadalajara

Recepción: 07 Junio 2019
Aprobación: 20 Junio 2019
Resumen: Este trabajo presenta una nueva aplicación para el análisis de señales de electroencefalograma (EEG). Las señales se prefiltran a través de la herramienta EEGLAB de MATLAB. La aplicación creada genera una convolución entre la señal original del EEG y una ondícula Morlet compleja. Como resultado final, la aplicación muestra el valor de potencia de la señal y un espectrograma de la señal medida. Además, la aplicación creada compara diferentes canales de EEG al mismo tiempo, de forma rápida y sencilla, a través de un análisis de tiempo y frecuencia. Finalmente, se demostró la efectividad de la aplicación creada al realizar un análisis de las señales alfa de sujetos sanos, una señal creada por el sujeto con los ojos cerrados y la otra, con la que se comparó, fue creada por el mismo sujeto con los ojos abiertos. Esto también sirvió para demostrar que la potencia de la banda alfa de la señal de ojos cerrados es mayor que la potencia de la señal de ojos abiertos.
Palabras clave: Aplicación, Ondícula, Electroencefalograma, Señal, Análisis.
Abstract: This paper presents a new application for analyzing electroencephalogram (EEG) signals. The signals are pre-filtered through MATLAB's EEGLAB tool. The created application performs a convolution between the original EEG signal and a complex Morlet wavelet. As a final result, the application shows the signal power value and a spectrogram of the convoluted signal. Moreover, the created application compares different EEG channels at the same time, in a fast and straightforward way, through a time and frequency analysis. Finally, the effectiveness of the created application was demonstrated by performing an analysis of the alpha signals of healthy subjects, one signal created by the subject with eyes closed and the other, with which it was compared, was created by the same subject with eyes open. This also served to demonstrate that the power of the alpha band of the closed-eyed signal is higher than the power of the open-eyed signal.
Keywords: Application, Wavelet, Electroencephalogram, Signal, Analysis.
Abstract: Este trabajo presenta una nueva aplicación para el análisis de señales de electroencefalograma (EEG). Las señales se prefiltran a través de la herramienta EEGLAB de MATLAB. La aplicación creada genera una convolución entre la señal original del EEG y una ondícula Morlet compleja. Como resultado final, la aplicación muestra el valor de potencia de la señal y un espectrograma de la señal medida. Además, la aplicación creada compara diferentes canales de EEG al mismo tiempo, de forma rápida y sencilla, a través de un análisis de tiempo y frecuencia. Finalmente, se demostró la efectividad de la aplicación creada al realizar un análisis de las señales alfa de sujetos sanos, una señal creada por el sujeto con los ojos cerrados y la otra, con la que se comparó, fue creada por el mismo sujeto con los ojos abiertos. Esto también sirvió para demostrar que la potencia de la banda alfa de la señal de ojos cerrados es mayor que la potencia de la señal de ojos abiertos.
Keywords: Application, Wavelet, Electroencephalogram, Signal, Analysis.
1 Introduction
The analysis of EEG signals has become one of the most critical methods for obtaining information regarding abnormal conditions or diseases in humans, e.g., epilepsy (Adeli, Zhou, & Dadmehr, 2003), Alzheimer (Alberdi, Aztiria, & Basarab, 2016; Liu et al., 2017), and attention deficit hyperactivity disorder (Mann, Lubar, Zimmerman, Miller, & Muenchen, 1991), to name only some of them. This analysis has been achieved by obtaining the most essential neuronal information provided by brain dynamics, obtained through electrical signals produced by the brain (Omidvarnia et al., 2017). These signals have been classified into different frequency waves (delta, theta, alpha, beta, gamma) that when they present notable changes it is possible to define if the person presents some type of abnormal condition, for example, some people with Alzheimer's disease have had altered channel synchronization, loss of complexity, a slowing of frequency and synchrony or correlation between EEG signals of the different parts of the brain is reduced, which may be indicative of brain degeneration (Alberdi et al., 2016; Ieracitano, Mammone, Bramanti, Hussain, & Morabito, 2019).
In order to study and classify the characteristics of EEG signals, different mathematical algorithms have been used such as fast Fourier transform (FFT), discrete wavelet transform, autoregressive (AR) model and entropy (Zhang, Liu, Ji, & Huang, 2016), multivariate multi-scale sample entropy, support vector machines (SVM), intrinsic mode functions (IMFs) (Bhattacharyya, Pachori, & Acharya, 2017), principal component analysis (Mann et al., 1991), mentioning some of them. Of all these methods, wave transforms was selected, because without discarding any of the aforementioned, wave transforms can provide high precision of the main characteristics of EEG signals in time and frequency (Adeli et al., 2003). Moreover, it allows an analysis within a specific frequency range; because of its properties, it can decompose the original signal in its different frequency sub-bands. This method was also selected because it is possible to create a spectrogram from the waveform and obtain information by visual inspection of the signal (Adeli et al., 2003).
Within the literature analyzed to carry out this study, there has not been found an application similar to the one created, that performs an EEG signal analysis using a Morlet Wavelet Transform, in a fast and straightforward way, providing a visual (spectrogram) and numerical response. Little information was found in the literature about a quick and easy way, for analyzing and generating a spectrogram of an EEG signal. Therefore, in this paper, an application that develops an analysis by performing a convolution is presented (Fig. 1). The left command window has a button at the top to upload a .mat file, also has a panel to insert the parameters of the wavelet within which are the number of cycles and an option to select the frequency band to analyze. In addition, the user is allowed to indicate the dataset number and the EEG channel number that will be analyzed. Finally, on the same left command window the button to start the analysis is found. The graphical spaces A1 and A2 show the spectrograms of the first channel, meanwhile spaces B1 and B2 show the spectrograms of the second channel. The comparison between both channels on the rank frequencies from 0 to 40 Hz can be seen in the right side figures. The panels on the left (1) show the zoom of a frequency band from each panel on the right (2), respectively.
The original signal and the complex Morlet wavelet are convoluted to generate the spectrogram of an EEG signal. Also, the created application calculates the power of each frequency band of the EEG signal to provide more accurate results.

Main application interface created with MATLAB. The left command window has a button at the top to upload a file, a panel to insert the parameters of the wavelet and a button to start the analysis. The graphical spaces A1 and A2 show the spectrogram of the first channel. Spaces B1 and B2 show the spectrogram of the second channel.
2 Methods
Signal pre-processing
Because the program does not filter the data, the data must be previously filtered with the EEGLAB toolbox provided by MATLAB or another filter (Fig. 2). For this study, the power of the alpha band (8 - 14 Hz (Lobier, Palva, & Palva, 2017)) will be analyzed, therefore a high-pass filter at 0.5 Hz is useful and recommended to minimize slow drifts (X Cohen, 2014), and 40 as the edge of the low-pass filter can help to remove high-frequency artifacts (X Cohen, 2014), it will also help to attenuate electrical line noise that occurs at 60 Hz in Mexico and 50 Hz in Europe produced by the power supply current. EEGLAB works with the created application, saving the most relevant information of the EEG signals that will be used to run the application. For example, the location of the electrodes must be saved with the number of each one, not just with the letter (e.g., Fz) in order that the application will know the number of the channel to analyze.

A) the Fast Fourier Transform of the unfiltered Pz channel signal, B) EEG signal but after applying a 0.5 to 40 Hz filter.
Algorithm
This program performs a convolution between EEG signals and a Complex Morlet Wavelet (Fig. 3), an algorithm described in (X Cohen, 2014).

Flowchart of the interchangeability of convolution in the time domain and frequency domain multiplication. The signals resulting from the processes shown within the blue box are the same, as are the signals resulting from the processes within the red box (X Cohen, 2014); using a shorter computation time the cycle on the right side of the flow chart.
The convolution method was chosen together with a wavelet transform, since the FFT method does not allow to visualize an analysis based on the time domain, whereas with the wavelet cycles a decomposition of the data in the frequency domain, in the time domain or both, can be performed (Pattnaik, Dash, & Sabut, 2016; X Cohen, 2014). Due to the limitations that the wavelets present as a band-pass filter, it was necessary to use a complex Morlet wavelet described in (X Cohen, 2014), which is created by multiplying, point by point, a Gaussian window and a complex sine wave:

with A being a frequency band-specific scaling factor, e a constant called Euler's number, t is time, i is the imaginary operator (X Cohen, 2014), f is frequency (Hz) and s is the standard deviation of the Gaussian:

where n is the number of wavelet cycles.
Also, this wavelet will serve to extract power information from the EEG data (X Cohen, 2014). Furthermore, the result of convolution in the time domain can be represented by a multiplication between two vectors in the frequency domain. To achieve this, the FFT of the original signal and the CMW (kernel) is calculated separately. Finally, both resulting FFT signals are multiplied and the IFFT of the convoluted signal is calculated:

or this study, multiplication in the frequency domain was chosen because it reduces the computing time (X Cohen, 2014) of MATLAB. It is important to mention that the created application uses automatically the frames per epoch and the trials of each dataset to execute the convolution, so the result will be the same as the length of the kernel plus the length of the original signal minus one, as stated in (X Cohen, 2014).
After convolution, the real part of the final signal is introduced into a matrix, and a filled contour plot is created with the isolines of the final signal power values. In which it will be observed in the axis of the ordinate the range of the frequency bands, from 1 up to 40 Hz; in the axis of the abscissa, it will be appreciated the time, that in this case are milliseconds.
Database
An EEG motor movement database (Schalk, Mcfarland, Hinterberger, Birbaumer, & Wolpaw, 2004) was used for evaluating the performance of the application. The used database consists of one hundred nine subjects performed different experiments, including opening and closing the fists of the hands, both physically and imaginatively, in order to distinguish these movements through the EEG signals (Goldberger et al., 2000). These signals were taken from an EEG of 64 channels, placed on the scalp according to the 10-20 international system and, each signal was sampled at 160 samples per second. The BCI2000 system was used to acquire the signals, developed and tested in (Schalk et al., 2004), which incorporates any brain signals, signal processing methods, output devices, and operating protocols. However, for this study, only the two baselines of the study were taken into account, which were created by the subject keeping eyes closed (without motor movement) for one minute and the other baseline keeping eyes open, for one minute as well.
Moreover, at a later stage, different analyses will be performed taking into account the potentials evoked due to imaginary movements, as well as the analysis of other mental states, in order to validate the application and demonstrate that it can be used as part of a multimodal system in order to find unique biomarkers that serve for the early diagnosis of different diseases such as Alzheimer's, autism, tumours, etc (Alberdi et al., 2016; Siuly & Zhang, 2016).
3 Results
The created application compares different EEG channels at the same time, in a fast and straightforward way, through a time and frequency analysis. The baselines of the EEG database were selected with the idea of demonstrating that the alpha waves have a higher power when the subject has closed eyes than when the subject has open eyes, this following the established in different previous studies (Butler & Glass, 1974; Kan, Croarkin, Phang, & Lee, 2017; Morgan, Mcdonald, & Macdonald, 1971; Teplan, 2002; Valipour, Shaligram, & Kulkarni, 2013). Moreover, the PZ (51), CZ (11), FZ (34), and O2 (63) electrodes were selected, because they are commonly used since they have given significant results (Hussain et al., 2017; Rushby et al., 2016; Wyckoff, Sherlin, Ford, & Dalke, 2015) in terms of the power of the alpha band. Just to demonstrate the functionality of the application, 3 random subjects were taken into consideration to verify that the power of the alpha band is greater when moving the electrode from the front to the parietal lobe (Valipour et al., 2013).
The created application asks the user to select the necessary characteristics for the analysis of EEG signals, i.e.: dataset number, channel number, number of wavelet cycles, the time range to be displayed on the plot (the application generates the analysis using the full-time range, not just the one selected by the user). Also, the colormap can be selected: Parula o Jet. Both colormaps have been proposed because colormaps in which their brightness function is linear, such as Parula (the default since MATLAB version R2014b), are still subject to usability problems (Helfman, 2015). However, the aim is for future researchers to be able to test both colormaps and have more reliable results. By the other hand, it is important to declare that the total number of wavelet frequencies used in the created application is 40, in a range from 0.5 to 40 Hz, since the frequencies of interest are within this range and the wave frequencies cannot be above the Nyquist frequency (half the sampling frequency) (X Cohen, 2014). The created application uses the sampling rate (Hz) of each dataset to select the center of the wavelets as a zero.
Figure 4 shows the Pz (51) channel spectrograms after having performed an analysis using seven cycles for the wavelet and selecting a time from 0 to 1000 ms to display on the plot. Dataset number 1 was defined by the baseline with the eyes closed, while the number 2 was created while the eyes were kept open, both datasets belong to the test subject number 1. The color limits for these graphics are set by the range values of the frequency band selected by the user (see Figure 4). Therefore, the areas with the highest power within the same frequency band can be identified.

Analysis of channel Pz (51). Time range selected to display from 0 to 1000 ms. Both spectrograms at the top belong to the dataset of subject 1 with closed eyes. The two spectrograms at the bottom belong to the dataset of subject 1 with open eyes. On the left, it can be seen the drop-down menu with the six frequency bands which are selectable for different analyses.
Figure 5 shows the results of the Cz (11) channel analysis. For this analysis, the full-time range of the signal (60000 ms) was selected to be displayed on the plot. It can be seen that the dataset with closed eyes has the power of the alpha band higher than that of open eyes. However, in the lower part of the section where the user specifies the characteristics for analysis, the application provides a result with the value of the power of the band that the user has previously selected, in this case, the values shown belong to the alpha band.

Analysis of channel Cz (11). Time range selected to display from 0 to 60000 ms. Both spectrograms at the top belong to the dataset of subject 1 with closed eyes. The two spectrograms at the bottom belong to the dataset of subject 1 with open eyes.
Figure 6 shows the spectrograms of channel Fz (34). Again it is observed that the dataset with closed eyes (1) has higher power than the dataset with open eyes (2). For this analysis, seven cycles were also used for the wavelet and the results from 20000 to 40000 ms were shown. Also, the colormap jet was selected only as a demonstration object for the reader's knowledge.

Analysis of channel Fz (34). Time range selected to display from 20000 to 40000 ms. Both spectrograms at the top belong to the dataset of subject 1 with closed eyes. The two spectrograms at the bottom belong to the dataset of subject 1 with open eyes.
Figure 7 shows another of the capabilities of the created application, which is to compare four channels at the same time. In this case, the channels O2 (63), PZ (51), CZ (11), and FZ (34) were compared. It can be seen from each of the spectrograms that the power is more significant as we move closer to the electrodes at the back of the brain, following the conclusions stipulated in [14]. Also, to have a more precise response, the application created shows the total value of the power of the EEG band previously selected for each of the analyzed channels (uV).

Analysis of O2 (top left), Pz (top right), Cz (bottom left), and Fz (bottom right) channels. Time range selected to display from 45000 to 60000 ms. Frequency range from 8 to 14 (alpha wave).
The number of cycles of the wavelet can be changed and defined every time before the analysis performed by the application. Figure 8 presents an analysis performed on the O2 (63) channel, increasing the cycles for the wavelet to demonstrate the differences produced by these cycles in each analysis. In order to achieve better temporal precision using fewer cycles (e.g., 3), or if greater frequency precision is required more cycles can be selected (e.g., 10). Finally, an average analysis can be performed by selecting an intermediate number of cycles (e.g., 7).

Analysis of channel O2 (63). Time range selected to display from 20000 to 30000 ms. Different numbers of wavelets cycles selected: 3 (top left), 7 (top right), 10 (bottom left), and 13 (bottom right).
Figure 9 shows how the created application can enlarge the spectrograms for more accurate analysis. Also, it is possible to observe each of the curves of the power bands created after convolution (Fig. 10), taking into account only the values provided by the band selected in the drop-down menu. Finally, if the user wishes to observe the original signal, the application allows this by selecting one of the last options from the bottom panel on the left side of the application (Fig. 11).

A) Maximization of the spectrogram of the frequency band selected (alpha) of the first channel.

B) Maximization of the spectrogram of all frequencies of the first channel.

Signal created after convolution, taking into account only the values present within the range of the frequency band selected by the user.

Original EEG signal from channel O2 (63).
4 Conclusions
A new application was described in this paper, which performs a convolution between the signals of an EEG and a complex Morlet wavelet, an algorithm described in (X Cohen, 2014). In addition, the application shows the spectrogram of each EEG signal and is able to calculate the power of each frequency band of the EEG signal. The created application allows the user to select the basic characteristics needed for an EEG signal analysis and to select the EEG channel number, in order to compare different EEG channels at the same time.
Compliance with Ethical Standards
Conflict of interest The authors declare that they have no conflict of interest.
Author biography
José Humberto Trueba Perdomo is a Master student in the Department of Electronics, Technological Institute of Orizaba, Mexico. His research interests include pain analysis through biometric signals.
Ignacio Herrera Aguilar is the Director of the Signal Processing Laboratory at the Technological Institute of Orizaba, Mexico. He has a PhD in Automatic Systems and a MSc in Electronic Engineering.He specializes in Control and Automation of robots and mechanisms that can be used in the industry, as well as in motor rehabilitation systems for human beings.
Francesca Gaspariniis an associate professor at the University of Milano Bicocca (Italy). She is head of the Multimedia Signal Processing Laboratory. Her research activity is concentrated in multimedia signal processing. She is particularly interested in processing and analysis of neurophysiological data as well as psychophysical ones, using machine learning techniques, genetic programming and optimization algorithms.
5 References
Adeli, H., Zhou, Z., & Dadmehr, N. (2003). Analysis of EEG records in an epileptic patient using wavelet transform. Journal of Neuroscience Methods, 123(1), 69–87. https://doi.org/https://doi.org/10.1016/S0165-0270(02)00340-0
Alberdi, A., Aztiria, A., & Basarab, A. (2016). On the early diagnosis of Alzheimer ’ s Disease from multimodal signals : A survey. Artificial Intelligence In Medicine, 71, 1–29. https://doi.org/10.1016/j.artmed.2016.06.003
Bhattacharyya, A., Pachori, R. B., & Acharya, U. R. (2017). Tunable-Q wavelet transform based multivariate sub-band fuzzy entropy with application to focal EEG signal analysis. Entropy, 19(3), 99. https://doi.org/10.3390/e19030099
Butler, S. R., & Glass, A. (1974). Asymmetries in the electroencephalogram associated with cerebral dominance. Electroencephalography and Clinical Neurophysiology, 36, 481–491. https://doi.org/https://doi.org/10.1016/0013-4694(74)90205-3
Goldberger, A., Amaral, L., Glass, L., Hausdorff, J., Ivanov, Pc., Mark, R., … Stanley, H. (2000). PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource for Complex Physiologic Signals. Circulation, 101(23), 215–220. https://doi.org/https://doi.org/10.1161/01.CIR.101.23.e215
Helfman, J. (2015). Hue tinting for interactive data visualization. Human Vision and Electronic Imaging XX. Society of Photo-Optical Instrumentation Engineers (SPIE), 9394, 1–12. https://doi.org/10.1117/12.2079543
Hussain, L., Aziz, W., Alowibdi, J. S., Habib, N., Rafique, M., Saeed, S., & Kazmi, S. Z. H. (2017). Symbolic time series analysis of electroencephalographic (EEG) epileptic seizure and brain dynamics with eye-open and eye-closed subjects during resting states. 36(21), 1–12. https://doi.org/10.1186/s40101-017-0136-8
Ieracitano, C., Mammone, N., Bramanti, A., Hussain, A., & Morabito, F. C. (2019). A convolutional neural network approach for classification of dementia stages based on 2D-spectral representation of EEG recordings. Neurocomputing, 323, 96–107. https://doi.org/10.1016/j.neucom.2018.09.071
Kan, D. P. X., Croarkin, P. E., Phang, C. K., & Lee, P. F. (2017). EEG differences between eyes-closed and eyes-open conditions at the resting stage for euthymic participants. Neurophysiology, 49(6), 432–440. https://doi.org/10.1007/s11062-018-9706-6
Liu, J., Li, M., Pan, Y., Lan, W., Zheng, R., Wu, F., & Wang, J. (2017). Complex brain network analysis and its applications to brain disorders : A survey. Complexity, 2017, 1–27.
Lobier, M., Palva, J. M., & Palva, S. (2017). High-alpha band synchronization across frontal, parietal and visual cortex mediates behavioral and neuronal effects of visuospatial attention. NeuroImage, 165, 222–237. https://doi.org/10.1016/j.neuroimage.2017.10.044
Mann, C. A., Lubar, J. F., Zimmerman, A. W., Miller, C. A., & Muenchen, R. A. (1991). Quantitative analysis of EEG in boys with attention-deficit-hyperactivity disorder : Controlled study with clinical implications. Pediatric Neurology, 8(1), 30–36. https://doi.org/https://doi.org/10.1016/0887-8994(92)90049-5
Morgan, A. H., Mcdonald, P. J., & Macdonald, H. (1971). Differences in bilateral alpha activity as a function of experimental task, with a note on lateral eye movements and hypnotizability. Neuropsychologia, 9(4), 459–469. https://doi.org/https://doi.org/10.1016/0028-3932(71)90011-X
Omidvarnia, A., Pedersen, M., Vaughan, D. N., Walz, J. M., Abbott, D. F., Zalesky, A., & Jackson, G. D. (2017). Dynamic coupling between fMRI local connectivity and interictal EEG in focal epilepsy : A wavelet analysis approach. Human Brain Mapping, 38(11), 5356–5374. https://doi.org/10.1002/hbm.23723
Pattnaik, S., Dash, M., & Sabut, S. K. (2016). DWT-based feature extraction and classification for motor imaginary EEG signals. Proceedings of 2016 International Conference on Systems in Medicine and Biology, (January), 186–191. https://doi.org/10.1109/ICSMB.2016.7915118
Rushby, J. A., Mcdonald, S., Fisher, A. C., Kornfeld, E. J., Blasio, F. M. De, Parks, N., & Piguet, O. (2016). Brain volume loss contributes to arousal and empathy dysregulation following severe traumatic brain injury. NeuroImage: Clinical, 12, 607–614. https://doi.org/10.1016/j.nicl.2016.09.017
Schalk, G., Mcfarland, D. J., Hinterberger, T., Birbaumer, N., & Wolpaw, J. R. (2004). BCI2000 : A General-Purpose Brain-Computer Interface ( BCI ) System. IEEE Transactions on Biomedical Engineering, 51(6), 1034–1043. https://doi.org/10.1109/TBME.2004.827072
Siuly, S., & Zhang, Y. (2016). Medical big data : neurological diseases diagnosis through medical data analysis. Data Science and Engineering, 1(2), 54–64. https://doi.org/10.1007/s41019-016-0011-3
Teplan, M. (2002). Fundamentals of EEG measurement. Measurement Science Review, 2(2), 1–11.
Valipour, S., Shaligram, A. D., & Kulkarni, G. R. (2013). Spectral analysis of EEG signal for detection of alpha rhythm with open and closed eyes. International Journal of Engineering and Innovative Technology (IJEIT), 3(6), 1–4.
Wyckoff, S. N., Sherlin, L. H., Ford, N. L., & Dalke, D. (2015). Validation of a wireless dry electrode system for electroencephalography. Journal of NeuroEngineering and Rehabilitation, 12(1), 1–9. https://doi.org/10.1186/s12984-015-0089-2
X Cohen, M. (2014). Analyzing neural time series data: Theory and practice. London, UK: The MIT Press.
Zhang, Y., Liu, B., Ji, X., & Huang, D. (2016). Classification of EEG signals based on autoregressive model and wavelet packet decomposition. Neural Process Lett, 45(2), 365–378. https://doi.org/10.1007/s11063-016-9530-1