SlideShare a Scribd company logo
Spectral analysis and Filtering in
EEG : Ways to go wrong
Narayan Subramaniyam
Dept. Of Neuroscience and Biomedical Engineering
Aalto University
Motivation for filtering
●
Removing low voltage changes (e.g. skin potentials,
electrode impedance drifts, etc) and line noise.
●
Antialiasing – Attenuation of frequencies higher than
1 / 2 of the sampling rate.
●
Preprocessing : filter out slow frequencies (< 0.1 Hz )
and/or high frequencies (>40 Hz).
Figure source : Cheveigné and Nelken 2019
Types of filters - I
Figure source : Cheveigné and Nelken 2019
How filtering affects your data
●
Amplitude attenuation
Figure source : Luck 2005
How filtering affects your data ?
●
Shape distortion due to sharper cut-off
Low pass filtering
High pass filtering
Figure source : Luck 2005
How filtering affects your data
●
Perils of high pass filtering
Figure source : Acunzo et al. 2012
Basic theory
●
A filter basically is a Linear Time Invariant (LTI)
system
●
An LTI obeys
– Superposition
– Time invariance
Basic theory
●
Knowing the impulse response is enough to know
everything about the LTI system
●
Impulse response (h) is the systems output when the
input is an impulse
●
By convolutuion of the input signal x to the impulse
response (filter coefficients) h, we get the filter output.
●
Convolution = series of multiplication followed by sum
of products
What is convolution ?
Figure source : Lyons 2004
Types of filters - II
Finite Impulse Response Infinite Impulse Response
Figure source : Lyons 2004
Types of filters - II
●
Finite impulse response
– Produces finite length output to an impulse
– Equal delays at all frequencies (linear phase)
●
Infinite impulse response
– Produces output for infinite duration to an impulse
– Achieved by feeding part of output to the input
– Unequal delays at different frequencies and unstable
– Typically not used in EEG pre-processing
Types of filters - III
●
Causal filters
– Output of filter depends on past and present inputs.
●
Non-causal filters
– Output depends on both past and future inputs.
– Achieved by filtering the data forward and backward.
– Offline filtering
– Can cause smearing effects back in time
Figure source : Cheveigné and Nelken 2019
How filtering affects your data
●
Causal or acausal ?
Figure source : Acunzo et al. 2012
Know your defaults!
●
EEGLAB uses a zero phase acausal FIR filter
as a default (it uses the filtfilt() function in
MATLAB).
●
FieldTrip uses a Butterworth filter (IIR) as
default.
●
MNE python uses acausal FIR filter as default.
The same EEG data can be distorted in different
ways if you filter them across pacakages using
default setting!
Some recommendations
●
High-pass filtering more problematic than low-
pass filtering
●
Avoid (offline) high-pass filtering if possible.
●
If not, lower values in the range of 0.01-0.05 is
preferred. Higher cut-off may distort the data.
●
Prefer FIR (zero phase) acausal filter unless
interested in earliest moment of effect.
Conclusions
●
Filters are a form of controlled distortion. Use
sparingly
●
Good looking data is not good data.
●
When publishing, report your filter settings in
detail (causal or acausal, zero or minimum
phase etc)
Power spectral density
●
Power spectral density (PSD) estimation a
fundamental tool in EEG analysis that utilizes
Fourier transform (FT).
●
Gives information about the power in each
frequency component
How to compute PSD?
●
Estimating PSD with fast Fourier Transform (FFT)
algorithm (fft() in MATLAB )
●
FFT computes the discrete-time Fourier transform (DFT) of
a signal in an efficient way.
●
PSD is then estimated by squaring the magnitude of DFT
●
FFT requires the number of DFT points N, which
determines the frequency resolution.
●
In practice, N is set to the power of 2 that is next above the
length of the signal (ex: length of signall is 1000, then N is
1024 = 2^10).
Example
●
20 seconds (4097) EEG data from one channel.
eyes closed.
Figure source : https://sapienlabs.co/factors-that-impact-power-spectrum-density-estimation/
Figure source : https://sapienlabs.co/factors-that-impact-power-spectrum-density-estimation/
How to compute PSD ? - The Welch
method
●
Results from FFT computation are noisy, jagged
and hard to interpret.
●
Welch’s method is routinely used to compute
PSD from EEG data
●
The idea is to divide the data into (overlapping)
windows and compute FFT for each window.
●
PSD is the average of FFTs over these
windows.
Parameters for Welch’s method
●
Window length (w)
●
Number of FFT points (N)
●
Percentage of window overlap (noverlap)
●
Choice of windowing function (to get continuous
waveform without sharp transitions)
Effect of window size
●
0.25 sec window (~2 cycles of alpha) gives poor
freq. Resolution (wide lobe between 5 – 15 Hz)
Figure source : https://sapienlabs.co/factors-that-impact-power-spectrum-density-estimation/
Effect of % of overlap
Figure source : https://sapienlabs.co/factors-that-impact-power-spectrum-density-estimation/
Windowing function
●
Hamming window is commonly used as it has
lower spectral leakage
Figure source : https://en.wikipedia.org/wiki/Window_function
Frequency bands
●
PSD is analyzed by slicing it into a small
number of frequency “bands”.
Figure source : https://sapienlabs.co/eyes-open-eyes-closed-and-variability-in-the-eeg/
Our brain is not a sinusoidal
generator!
●
Basic assumption in applying FT : The EEG can
be broken down to bunch of sinusoids
●
Many EEG signals display nonsinusoidal
features.
●
Non sinusoidal signals contains multiple
frequencies and these end up showing as
harmonics when using Fourier transform
Examples of non-sinusoidal EEG
Figure source : Cole et al. 2017
Conclusions
●
By using Welch method one can obtain smoother PSD
●
Choosing very short windows to compute PSD can lead to poor results
(esp. for analyzing lower frequencies)
●
Longer windows can result in finer resolution of PSD, but can lead to
noisy PSD
●
The number of DFT points (N) should always be greater than or equal to
the length of your data or window
●
Highly overlapping windows does not guarantee smoother PSD. (due to
correlation between the windows).
●
Many EEG signals are non-sinusoidal and violate FT assumption.
●
Look at the whole PSD and not just the ‘band’ as band definitions are
arbitrary and somewhat inconsistent across studies!

More Related Content

PDF
Timer And Counter in 8051 Microcontroller
PPTX
Ic 555 timer as astable
DOCX
EC6612 VLSI Design Lab Manual
PPT
Amplificateur opérationnel
PDF
TP Les bascules - logique combinatoire
PPTX
Microcontroller 8051 and its interfacing
PDF
Session 2,3 FPGAs
Timer And Counter in 8051 Microcontroller
Ic 555 timer as astable
EC6612 VLSI Design Lab Manual
Amplificateur opérationnel
TP Les bascules - logique combinatoire
Microcontroller 8051 and its interfacing
Session 2,3 FPGAs

What's hot (20)

PPTX
Registers siso, sipo
PPTX
I/O port programming in 8051
PDF
Cours strm mme_touil_all
DOCX
Timing analysis
PPTX
Dynamic Voltage and Frequency Scaling
PDF
Fstm deust mip-e141_cee_chap_iii_régime sinusoidal
PPTX
Astable multivibrator
PDF
Writing Cadence Ocean scripts
PPTX
DRCs.pptx
PPTX
1 ph semi converter (r-l load)
PPTX
Powerplanning
PPTX
ATPG flow chart
PPT
Introduction To Filters.ppt
PDF
Practical Differential Fault Attack on AES
PPTX
8086 Interrupts & With DOS and BIOS by vijay
PDF
Chapter 5 introduction to VHDL
PPTX
8251 USART
PDF
Chapitre II : Transformateurs
PDF
Amplification Bipolaire
PPTX
Advanced Pipelining in ARM Processors.pptx
Registers siso, sipo
I/O port programming in 8051
Cours strm mme_touil_all
Timing analysis
Dynamic Voltage and Frequency Scaling
Fstm deust mip-e141_cee_chap_iii_régime sinusoidal
Astable multivibrator
Writing Cadence Ocean scripts
DRCs.pptx
1 ph semi converter (r-l load)
Powerplanning
ATPG flow chart
Introduction To Filters.ppt
Practical Differential Fault Attack on AES
8086 Interrupts & With DOS and BIOS by vijay
Chapter 5 introduction to VHDL
8251 USART
Chapitre II : Transformateurs
Amplification Bipolaire
Advanced Pipelining in ARM Processors.pptx
Ad

Similar to Spectral analysis and filtering (20)

PDF
AnalysisofEEGsignal_for_education___.pdf
PPTX
Neural signal processing by mustafa rasheed & zeena saadon & walaa kahtan 2015
PDF
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
PPTX
Medical dsp
PDF
FPGA Implementation of Accelerated Finite Impulse Response Filter for EEG Ana...
PDF
Denoising Techniques for EEG Signals: A Review
PDF
5. detection and separation of eeg artifacts using wavelet transform nov 11, ...
PDF
I365358
PPTX
Removal of artifacts in EEG by averaging and
PPT
analysingeeg datausing matlab.ppt
PDF
Denoising of EEG Signals for Analysis of Brain Disorders: A Review
PPT
EEG_circuit.ppt
PPT
EEG_circut.ppt
PDF
Performance Comparison of Known ICA Algorithms to a Wavelet-ICA Merger
PDF
Z4101154159
PDF
A New Approach to Denoising EEG Signals - Merger of Translation Invariant Wav...
PPTX
Analysing EEG data using MATLAB
PDF
40120130405007
PDF
Eyeblink artefact removal from eeg using independent
PPTX
EEG course.pptx
AnalysisofEEGsignal_for_education___.pdf
Neural signal processing by mustafa rasheed & zeena saadon & walaa kahtan 2015
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
Medical dsp
FPGA Implementation of Accelerated Finite Impulse Response Filter for EEG Ana...
Denoising Techniques for EEG Signals: A Review
5. detection and separation of eeg artifacts using wavelet transform nov 11, ...
I365358
Removal of artifacts in EEG by averaging and
analysingeeg datausing matlab.ppt
Denoising of EEG Signals for Analysis of Brain Disorders: A Review
EEG_circuit.ppt
EEG_circut.ppt
Performance Comparison of Known ICA Algorithms to a Wavelet-ICA Merger
Z4101154159
A New Approach to Denoising EEG Signals - Merger of Translation Invariant Wav...
Analysing EEG data using MATLAB
40120130405007
Eyeblink artefact removal from eeg using independent
EEG course.pptx
Ad

Recently uploaded (20)

PPTX
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
PPTX
Microbiology with diagram medical studies .pptx
PPTX
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
PPTX
INTRODUCTION TO EVS | Concept of sustainability
PDF
Placing the Near-Earth Object Impact Probability in Context
PPTX
famous lake in india and its disturibution and importance
PDF
HPLC-PPT.docx high performance liquid chromatography
PPTX
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
PDF
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
PPT
protein biochemistry.ppt for university classes
PPTX
Taita Taveta Laboratory Technician Workshop Presentation.pptx
PPT
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
PDF
Biophysics 2.pdffffffffffffffffffffffffff
PPTX
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
DOCX
Viruses (History, structure and composition, classification, Bacteriophage Re...
PDF
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
PDF
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
PPTX
Classification Systems_TAXONOMY_SCIENCE8.pptx
PPTX
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
PDF
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
Microbiology with diagram medical studies .pptx
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
INTRODUCTION TO EVS | Concept of sustainability
Placing the Near-Earth Object Impact Probability in Context
famous lake in india and its disturibution and importance
HPLC-PPT.docx high performance liquid chromatography
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
protein biochemistry.ppt for university classes
Taita Taveta Laboratory Technician Workshop Presentation.pptx
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
Biophysics 2.pdffffffffffffffffffffffffff
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
Viruses (History, structure and composition, classification, Bacteriophage Re...
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
Classification Systems_TAXONOMY_SCIENCE8.pptx
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...

Spectral analysis and filtering

  • 1. Spectral analysis and Filtering in EEG : Ways to go wrong Narayan Subramaniyam Dept. Of Neuroscience and Biomedical Engineering Aalto University
  • 2. Motivation for filtering ● Removing low voltage changes (e.g. skin potentials, electrode impedance drifts, etc) and line noise. ● Antialiasing – Attenuation of frequencies higher than 1 / 2 of the sampling rate. ● Preprocessing : filter out slow frequencies (< 0.1 Hz ) and/or high frequencies (>40 Hz). Figure source : Cheveigné and Nelken 2019
  • 3. Types of filters - I Figure source : Cheveigné and Nelken 2019
  • 4. How filtering affects your data ● Amplitude attenuation Figure source : Luck 2005
  • 5. How filtering affects your data ? ● Shape distortion due to sharper cut-off Low pass filtering High pass filtering Figure source : Luck 2005
  • 6. How filtering affects your data ● Perils of high pass filtering Figure source : Acunzo et al. 2012
  • 7. Basic theory ● A filter basically is a Linear Time Invariant (LTI) system ● An LTI obeys – Superposition – Time invariance
  • 8. Basic theory ● Knowing the impulse response is enough to know everything about the LTI system ● Impulse response (h) is the systems output when the input is an impulse ● By convolutuion of the input signal x to the impulse response (filter coefficients) h, we get the filter output. ● Convolution = series of multiplication followed by sum of products
  • 9. What is convolution ? Figure source : Lyons 2004
  • 10. Types of filters - II Finite Impulse Response Infinite Impulse Response Figure source : Lyons 2004
  • 11. Types of filters - II ● Finite impulse response – Produces finite length output to an impulse – Equal delays at all frequencies (linear phase) ● Infinite impulse response – Produces output for infinite duration to an impulse – Achieved by feeding part of output to the input – Unequal delays at different frequencies and unstable – Typically not used in EEG pre-processing
  • 12. Types of filters - III ● Causal filters – Output of filter depends on past and present inputs. ● Non-causal filters – Output depends on both past and future inputs. – Achieved by filtering the data forward and backward. – Offline filtering – Can cause smearing effects back in time Figure source : Cheveigné and Nelken 2019
  • 13. How filtering affects your data ● Causal or acausal ? Figure source : Acunzo et al. 2012
  • 14. Know your defaults! ● EEGLAB uses a zero phase acausal FIR filter as a default (it uses the filtfilt() function in MATLAB). ● FieldTrip uses a Butterworth filter (IIR) as default. ● MNE python uses acausal FIR filter as default. The same EEG data can be distorted in different ways if you filter them across pacakages using default setting!
  • 15. Some recommendations ● High-pass filtering more problematic than low- pass filtering ● Avoid (offline) high-pass filtering if possible. ● If not, lower values in the range of 0.01-0.05 is preferred. Higher cut-off may distort the data. ● Prefer FIR (zero phase) acausal filter unless interested in earliest moment of effect.
  • 16. Conclusions ● Filters are a form of controlled distortion. Use sparingly ● Good looking data is not good data. ● When publishing, report your filter settings in detail (causal or acausal, zero or minimum phase etc)
  • 17. Power spectral density ● Power spectral density (PSD) estimation a fundamental tool in EEG analysis that utilizes Fourier transform (FT). ● Gives information about the power in each frequency component
  • 18. How to compute PSD? ● Estimating PSD with fast Fourier Transform (FFT) algorithm (fft() in MATLAB ) ● FFT computes the discrete-time Fourier transform (DFT) of a signal in an efficient way. ● PSD is then estimated by squaring the magnitude of DFT ● FFT requires the number of DFT points N, which determines the frequency resolution. ● In practice, N is set to the power of 2 that is next above the length of the signal (ex: length of signall is 1000, then N is 1024 = 2^10).
  • 19. Example ● 20 seconds (4097) EEG data from one channel. eyes closed. Figure source : https://sapienlabs.co/factors-that-impact-power-spectrum-density-estimation/
  • 20. Figure source : https://sapienlabs.co/factors-that-impact-power-spectrum-density-estimation/
  • 21. How to compute PSD ? - The Welch method ● Results from FFT computation are noisy, jagged and hard to interpret. ● Welch’s method is routinely used to compute PSD from EEG data ● The idea is to divide the data into (overlapping) windows and compute FFT for each window. ● PSD is the average of FFTs over these windows.
  • 22. Parameters for Welch’s method ● Window length (w) ● Number of FFT points (N) ● Percentage of window overlap (noverlap) ● Choice of windowing function (to get continuous waveform without sharp transitions)
  • 23. Effect of window size ● 0.25 sec window (~2 cycles of alpha) gives poor freq. Resolution (wide lobe between 5 – 15 Hz) Figure source : https://sapienlabs.co/factors-that-impact-power-spectrum-density-estimation/
  • 24. Effect of % of overlap Figure source : https://sapienlabs.co/factors-that-impact-power-spectrum-density-estimation/
  • 25. Windowing function ● Hamming window is commonly used as it has lower spectral leakage Figure source : https://en.wikipedia.org/wiki/Window_function
  • 26. Frequency bands ● PSD is analyzed by slicing it into a small number of frequency “bands”. Figure source : https://sapienlabs.co/eyes-open-eyes-closed-and-variability-in-the-eeg/
  • 27. Our brain is not a sinusoidal generator! ● Basic assumption in applying FT : The EEG can be broken down to bunch of sinusoids ● Many EEG signals display nonsinusoidal features. ● Non sinusoidal signals contains multiple frequencies and these end up showing as harmonics when using Fourier transform
  • 28. Examples of non-sinusoidal EEG Figure source : Cole et al. 2017
  • 29. Conclusions ● By using Welch method one can obtain smoother PSD ● Choosing very short windows to compute PSD can lead to poor results (esp. for analyzing lower frequencies) ● Longer windows can result in finer resolution of PSD, but can lead to noisy PSD ● The number of DFT points (N) should always be greater than or equal to the length of your data or window ● Highly overlapping windows does not guarantee smoother PSD. (due to correlation between the windows). ● Many EEG signals are non-sinusoidal and violate FT assumption. ● Look at the whole PSD and not just the ‘band’ as band definitions are arbitrary and somewhat inconsistent across studies!