International Journal of Electronics Engineering, 3 (1), 2011, pp.
5– 10
EEG Signal Preprocessing using Wavelet Transform
Arun S. Chavan1 and Mahesh Kolte2
1
Vidyalankar Institute of Technology, Wadala, Mumbai-400 037.
2
Shree Chhatrapati Shavaji Maharaj College of Engineering, Pune.
E-mail: arunschavan@[Link]
Abstract: The purpose of the study was to investigate the feasibility of using wavelet transform as a preprocessor for EEG
spikes detection system. The study aimed at decreasing the information content of the signal without degrading the detection
performance. Since routine clinical EEG requires recording from many channels (generally 32 to 44), input size becomes a
critical design parameter for real – time multichannel spike detection systems.
The Short Time Fourier Transform (STFT) is used for time analysis of non-stationary signals like EEG, because it
frequency analysis of signals on a routine basis. The STFT provides an alternative to the classical Short-Time Fourier
has some drawbacks, such as bandwidth can be arbitraly Transform (STFT) or Gabor transform. The basic difference
small, and increasing the resolution in time decreases the is, in contrast to the STFT, which uses a single analysis
resolution in frequency and vice versa. Another characteristic window, the Wavelet Transform (WT) uses short windows
of the STFT is its fixed time-frequency resolution. Once a at high frequencies and long windows at lower frequencies.
time window has been chosen, the time-frequency resolution This is similar to “Constant Q” or Conastant relative
remains the same for all the frequencies in the time-frequency bandwidth frequency analysis.[6]
plane. [6] For some applications WT can be seen as signal
We proposed to use wavelet transform to overcome decomposition onto a set of basis functions. Basis functions
some of the short comings of the STFT by performing a called Wavelets are obtained by a single prototype wavelet
multiresolution analysis of signals. In the wavelet transform, by dilation and contraction (Scaling) as well as shifts. The
high frequency components are analyzed with a sharp time prototype wavelet can be thought of as a band pass filter,
resolution than low frequency components. This is a and the constant Q property of the other bandpass filter
desirable property, especially in analyzing fast transient (Wavelets) follows because they are scaled version of
waveforms such as EEG spikes. [6] prototype. [6]
The wavelet transform is used to represent essential Therefore, in a WT, the notion of the scale is introduced
characteristics of EEG spikes and spike wave(SSW) complex as an alternative to frequency leading to time scale
with few coefficients. Since spikes contain high frequency representation. It means that a signal is mapped into a
energy, they will be represented in particular scale localized time-scale plane as compared to the time frequency plane
in a small time window. The wave portion of the spike wave used in the STFT. [6]
complex will be represented in a lower scale of WT, covering
wider span of time. Thus with the proper selection of WT Non Stationary Signal Analysis
scales and time spans a fewer number of WT coefficients The aim of signal analysis is to extract relative information
may be used to represent the SSW complexes. [6] from a signal by transforming it. Perhaps the most well known
In order to reduce the false detection, we can extend the tool for transforming is Fourier transform analysis, which
contextual information by referring to other signals such as breaks down a signal into constituent sinusoids of different
EOG for information about eye movements, EMG frequencies. Another way to think of it as a mathematical
(ElectroMyoGram) for information about muscle electrical technique for transforming view of signal from a time based
activity. With this it is possible to reduce greatly the false one to frequency-based one[4]
detection of sharp transients due to artifacts. [3] For a signal x(t), Fourier transform is given as,
+∞
1. WAVELETTRANSFORM
∫ X (t ) e
– j 2 ft
X( f ) = dt
Wavelet theory provides a unified framework for a number –∞
of techniques developed for various signal-processing As it is clear from above equation, analysis coefficients
applications. Particularly, it is of immerse interest for the x(f) can be computed as inner products of the signal with
6 International Journal of Electronics Engineering
sinewave basis functions of infinite duration. As a result, of the signal at a time, a technique called windowing the
Fourier analysis works well if x(t) is composed of a few signal. Gabor’s adaptation called the Short – Time Fourier
stationary components (e.g. sinewaves). However, any Transform (STFT), maps a signal into a two dimensional
abrupt change in time in a non-stationary signal x(t) is spread function of time and frequency. [6]
out over the whole frequency axis in x(f). Most interesting Consider a signal x(t). Assuming that it is stationary
signals contain numerous non-stationary or transitory when seen through a window g(t) of limited extents, centered
characteristics as drift, trends, abrupt changes and beginning at time location T, the Fourier Transform of the windowed
and end of events. These characteristics are often the most signals x(t) g(t – T) yields the Short-time Fourier Transform
important part of signal, and Fourier analysis is not suited to
+∞
detecting them. [6]
∫ X (t ) g (t – T ) e
– j 2 ft
STFT (T, f) = dt
The usual approach is to introduce time dependency in –∞
the Fourier analysis while preserving linearity. The idea is to
introduce a “local frequency” parameter (local in time) so The STFT represents a sort of compromised between
that the “local” Fourier transform looks at the signal through the time and frequency based views of a signal. It provides
a window over which the signal is approximately stationary. some information about both, when and at what frequencies
Another, equivalent way is to modify the sine wave basis a signal event occurs. However one can only obtain this
function used in the Fourier transform to basis functions information with limited precision, and that precision is
which are more concentrated in time (but less concentrated determined by the size of the window. [6]
in frequency). [6] An alternative view is based on a filter bank
interpretation of the same process. At a given frequency
Short-Time Fourier Analysis f, equation above amounts to filtering the signal “at all times”
In an effort to correct the deficiency, Dennis Gabor (1946) with a bandpass filter having the window function modulated
adopted the Fourier transform to analyze only a small section to that frequency as impulse response, Thus the STFT may
be seen as modulated filter bank. [6]
Fig. 1: (a) Standard Time Domain Basis, (b) Standard Frequency Domain Basis.
Fig. 2: Time Frequency Plane Corresponding to Short Time Fourier Transform
EEG Signal Preprocessing using Wavelet Transform 7
Fig. 3: Time Frequency Resolution of the Short Time Fourier Transform and Wavelet Transform
Heisenberg Inequality Multiresolution Analysis
From the dual interpretation of equation for STFT, exists a Anyone who would like to use STFT is faced with this
drawback related to the time and frequency resolution. For a problem of resolution. What kind of windows to use? Narrow
window function g(t) and its Fourier transform G(f), the windows give good time resolution, but poor frequency
‘bandwidth ‘∆f of the filter is defined as resolution; wide windows may violate the condition of
stationary.
∫ f G( f ) df
2 2
One Alternative to overcome this resolution limitation
∆f =
of STFT is by letting the resolution ∆t and ∆f vary in the
∫ G( f ) df
2
time- frequency plane in order to obtain a multi resolution
Where the denominator is the energy of g(t). Two analysis. That is when the analysis is viewed as a filter bank;
sinusoidals will be discriminated only if they are more than the time resolution must increase with the central frequency
∆f apart. Thus the resolution in the frequency of STFT of the analysis filters. To make this happen, the ∆f should be
analysis is given by ∆f. Similarly the spread in time is given made proportional to f or ∆f / f = c; where c is a constant.
by ∆t as The analysis filter bank is then composed of bandpass
filters with constant relative bandwidth (constant Q analysis).
∫ t G(t ) dt
2 2
When above equation is satisfied, ∆f and therefore also ∆t
∆t 2 =
∫ G( f ) dt
2
changes with center frequency of analysis window. of
course, they still satisfy the Heisenberg inequality, but now,
Where the denominator is the energy of g(t). Two pulses the time resolution becomes arbitrary good at high
in time can be discriminated only if they are more than ∆t frequencies, while the frequency resolution becomes
apart. arbitrary good at low frequencies. For example, two very
Resolution in time and frequency cannot be arbitrary close short bursts can always be eventually separated in the
small, because their product is lower bounded. analysis by going up to higher analysis frequencies in order
Time-Bandwidth Product = ∆t * ∆f ≥ 1/4π to increase time resolution. This kind of analysis works best
if the signal is composed of high frequency component of
This is referred to as the uncertainty principle, or
short duration plus low frequency component of long
Heisenberg inequality. It means that one can only trade time
duration, which is often the case with the biomedical signals
resolution for frequency resolution or vise versa. That is
like EEG.
one cannot know that exact time-frequency representation
of a signal or one can not know what spectral components
exist at what instances of time. What one can know are the
time intervals in which certain band of frequencies exists.
More important is that once a window has been chosen
for the STFT, then the time – frequency resolution given by
equation for ∆t & ∆f is fixed over the entire time frequency
plane (since the same window is used at all frequencies).
Suppose if the signal is composed of small bursts associated
with long quasi – stationary components like spikes and
slow – wave complex in epilleptform EEG activity, then each
type of component can be analyzed with good time resolution
Fig. 4: Wave and Wavelet
or frequency resolution, but not both.
8 International Journal of Electronics Engineering
Wavelet Transform location of the wavelets is known directly from the
The wavelet transform of a sigmoid x(t) is defined as position of the output Wavelet coefficients.
[5] The Fourier transform has equal time and frequency
1 +∞ resolution for all the components. Wavelet
∫ x (t ) h ((t – T ) / a)e
– j 2 πft
WTX(T, a) = dt
a –∞ decomposition has a large time aperture, but closely
spaced frequency resolution for slow components;
1 +∞ and small time aperture but broad frequency resolution
∫ x ( at ) h (t – (T / a))e
– j 2 πft
WTX(T, a) = dt for fast components.
a –∞
In WT, analysis of a signal is carried out by the use of a 2. METHODOLOGY
special function, h(t), called the mother wavelet. This function The methodology followed in the study is summarized below.
is translated in time for selecting that part of the signal to be It consists of three sequentially performed procedures.
analyzed. The portion of the signal selected is then expanded • Data Selection
or contracted using a scale parameter, a, which is analogous
• Waveform Transformation
to frequency. For small values of a, the wavelet is a narrow
function of the original function, which corresponds roughly • Data Compression
to higher frequencies. For very large values of a, the wavelets • Signal Reconstruction
are expanded and correspond to low frequency. In the WT, The EEG data used in the study in this study was
high frequency components are analyzed with the sharper obtained from Nasan Medical Electronics pvt. Ltd., Pune.
time resolution than low frequency components. This is The data was available in binary file format with 12 bit
desirable properly, especially in analyzing fast transient resolution and the sampling frequency of 250 samples per
waveforms such as EEG spikes. [6] second. It was then preprocessed to separate the 20-channel
The functions WTX (T, a) is the projection of signal waveform and stored in a separate file for subsequent
onto the wavelet shifted by T and scaled by a, and hence transformation with wavelets.
indicates the contribution of wavelet to the signal. Thus,
such a transformation does not lead to time-frequency Data Selection
representation but instead, to, time – scale decomposition in The EEG is broken down into sections, or epochs, for the
which scales are related to frequency. purpose of wavelet transform. An epoch of 2.0485 sec. is
used for following reasons:
Advantages of Wavelet Transform
(1) It is long enough to capture the main statistical
[1] The Fourier transform represents a signal as characteristics of the EEG and short enough to capture
combination of scaled and phase shifted sinusoids. the evolution of seizures.
Wavelet decomposition represents a signal as a
combination of scaled wavelets; the mother wavelet (2) To detect the seizures as soon as possible, a short
shape selected depends on the application. epoch length may increase the chance of early
detection.
[2] The Discrete Fourier transform assumes that the signal
is periodic and in the case of non – periodic signals (3) The EEG being digitized at a sampling rate of 250 Hz,
complex techniques must be used to estimate the an epoch of 2.0485 contains 512 samples, a convenient
Fourier components without misrepresentation. length to complete wavelet Transform.
Wavelets decomposition is naturally amenable to Wavelets transforming of 512 data points produced eight
represent non- periodic functions. resolution scales consisting of 256, 128, 64, ……………..2
[3] The wavelet expansion allows a more accurate local data points. Scale 1 represented the highest frequency region
description and separation of signal characteristics. with 256 points. The next scale presented the next lower
A Fourier coefficient represents a component that last frequency region with half the number of the data points
for all time and therefore, temporary events must be and so on. Since the seizure can be characterized to have a
described by a phase characteristics that allows theta (4 – 7.75HZ) and beta (16 to 25Hz) dominate
cancellation or reinforcement over large time periods. monofrequency at the beginning, which rapidly evolves to a
A wavelet expansion coefficient represent a dominant alpha monofrequency for the rest of the seizure.,
component that is itself local and is easier to represent. the scale corresponding to the alpha(8 – 13 Hz) is selected.
Three types of mother Wavelets used; db1 (or Haar) wavelets
[4] The Fourier transform acts on a block of data
& db-4. Daubechies wavelets were found to be ideally suited
simultaneously, therefore, information about the
for detection of spike/spike and wave (SSW) activity due to
location of different components within the block is
their compact support.
not available. In wavelet decomposition the time
EEG Signal Preprocessing using Wavelet Transform 9
Waveform Transformation detection system. The study aimed at decreasing the
Wavelet transformation is done using db-1 & db-4 wavelets information content of the signal without degrading the
producing eight resolution scales. The wavelet coefficients detection performance. Since routine clinical EEG requires
for different channels are stored in an array, which then are recording from many channels (generally 32 to 44), input
used for wave reconstruction and compression. size becomes a critical design parameter for real – time
multichannel spike detection systems.
Data Compression
The results of the study now that the use of the WT
Data compression is done by setting different threshold drastically decrease the input size, without much compromise
levels. The basic idea is to ignore the samples which are not
in performance. The most important factor in performance,
contributing for the study of different characteristics of EEG.
Software is developed for decompression & to reconstruct however, was the proper selection of the scale. Scale 4
the wave form after compression. Since it is also necessary performed the best for the Haar as well as Daubechies
to know the amount of energy restored after compression, Wavelets indicating that it contained most content of the
the software is accordingly modified to calculate and display relevant information for detection. [2]
the amount of energy restored. Out of two wavelets analyzed namely Haar (Daub-1),
Daub-4, it was found that Daub-4 gives good results.
Signal Reconstruction Daubechies Wavelets were found suitable for analysis due to
Signal is reconstructed after compression. The original and the compact support and their similarity with the SSW wave.
reconstructed signals are displayed simultaneously for
comparison. The reconstructed signal is displayed with Programs are developed to display the sample waveform
compression ratio and amount of energy restored. for different channels, for decomposition of the waveform
using DB-1 & DB-4 as well as for the display of original,
3. RESULTSAND CONCLUSION denoised and compressed waveforms for each channel.
The purpose of the study was to investigate the feasibility In the following figures the sample waveforms for
of using wavelet transform as a preprocessor for EEG spikes channel-2 are shown.
Fig. 5: Waveform for Channel No-2
Fig. 6: The Wavelet Decomposition for Channel-2 Using DB-1 Wavelets
10 International Journal of Electronics Engineering
Fig. 7: The Wavelet Decomposition for Channel-2 Using DB-4 Wavelets
Fig. 8: The Original, Reconstructed, Compressed & Denoised EEG Signal for Channel-2 with 10 % Threshold Level.
4. FUTURE SCOPE In order to replicate the reasoning of EEGer, the expert
In order to reduce the false detection. we can extend the system provided with the knowledge of spatial context may
contextual information by referring to other signals such as be designed.
EOG( Electro culogram) for information about eye movements, Finally, the system must be evaluated by comparing its
EMG(Electro myogram) for information about performance after applying it to large number of abnormal
electrocardiography activity. With this it is possible to reduce cases, including normal cases with visual scoring by EEGer.
greatly the false detection of sharp transients due to artifacts.
For more reliable detection of epilepsy , number of clinical REFERENCES
and pathological information such as age, sex , body [1] Hou qu, Jean Gotmon, “A Patient–Specific Algorithm for
temperature , pulse rate , body sugar etc. and behavioral the Detection of Seizure Onset in Long–Term EEG
status of patient like co-operative or non co-operative , Monitoring : Possible Use as a Warning Device”, IEEE Trans,
Introvert or extrovert , right handed or left handed etc. and Biomed, Engng BME – 44(2) 115-122,1997.
different EEG recording with photic stimulations, [2] Gotman jn Ives I, Gloor P, “Frequency Content of EEG and
hyperventilation may be used. EMG at Seizure Onset. – Possibility of Removal of EMG
Artifact by Digital Filtering”, Electroenceph Clin
Although in this study, the accuracy of Daub-4 found
Neurophusiol 52:626 – 639, 1981.
to be satisfactory, other type of wavelets such as morlets
wavelet or spline wavelets need to be analyzed. Designing [3] Tulga kalayci, Ozcan Ozdamar, “Wavelet Preprocessing for
the mother wavelet that matches the shape of frequency Automated Neural Network Detection of EEG Spikes”,
IEEE Engineering in Medicine and Biology 160-166, March/
characteristics of Spike and Spike Wave (SSW) events may
april1995.
also offer higher accuracy. These possibilities are open for
future studies. [4] Rioulo, Vitterli M, “Wavelets and Signal Processing”, IEEE
SP Magazine 14- 38 , October 1991.
The method was implemented and tested off-line.
However, this can be further extended for on-line [5] Fernando Lopes da Silva, “EEG Analysis: Theory and
Practice”,
implementation by taking into account memory management
and computational load. [6] Raghuveer R. Bapordikar A, “Wavelet Transforms –
Introduction to Theory and Applications”, Addis on –
This method can be further extended with ANN to Wesley, 2000.
classify the EEG into normal or abnormal depending upon
[7] [Link], “Medical Electronics”, Indiansociety for Technical
its frequency distribution. It can be extended to further
Education, Exel books, First Edition: New Delhi, 2003.
classify the abnormalities.