Wavelets for EEG Analysis

This chapter introduces the applications of wavelet for Electroencephalogram (EEG) signal analysis. First, the overview of EEG signal is discussed to the recording of raw EEG and widely used frequency bands in EEG studies. The chapter then progresses to discuss the common artefacts that contaminate EEG signal while recording. With a short overview of wavelet analysis techniques, namely; Continues Wavelet Transform (CWT), Discrete Wavelet Transform (DWT), and Wavelet Packet Decomposition (WPD), the chapter demonstrates the richness of CWT over conventional time-frequency analysis technique e.g. Short-Time Fourier Transform. Lastly, artefact removal algorithms based on Independent Component Analysis (ICA) and wavelet are discussed and a comparative analysis is demonstrated. The techniques covered in this chapter show that wavelet analysis is well-suited for EEG signals for describing time-localised event. Due to similar nature, wavelet analysis is also suitable for other biomedical signals such as Electrocardio-gram and Electromyogram.


Introduction
Biomedical signals are electrical activities recorded by sensors from a part of the body, such as the brain, heart, muscles, etc. They can be recorded as images e.g. functional Magnetic resonance Image (fMRI) from brain or a temporal signal e.g. Electrocardiogram (ECG), Electroencephalogram (EEG), Electromyogram (EMG), Galvanic Skin Response (GSR), etc. These signals contain useful information to analyse and understand the underlying physiological response of the body, thus they are also referred to as physiological signals. Biomedical signals are extensively used in healthcare to diagnose deceases and monitor health. With recent advancements and ease of using the devices to record the biomedical signals have open a window to use it to analyse and understand the day-to-day activities, emotions, and, experiences [1][2][3]. While recording the physiological activities through sensors, the signals are usually contaminated by noise and various artefacts [4]. Corrupted signals mislead the analysis and understanding of the underlying physiology [5]. The characteristics of wavelet to identify the time-localised events makes it suitable for the biomedical signals to clean, process, feature extraction, and analyse for various applications. Recent studies have shown the promising results of using wavelet in biomedical signals [6].
In this chapter, first, we introduce one kind of biomedical signal -EEG. We will explain the conventional features used in EEG studies. We will introduce the artefacts that commonly contaminate EEG signals, which makes it harder to use. The chapter then will move towards a short description of Wavelet analysis techniques, namely Continues Wavelet Transform (CWT), Discrete Wavelet Transform (DWT), and Wavelet Packet Decomposition (WPD). We would, then, compare CWT and STFT for EEG signal. Then, we will discuss artefact removal algorithms, with more details on Wavelet-based algorithms. The chapter will show the comparative analysis of artefact removal algorithm. The approach and analysis shown in this chapter for EEG signals can easily be applied to other biological signals.

Electroencephogram -EEG
The brain processes any information by means of neurons that use electrical and chemical signals to communicate by releasing and receiving neurotransmitters. The neural activity in the human brain is an electrical change. The brain generates electrical signals throughout the day for various activities. Studying these electrical signals is vital to understanding the neurophysiological behaviour of the brain [4]. A number of techniques are used to study brain activities. Functional magnetic resonance imaging (fMRI), Functional Near-Infrared Spectroscopy (firs), and Electroencephalography (EEG) recordings widely used techniques. The fMRI measures brain activity by scanning the blood flow. The fNIRS measures brain activity by measuring hemodynamic response in the brain through detecting the temporal changes in infrared light source. The EEG measures the electrical activity of the brain by electrodes placed on the scalp. Comparing to the other two, EEG measures brain activity directly, with high temporal resolution and most accessible and portable for the research. The fMRI has a high spatial resolution but very expensive, therefore it is mostly limited to medical diagnosis and treatments.

The EEG measure
The EEG signal is measured by placing multiple electrodes on the scalp that measure the current flow from neurons. A setup for EEG recording is shown in Figure 1. Each neuron (brain cell), when activated, it produced an electrical and magnetic field around the scalp. Since there are 100 billion neurons in the brain, when an electrode is placed on the scalp, it measures the accumulative activity of many neurons together. The complex structure of the brain attenuates the electrical signals, therefore an electrode can record the brain activity, only when a large number of neurons generate enough potential. The EEG devices amplify the recorded signal to store and process it [4]. The placement of electrodes has been standardised with the specific anatomical landmarks with a distance between electrodes as 10% or 20% of total length. This placement is called the 10-20 system, as shown in Figure 1b. The number of electrodes used for EEG recording varies, depending on the device. One of the low spatial resolutions can be of a 14-channel EEG device and high spatial resolution with 128 or 256 channels. The name of the electrode position is labelled as character followed by a number to identify the part of the brain. The characters are Fop for pre-frontal, F for frontal, P for parietal, T for temporal, O for occipital, and C for central lobe of the brain. A few in between two landmarks are named with two characters, such as AF, between Fp and F and FC, between F and C [4]. An example of 14-channel is shown in Figure 1b.
The raw recording of EEG signal in the time-domain is complex to interpret. Similar to many other signals, frequency domain analysis has been widely used. The decades of work on EEG studies have identified five major frequency bands for EEG signals and established the correlation between behaviour and neural activity of a certain part of the brain. The frequency bands widely used are; Delta (0:1 À 4 Hz or 0:5 À 4 Hz), Theta (4 À 8 Hz), Alpha (8 À 14 Hz), Beta (14 À 30 Hz), Gamma (30 À 63 Hz). A raw EEG signal from a channel and corresponding signal in different bands are shown in Figure 2. It can be observed that low frequency, Delta activity, is the dominating wave in raw EEG and high-frequency Gamma is almost noise like with a little amplitude [4].
Due to multichannel signals, it is usually viewed as topographical brain activity (heatmap over an image of head) under different frequency bands. An example of 5 seconds EEG recording with a 14-channel device is shown in Figure 3. The first second of all the channels are used to compute the energy distribution over brain regions. In Figure 3, the top left shows the raw EEG signal and corresponding brain activity, which shows a high activity in the frontal lobe of the brain. However, under different frequency bands, the different part of the brain shows higher activity.
The frequency bands; Delta, Theta, Alpha, Beta, and Gamma, are also called brain rhythms. Brain rhythms have been investigated over decades and a few characteristic behaviour of these brain rhythms have been established [4]. • Delta: Delta waves were first introduced by Walter in 1936, it ranges from 0.1 (or 0.5) to 4 Hz in frequency. Delta waves are usually observed in deep sleep. Since delta wave is the low-frequency wave, it is easily confused by the movement artefact, due to similar nature. Delta waves have also been linked to continuous attention tasks.
• Theta: Theta waves were introduced by Dovey and Wolter, ranges from 4 to 8 Hz in frequency. Theta waves are linked to drowsiness and deep meditation state.
• Alpha: Alpha waves, perhaps are the most widely investigated waves in EEG studies. Alpha waves were introduced by Berger in 1929. They lie in a range from 8 to 14 Hz. Alpha waves usually appear on the occipital lobe of the brain. Alpha waves are the most common indication of a relaxing state of mind and are also linked to closing eyes. Any sign of anxiety or attention reduces the alpha waves.
• Beta: Beta waves lie in the range of 14-30 Hz of frequency. Beta waves have been associated with active thinking, anxious, high alert, and focus of the brain.
• Gamma: Gamma waves are the higher frequency waves, ranges from 30 to onwards. Gamma wave is considered to play a complex role in brain functionality, such as combining information from two different sensory inputs. It is also used to confirm certain brain diseases.

Artefacts in EEG
While recording, EEG signals are frequently contaminated with various artefacts. The most common types of artefacts are motion, muscular, ocular, and cardiac artefacts [4], which are shown in Figure 4. The motion artefacts are caused by the physical movement of the person's body. As shown in Figure 4a, motion artefacts produce a sudden high valued spike in all the channels of EEG recording. The muscular artefacts, shown in Figure 4b are caused by any muscular contraction such as grinding the teeth. It produces high-frequency bursts in EEG recording as circled in the Figure 4b. The cardiac artefacts, shown in Figure 4c, are caused by the electrical activities of the heart. They appear as a weak form of QRS wave of heart and most likely to be appeared in the channels near to ears (temporal lobe), though it can be sometimes present in channels from the frontal lobe [7]. The ocular artefacts are slow oscillating waves appear on the frontal lobe, caused by the eye movements or closed eyes, as circled in the Figure 4d. The higher magnitude of the artefacts corrupts the EEG recording and leads to misinterpretations of the results and analysis [5]. Even though there are many algorithms to remove the artefacts, but there is always a possibility of losing the cerebral information while removing the artefacts.

Wavelet analysis
Most of the real-life signals are non-stationary in behaviour, which means their properties change over time. To localise the events of interest, time-frequency analysis is widely used. The conventional way of time-frequency analysis is the Short-Time Fourier Transform (STFT), where Fourier transform of the signal is taken over short-windows, resulting spectrogram plot. STFT has limitations on resolutions, due to Heisenberg's uncertainty principle, e.g. improvement in time resolution results in poorer frequency resolution and vice-versa. The alternative to STFT is wavelet transform, which exploits the property of low-frequency signals being widespread over time and high-frequency bursts occurring on short intervals. Wavelet transform uses the variable size of windows with a wavelet function.
Wavelet analysis is usually applied in two ways, Continuous Wavelet Transform (CWT) and Discrete Wavelet Transform (DWT). CWT uses a wavelet function ψ t ð Þ and produces a scalogram, similar to a spectrogram for time-frequency analysis. However, DWT decomposes a signal into two (1) average or lowpass signal, using scaling function and (2) difference or highpass signal using wavelet function. The conventional DWT recursively decomposes lowpass signal with the same scaling and wavelet functions to the desired level of decomposition. A decomposition tree for DWT is shown in Figure 5a. For some applications, it is useful to decompose highpass signal at each level too, this is called Wavelet Packet Decomposition (WPD). A tree for WPD is shown in Figure 5b.
As shown in Figure 5, block LP is a lowpass filter h n ð Þ and block HP is a highpass filter g n ð Þ, both followed by downsampler (↓2). The coefficients of lowpass filter are corresponds to scalling function ϕ n ð Þ and coefficients of highpass filter are corresponds to wavelet funciton ψ n ð Þ. A N-level DWT decomposes a signal x n ð Þ into set of signals: [X N L , X N H , X NÀ1 H , … , X 1 H ], each with different dimensions. However, a N-level WPD decomposes a signal x n ð Þ into set of packets: [X 1 N , X 2 N , … , X 2 N N ], each with same dimensions.

Time-frequency analysis of EEG using CWT
As discussed, a conventional way to time-frequency analysis is STFT, however, using CWT with different wavelet functions can enrich the analysis with more details. In this section, we will show, how a continuous wavelet function (ψ t ð Þ), can be applied to a discrete EEG signal x n ð Þ, and compare the spectrogram with scalogram of different wavelet functions.
A spectrogram is obtained using STFT, which is Fourier Transform computed for a short windows. STFT X stft τ, ω ð Þof signal x t ð Þ as given as Eq. (1), where w t ð Þ is a window function. On the other hand, CWT X cwt a, b ð Þ of a signal x t ð Þ is given by Eq. (2), where ψ * a,b t ð Þ is a complex conjugate of scaled and shifted version of mother wavelet ψ t ð Þ, a is scaling parameter and b is shifting parameter.
CWT operation from Eq. (2) can be seen as convolution of input signal x t ð Þ with scaled version of wavelet function ψ t ð Þ.
where X f ð Þ is Fourier transform of x t ð Þ, and the same for others. For computations with discrete signal x n ð Þ, both equations; 3 and 4 can be used with discrete operations, e.g. convolution and multiplication and discrete wavelet function ψ n ð Þ, while for Fourier Transform, Fast Fourier Transform (FFT) is used. For computational efficiency, however, Eq. (4) is widely used, by multiplying FFT of x n ð Þ and FFT of scaled and discrete version ψ n ð Þ. Even though, for discrete signal x n ð Þ, discrete wavelet function ψ n ð Þ is used, however, the conventional definitions of wavelet functions for CWT are defined in continues time-domain. A set timedomain and frequency-domain equations for six complex wavelet functions are defined below. Figure 6 shows all the six wavelet functions, with their real and imaginary part. All six functions are similar, in terms of smoothness and being derived from exponential and sinusoidal functions, however, they have different parameters to control the oscillation and frequency band to be captured.
Gaussian Wavelet: A time-domain wavelet it derived from a Gaussian function centered at t 0 and modulated by a complex exponential function with frequency f 0 [8].
Poisson Wavelet: Poisson wavelet is defined by positive integers (n), unlike other, and associated with Poisson probability distribution [11,12].
where w ¼ 2πf and u w ð Þ is a unit step function, e.g. u w ð Þ ¼ 1 if w > ¼ 0, 0 else. Complex Mexican hat wavelet: Complex Mexican hat wavelet is derived from the conventional Mexican hat wavelet. It is a low-oscillation wavelet which is modulated by a complex exponential function with frequency f 0 [13].
where w ¼ 2πf and w 0 ¼ 2π f 0 . Complex Shannon wavelet: Complex Shannon wavelet is the most simplified wavelet function, exploiting Sinc function by modulating with sinusoidal, which results in an ideal bandpass filter. Real Shannon wavelet is modulated by only a cos function [14].
where Q x ð Þ ¼ 1 if x ≤ 0:5, 0 else and w ¼ 2πf and w 0 ¼ 2π f 0 . An example of using the above six wavelet functions for a small single-channel EEG segment is shown in Figure 7, along with spectrogram. It can be observed, spectrogram highlights a few events in signal (sharp peaks and lowpass wave), however, using CWT with different Wavelet functions, much richer information can be observed. Since, we observed that in the formulation of wavelet functions that they are similar to the underlying principle, we could also observe the similarities across different scalograms. Specifically, spectrogram using Complex Shannon and Complex Mexican hat wavelet are much similar. Interestingly, Morlate and Poisson wavelet functions are able to produce a better resolution towards lower frequencies.

Artefact removal algorithms using DWT and WPD
Artefacts in EEG recording is a primary obstacle that all researchers have to deal with. There are decades of research work in literature to remove these artefacts [15,16]. A range of methods have been proposed to remove the artefacts, starts with a statistical with interpolation method [17] and regression method [18]. The most commonly used approaches are based on Blind Source Separation (BSS) using Independent Component Analysis (ICA) [19,20]. ICA based approach have been widely explored with statistical measures [21][22][23][24], and variant of ICA as FastICA, InfoMax, and Extended InfoMax [25][26][27]. Wavelet-based approaches are well suited for time-localised short events, as opposed to ICA. This property has been exploited to remove artefacts from single-channel EEG. In contrast to a single channel, wavelet has also been used for multi-channel EEG [28] and in combination with ICA [29][30][31][32][33][34], in which identified artifactual component is cleaned with wavelet rather than removed. The ICA-based approaches can only be applied to multichannel EEG and need an expert to select artifactual component, which has been  [21,35,36]. In contrast, most wavelet-based algorithms remove artefacts from each channel individually.
The key idea of wavelet-based artefact removal algorithms is to apply DWT on single-channel EEG signal x n ð Þ and remove (set to zero) wavelet coefficients that fall above some statistical threshold and reconstruct signal back using inverse-DWT (IDWT)x n ð Þ [37][38][39]. With linear property of electrical activities, recorded EEG signal is considered as x n ð Þ ¼ s n ð Þ þ v n ð Þ, where s n ð Þ is source signal of brain activity and v n ð Þ is artifactual components. The two most widely used threshold formulations are used with wavelet.
Global Threshold: Also known as the optimal threshold for removing whitegaussian noise from any signal [40] using DWT. Global Threshold (T G ) is defined as; (17) where N is the length of signal and for wavelet coefficients w,σ is the estimate of noise variance. To denoise a signal, wavelet coefficients with magnitude below the threshold T G are set to zero and reconstruct the signal back. However, for recorded EEG signal x n ð Þ, source signal s n ð Þ is considered to be zero mean and normally distributed, i.g. s n ð Þ $ N 0, σ ð Þ [4]. For which any wavelet coefficients with a magnitude above the threshold T G is considered to be artifactual and removed (set to zero).
Standard Deviation (STD) Threshold: As name suggests, STD threshold is based on Standard Deviation (STD) of wavelet coefficients [39].
ATAR algorithm: A recent study has shown that approaches based on above thresholds are very aggressive, since, statistically, a few wavelet coefficients of any signal will always fall above these thresholds [14]. In contrast, an Automatic and Tunable Artefact Removal (ATAR) Algorithm based on WPD was proposed [41], which provides three different wavelet filtering modes and a tunable parameter. As shown a block diagram of ATAR algorithm in Figure 8, a single channel EEG signal x n ð Þ is first split into smaller windows x w n ð Þ, apply L-level WPD to get wavelet coefficients w ¼ X L k ð Þ ¼ WPD x w n ð Þ ð Þ, then wavelet coefficients are filtered using wavelet filteringŵ ¼ λ w ð Þ to reconstruct signalx n ð Þ from corrected windowsx w n ð Þ. The three filtering modes in ATAR algorithm are namely; Elimination λ e Á ð Þ, Linear attenuation λ a Á ð Þ, and soft thresholding λ s Á ð Þ, which are defined below; where w is a wavelet coefficient, sgn Á ð Þ is the signum function, and θ α > θ γ . A default setting for θ γ and θ β is; θ γ ¼ 0:8θ α and θ β ¼ 2θ α . The characteristics of wavelet filtering mode are shown in Figure 9. From Figure 9, it can be seen that Elimination mode of filtering is the same as conventional filtering, however, Linear attenuation and soft-thresholding modes do not remove the wavelet coefficient, rather suppress them softly. Another distinction ATAR algorithm has over others is the threshold selection. The threshold θ α is computed from Interquartile Range (IQR) of wavelet coefficients using Eq. (22), which is robust against outliers, as oppose to STD.
where r is Interquartile Range (IQR) of coefficients i.e. r ¼ IQR w ð Þ and k 1 and k 2 are lower and upper bounds on filtering. Figure 10 shows a visual comparative analysis of wavelet-based approaches (i.e. Global threshold, STD threshold, and ATAR algorithm) and ICA based approaches (FastICA, InfoMax, and Extended-InfoMax) to remove the artefacts. It is visually apparent that wavelet-based approaches are better than ICA-based approaches.
Among wavelet-based approaches, using ATAR gives much control over Global and STD based threshold selection. Other quantitative analyses of the above-mentioned approaches are discussed in the article [41], which also demonstrate the effect of tuning parameter and filtering modes on different predictive tasks of EEG signal. The formulation of relationship, algorithmic implementation details, and comparative results are given in article [41].

Conclusions
This chapter presents the overview of Wavelet for EEG analysis. The first chapter introduces EEG signal, commonly used features for predictive analysis, and artefacts that often contaminate EEG signal. Then chapter discusses the Wavelet analysis approaches, namely CWT, DWT, and WPD. The richness of CWT over STFT for time-frequency analysis using various wavelet functions is demonstrated. Finally, the artefact removal algorithms based on wavelet and ICA are discussed. The comparative analysis present in the chapter shows that the wavelet-based approach outperforms ICA based approach. Specifically, a recent algorithm (ATAR) allows controlling the removal or suppression of assumed artifactual components in the signal, which can be tuned to improve the performance of any predictive tasks. The techniques presented in this chapter show how wavelet can be used for EEG studies to extract rich information and removing the artefacts. The comparative analysis shows wavelet based approaches are well suited for EEG signal processing. Further, similar approaches can be used with other biomedical signals such as electrocardiogram (ECG or EKG), Electromyography (EMG) etc.