SlideShare a Scribd company logo
1 of 30
From raw EEG data to ERP
Eva A.M. van Poppel, MSc

Overview
•What is EEG?
•What is an ERP?
•Introduction to MATLAB
•Break
•From raw EEG data to ERP in EEGLAB
2
What is EEG?
EEG stands for Electro
Encephalo Graphy
It is the firing of neuronal pyromodal cells,
measured by electrodes on the outside of the brain
(scalp) in microvolts (µV).
3
Picture by Saint Luke's Health System
What is EEG?
Can we measure the activity of inner brainstructures,
like the hippocampus, with EEG?
No, we can only measure the outer layer of neurons,
the neocortex. To measure deeper brain structures,
you need other brain imaging techniques, like MRI.
But compared to MRI, EEG has a better timing.
4
Picture by Saint Luke's Health System
Frequencies
What is an ERP?
ERP stands for
Event Related
Potential.
It is the evoked
brain response
after a stimulus.
The start of the
stimulus is
normally at time
point 0 ms.
6
Introduction to MATLAB
• MATLAB stands for Matrix Laboratory
• First of all, it is a calculator. For example, type 5 +
8*5 and press Enter
• A Matrix is an array (series) of data, stored in rows
and columns (2D). For example, type [1:5;6:10] and
press Enter.
• Variable is the way MATLAB stores data in the
working memory (workspace). Press arrow up and
make it A= [1:5;6:10]
Variable A now contains your matrix. Note that
variable ans will be overwritten.
7
• Now, we want to know what is in row 2, column 3 of
Variable A. We type: A(2,3) and press Enter
• What happens when you forget one of the dimensions
(row or column) and type A(4)?
• Type B=4 (Enter) C=5 (Enter). Type B+C (Enter)
• Sometimes, you don’t want to see all internal
calculations (for example when you load in a complete
EEG data set). In this case, you should use the
semicolon ;
• Type D=ones(1,10);
• How does D look like? What happens when you make
D=ones(10,1) ?
• This is called a vector, which is just one row or column
containing data (1D)
8
Transpose and Text
• Type E=D’
• Transpose ‘
• T = ‘Text’;
• Price = ‘10CHF’
• randn function makes a vector with normally
distributed random numbers, which are the same on
each Matlab start up.
• X=randn(5)
• Y=[1:2:10]
• Y = [1:2:10;2:3:15]
9
Loops
• Press the button «New script» in the left upper
corner.
• Type:
for i = 1:length(Y)
F(i) = Y(1,i)+1;
end
• What did you do? How does F look?
10
FOR & IF Loop
for j = 1:length(Y)
if F(j) > Y(1,j)
G(j) = Y(1,j)
end
end
11
MATLAB tricks
• Don’t show calculations ;
• Transpose ‘
• Text ‘’
• Comments %
• Paragraph %%
• Run full script F5
• Ctrl + C abort run
• Compare scripts
• Clear G; Clear all
12
Break
13
EEGLAB
• Download on
https://sccn.ucsd.edu/eeglab/downloadtoolbox.php
• Extract for example in Documents
• Click Set Path in Matlab  Add folder  eeglab
• Save the path, but don’t save this on a shared
server e.g. Rekenbeest
• Type eeglab in the command window and press
Enter
14
Memory settings
15
Import data
• Go to File  Manage EEGLAB extensions
 Data processing extensions
• Choose the amplifier / EEG data recording
software you use and install
• Go to File  Import data  Using EEGLAB
functions and plugins
and choose your data type
16
Names
Edit  Channel
locations.
Use a template
with XYZ
coordinates and
channel names for
the EEG cap you
used.
17
Reference
• The ERP
value at
electrode X is
the value of
electrode X
with respect
to the
location of
the reference
electrode.
18
• Therefore, we re-reference the recorded data to the
average of the mastoid electrodes behind the ears.
Re-reference
• In EEGLAB, click Tools  Re-reference  Re-
reference data to channel(s): M1 M2
• Exclude channels containing non-EEG data, like
EMG, EOG or trigger channels.
• Add current reference channel back to the data
when you want to restore the data of the physical
reference electrode. You cannot use this when you
recorded with average reference (TMSi & ANT).
19
Filter
• A high-pass filter passes signals with a frequency
higher than a certain cutoff frequency. For EEG
data, you should use a high-pass filter of at least
0.1 Hz to remove the lower drift noise.
• A low-pass filter passes signals with a frequency
lower than a certain cutoff frequency. For ERP
analysis, we typically use a low-pass band from 35
Hz.
• A filter shifts the signal. Therefore, we first run a
high-pass filter, and afterwards run the low-pass
filter to shift it back.
20
Filter
• A filter never cuts off at the given band exactly.
• The slope is dependent of the filter order.
• EEGLAB uses a basic FIR filter as a default
(Finite Impulse
Response)
• The line noise
(electricity network in
Europe) is at 50 Hz.
You need a notch filter
of at least 48-52Hz to
filter this out. 21
Filter
• Because of filter artifacts at the end and beginning
of the data, it is important you filter the data before
epoching (cutting)
• In EEGLAB, Tools  Filter the data  Basic FIR filt
 Lower edge of the frequency pass band  0.1
Hz
• In EEGLAB, Tools  Filter the data  Basic FIR filt
 Higher edge of the frequency pass band  35
Hz
22
Epoch
• Now, we want to aline our data, to make sure all
trials start at 0 ms at the start of the stimulus.
Therefore we “cut” our data -1000 ms before the
stimulus and lasting 2500 ms after.
• In EEGLAB, Tools  Extract epochs  Epoch limits
in seconds -1 2.5
23
Baseline correction
• Baseline correction is the procedure of relativizing
the brain signal of interest (evoked response) with
respect to a control (baseline) signal
• In wake data, you normally use -200 to 0 ms before
the stimulus onset as the baseline
• In (deep) sleep data, we use -1000 to 0 ms as the
baseline
• EEGLAB automatically asks for the baseline period
in ms after the epoch settings
24
Artefact rejection
• Plot  Channel data scroll
• Settings  Time range to display  1 Epoch
• In wake data, EEG values > 75µV are considered
artefacts and those trials are marked for rejection.
In (deep) sleep data, this rule does not apply
• Mark trials containing movements and artefacts for
rejection, write the trial number in an Excel
• You need at least 25 correct trials per subject for a
nice ERP without noise
• Normally, 5 -10% of trials contain artefacts
25
Interpolation
• Some channels are noisy. In this case, we don’t
reject the whole trial, but interpolate the channel
affected
• Interpolation is an artificial reconstruction of the
channel, using the data of the surrounding
channels
• Run the script Eva_Interpolation.m to interpolate
certain channels per trial
• When you want to interpolate a bad channel in all
trials, you have to do this before the epoching using
Tools  Interpolate electrodes
26
Final datasets
• When you interpolated bad channels, you can
delete the trials containing artefacts
• In EEGLAB: Edit  Select data  Epoch range fill in
trials to reject e.g. [1 10] Click remove these and ok
• Save as P5_Final.set
27
Create ERP
• File  Create study  Simple ERP study
• Load in all final datasets
• One row means the same subject, so two files on
the same row means a within subject design,
where each subject on a seperate row means a
between subject design
28
ERP Statistics
• Download the Fieldtrip toolbox and save it in your
path
• Or go to File  Manage EEGLAB extensions  Data
processing extensions  Fieldtrip-lite
• Choose the “Montecarlo/Permutation based”
statistics with “Cluster correction (CC)”
29
Sources
Discovering Statistics Using SPSS, Andy Field, 3rd edition, 2009,
SAGE Publications Ltd.
Discovering Statistics Using R,
Andy Field, 1st edition, 2012, SAGE Publications Ltd.
https://ch.mathworks.com/help/matlab/matlab_prog/loop-
control-statements.html
https://sccn.ucsd.edu/eeglab/downloadtoolbox.php
http://www.fieldtriptoolbox.org/download

More Related Content

What's hot

EEG signal background and real-time processing
EEG signal background and real-time processingEEG signal background and real-time processing
EEG signal background and real-time processingRobert Oostenveld
 
parametric method of power spectrum Estimation
parametric method of power spectrum Estimationparametric method of power spectrum Estimation
parametric method of power spectrum Estimationjunjer
 
1 basics of eeg and fundamentals of its measurement
1 basics of eeg and fundamentals of its measurement1 basics of eeg and fundamentals of its measurement
1 basics of eeg and fundamentals of its measurementSwathy Ravi
 
Magnetoencephalogram-MEG
Magnetoencephalogram-MEGMagnetoencephalogram-MEG
Magnetoencephalogram-MEGSimmiRockzz
 
EEG Artifact and How to Resolve
EEG Artifact and How to ResolveEEG Artifact and How to Resolve
EEG Artifact and How to ResolveLalit Bansal
 
EC8562 DSP Viva Questions
EC8562 DSP Viva Questions EC8562 DSP Viva Questions
EC8562 DSP Viva Questions ssuser2797e4
 
Bio Potential and Bio Electrodes
Bio Potential and Bio ElectrodesBio Potential and Bio Electrodes
Bio Potential and Bio ElectrodesBurdwan University
 
Artifacts in EEG - Recognition and differentiation
Artifacts in EEG - Recognition and differentiationArtifacts in EEG - Recognition and differentiation
Artifacts in EEG - Recognition and differentiationRahul Kumar
 
Electroenchephalography
ElectroenchephalographyElectroenchephalography
Electroenchephalographyimabongaigaon
 

What's hot (20)

EEG signal background and real-time processing
EEG signal background and real-time processingEEG signal background and real-time processing
EEG signal background and real-time processing
 
EEG course.pptx
EEG course.pptxEEG course.pptx
EEG course.pptx
 
Basics of eeg signal
Basics of eeg signalBasics of eeg signal
Basics of eeg signal
 
EEG ppt
EEG pptEEG ppt
EEG ppt
 
parametric method of power spectrum Estimation
parametric method of power spectrum Estimationparametric method of power spectrum Estimation
parametric method of power spectrum Estimation
 
1 basics of eeg and fundamentals of its measurement
1 basics of eeg and fundamentals of its measurement1 basics of eeg and fundamentals of its measurement
1 basics of eeg and fundamentals of its measurement
 
Electroencephalography (EEG) - Basics
Electroencephalography (EEG) - BasicsElectroencephalography (EEG) - Basics
Electroencephalography (EEG) - Basics
 
Magnetoencephalogram-MEG
Magnetoencephalogram-MEGMagnetoencephalogram-MEG
Magnetoencephalogram-MEG
 
EEG artifacts
EEG  artifactsEEG  artifacts
EEG artifacts
 
EEG Artifact and How to Resolve
EEG Artifact and How to ResolveEEG Artifact and How to Resolve
EEG Artifact and How to Resolve
 
EC8562 DSP Viva Questions
EC8562 DSP Viva Questions EC8562 DSP Viva Questions
EC8562 DSP Viva Questions
 
Bio Potential and Bio Electrodes
Bio Potential and Bio ElectrodesBio Potential and Bio Electrodes
Bio Potential and Bio Electrodes
 
Ec8073 medical electronics1
Ec8073 medical electronics1Ec8073 medical electronics1
Ec8073 medical electronics1
 
Artifacts in EEG - Recognition and differentiation
Artifacts in EEG - Recognition and differentiationArtifacts in EEG - Recognition and differentiation
Artifacts in EEG - Recognition and differentiation
 
Oled
OledOled
Oled
 
Ecg Signal Processing
Ecg Signal ProcessingEcg Signal Processing
Ecg Signal Processing
 
NON PARAMETRIC METHOD
NON PARAMETRIC METHODNON PARAMETRIC METHOD
NON PARAMETRIC METHOD
 
EEG
EEGEEG
EEG
 
EEG normal
EEG normalEEG normal
EEG normal
 
Electroenchephalography
ElectroenchephalographyElectroenchephalography
Electroenchephalography
 

Similar to Analysing EEG data using MATLAB

Pablo Magani - BCI SSVEP Speller
Pablo Magani - BCI SSVEP SpellerPablo Magani - BCI SSVEP Speller
Pablo Magani - BCI SSVEP SpellerPablo Magani
 
Artificial neural networks
Artificial neural networksArtificial neural networks
Artificial neural networksarjitkantgupta
 
⭐⭐⭐⭐⭐ EMG Signal Processing with Clustering Algorithms for Motor Gesture Tasks
⭐⭐⭐⭐⭐ EMG Signal Processing with Clustering Algorithms for Motor Gesture Tasks⭐⭐⭐⭐⭐ EMG Signal Processing with Clustering Algorithms for Motor Gesture Tasks
⭐⭐⭐⭐⭐ EMG Signal Processing with Clustering Algorithms for Motor Gesture TasksVictor Asanza
 
Central processing unit
Central processing unitCentral processing unit
Central processing unitHeman Pathak
 
08 neural networks
08 neural networks08 neural networks
08 neural networksankit_ppt
 
Study of various Data Compression Techniques used in Lossless Compression of ...
Study of various Data Compression Techniques used in Lossless Compression of ...Study of various Data Compression Techniques used in Lossless Compression of ...
Study of various Data Compression Techniques used in Lossless Compression of ...Ankita Tiwari
 
EEG Basics monish.pptx
EEG Basics monish.pptxEEG Basics monish.pptx
EEG Basics monish.pptxMohinishS
 
Machine learning
Machine learningMachine learning
Machine learningVikas Sinha
 
Matthew Gray Summer 2015 Presentation
Matthew Gray Summer 2015 PresentationMatthew Gray Summer 2015 Presentation
Matthew Gray Summer 2015 PresentationMatthew Gray
 
Sim Slides,Tricks,Trends,2012jan15
Sim Slides,Tricks,Trends,2012jan15Sim Slides,Tricks,Trends,2012jan15
Sim Slides,Tricks,Trends,2012jan15Dennis Sweitzer
 
Simulating data to gain insights into power and p-hacking
Simulating data to gain insights intopower and p-hackingSimulating data to gain insights intopower and p-hacking
Simulating data to gain insights into power and p-hackingDorothy Bishop
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisAnindita Kundu
 
Digital electronics
Digital electronicsDigital electronics
Digital electronicscallr
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity CalculationAkhil Kaushik
 

Similar to Analysing EEG data using MATLAB (20)

Pablo Magani - BCI SSVEP Speller
Pablo Magani - BCI SSVEP SpellerPablo Magani - BCI SSVEP Speller
Pablo Magani - BCI SSVEP Speller
 
Artificial neural networks
Artificial neural networksArtificial neural networks
Artificial neural networks
 
⭐⭐⭐⭐⭐ EMG Signal Processing with Clustering Algorithms for Motor Gesture Tasks
⭐⭐⭐⭐⭐ EMG Signal Processing with Clustering Algorithms for Motor Gesture Tasks⭐⭐⭐⭐⭐ EMG Signal Processing with Clustering Algorithms for Motor Gesture Tasks
⭐⭐⭐⭐⭐ EMG Signal Processing with Clustering Algorithms for Motor Gesture Tasks
 
Central processing unit
Central processing unitCentral processing unit
Central processing unit
 
08 neural networks
08 neural networks08 neural networks
08 neural networks
 
Unit 2 ml.pptx
Unit 2 ml.pptxUnit 2 ml.pptx
Unit 2 ml.pptx
 
Study of various Data Compression Techniques used in Lossless Compression of ...
Study of various Data Compression Techniques used in Lossless Compression of ...Study of various Data Compression Techniques used in Lossless Compression of ...
Study of various Data Compression Techniques used in Lossless Compression of ...
 
Project
ProjectProject
Project
 
EEG Basics monish.pptx
EEG Basics monish.pptxEEG Basics monish.pptx
EEG Basics monish.pptx
 
Machine learning
Machine learningMachine learning
Machine learning
 
Matthew Gray Summer 2015 Presentation
Matthew Gray Summer 2015 PresentationMatthew Gray Summer 2015 Presentation
Matthew Gray Summer 2015 Presentation
 
Sim Slides,Tricks,Trends,2012jan15
Sim Slides,Tricks,Trends,2012jan15Sim Slides,Tricks,Trends,2012jan15
Sim Slides,Tricks,Trends,2012jan15
 
Simulating data to gain insights into power and p-hacking
Simulating data to gain insights intopower and p-hackingSimulating data to gain insights intopower and p-hacking
Simulating data to gain insights into power and p-hacking
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysis
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
Classification of indoor actions through deep neural networks
Classification of indoor actions through deep neural networksClassification of indoor actions through deep neural networks
Classification of indoor actions through deep neural networks
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
ECG
ECGECG
ECG
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 

Recently uploaded

USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Recently uploaded (20)

USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 

Analysing EEG data using MATLAB

  • 1. From raw EEG data to ERP Eva A.M. van Poppel, MSc 
  • 2. Overview •What is EEG? •What is an ERP? •Introduction to MATLAB •Break •From raw EEG data to ERP in EEGLAB 2
  • 3. What is EEG? EEG stands for Electro Encephalo Graphy It is the firing of neuronal pyromodal cells, measured by electrodes on the outside of the brain (scalp) in microvolts (µV). 3 Picture by Saint Luke's Health System
  • 4. What is EEG? Can we measure the activity of inner brainstructures, like the hippocampus, with EEG? No, we can only measure the outer layer of neurons, the neocortex. To measure deeper brain structures, you need other brain imaging techniques, like MRI. But compared to MRI, EEG has a better timing. 4 Picture by Saint Luke's Health System
  • 6. What is an ERP? ERP stands for Event Related Potential. It is the evoked brain response after a stimulus. The start of the stimulus is normally at time point 0 ms. 6
  • 7. Introduction to MATLAB • MATLAB stands for Matrix Laboratory • First of all, it is a calculator. For example, type 5 + 8*5 and press Enter • A Matrix is an array (series) of data, stored in rows and columns (2D). For example, type [1:5;6:10] and press Enter. • Variable is the way MATLAB stores data in the working memory (workspace). Press arrow up and make it A= [1:5;6:10] Variable A now contains your matrix. Note that variable ans will be overwritten. 7
  • 8. • Now, we want to know what is in row 2, column 3 of Variable A. We type: A(2,3) and press Enter • What happens when you forget one of the dimensions (row or column) and type A(4)? • Type B=4 (Enter) C=5 (Enter). Type B+C (Enter) • Sometimes, you don’t want to see all internal calculations (for example when you load in a complete EEG data set). In this case, you should use the semicolon ; • Type D=ones(1,10); • How does D look like? What happens when you make D=ones(10,1) ? • This is called a vector, which is just one row or column containing data (1D) 8
  • 9. Transpose and Text • Type E=D’ • Transpose ‘ • T = ‘Text’; • Price = ‘10CHF’ • randn function makes a vector with normally distributed random numbers, which are the same on each Matlab start up. • X=randn(5) • Y=[1:2:10] • Y = [1:2:10;2:3:15] 9
  • 10. Loops • Press the button «New script» in the left upper corner. • Type: for i = 1:length(Y) F(i) = Y(1,i)+1; end • What did you do? How does F look? 10
  • 11. FOR & IF Loop for j = 1:length(Y) if F(j) > Y(1,j) G(j) = Y(1,j) end end 11
  • 12. MATLAB tricks • Don’t show calculations ; • Transpose ‘ • Text ‘’ • Comments % • Paragraph %% • Run full script F5 • Ctrl + C abort run • Compare scripts • Clear G; Clear all 12
  • 14. EEGLAB • Download on https://sccn.ucsd.edu/eeglab/downloadtoolbox.php • Extract for example in Documents • Click Set Path in Matlab  Add folder  eeglab • Save the path, but don’t save this on a shared server e.g. Rekenbeest • Type eeglab in the command window and press Enter 14
  • 16. Import data • Go to File  Manage EEGLAB extensions  Data processing extensions • Choose the amplifier / EEG data recording software you use and install • Go to File  Import data  Using EEGLAB functions and plugins and choose your data type 16
  • 17. Names Edit  Channel locations. Use a template with XYZ coordinates and channel names for the EEG cap you used. 17
  • 18. Reference • The ERP value at electrode X is the value of electrode X with respect to the location of the reference electrode. 18 • Therefore, we re-reference the recorded data to the average of the mastoid electrodes behind the ears.
  • 19. Re-reference • In EEGLAB, click Tools  Re-reference  Re- reference data to channel(s): M1 M2 • Exclude channels containing non-EEG data, like EMG, EOG or trigger channels. • Add current reference channel back to the data when you want to restore the data of the physical reference electrode. You cannot use this when you recorded with average reference (TMSi & ANT). 19
  • 20. Filter • A high-pass filter passes signals with a frequency higher than a certain cutoff frequency. For EEG data, you should use a high-pass filter of at least 0.1 Hz to remove the lower drift noise. • A low-pass filter passes signals with a frequency lower than a certain cutoff frequency. For ERP analysis, we typically use a low-pass band from 35 Hz. • A filter shifts the signal. Therefore, we first run a high-pass filter, and afterwards run the low-pass filter to shift it back. 20
  • 21. Filter • A filter never cuts off at the given band exactly. • The slope is dependent of the filter order. • EEGLAB uses a basic FIR filter as a default (Finite Impulse Response) • The line noise (electricity network in Europe) is at 50 Hz. You need a notch filter of at least 48-52Hz to filter this out. 21
  • 22. Filter • Because of filter artifacts at the end and beginning of the data, it is important you filter the data before epoching (cutting) • In EEGLAB, Tools  Filter the data  Basic FIR filt  Lower edge of the frequency pass band  0.1 Hz • In EEGLAB, Tools  Filter the data  Basic FIR filt  Higher edge of the frequency pass band  35 Hz 22
  • 23. Epoch • Now, we want to aline our data, to make sure all trials start at 0 ms at the start of the stimulus. Therefore we “cut” our data -1000 ms before the stimulus and lasting 2500 ms after. • In EEGLAB, Tools  Extract epochs  Epoch limits in seconds -1 2.5 23
  • 24. Baseline correction • Baseline correction is the procedure of relativizing the brain signal of interest (evoked response) with respect to a control (baseline) signal • In wake data, you normally use -200 to 0 ms before the stimulus onset as the baseline • In (deep) sleep data, we use -1000 to 0 ms as the baseline • EEGLAB automatically asks for the baseline period in ms after the epoch settings 24
  • 25. Artefact rejection • Plot  Channel data scroll • Settings  Time range to display  1 Epoch • In wake data, EEG values > 75µV are considered artefacts and those trials are marked for rejection. In (deep) sleep data, this rule does not apply • Mark trials containing movements and artefacts for rejection, write the trial number in an Excel • You need at least 25 correct trials per subject for a nice ERP without noise • Normally, 5 -10% of trials contain artefacts 25
  • 26. Interpolation • Some channels are noisy. In this case, we don’t reject the whole trial, but interpolate the channel affected • Interpolation is an artificial reconstruction of the channel, using the data of the surrounding channels • Run the script Eva_Interpolation.m to interpolate certain channels per trial • When you want to interpolate a bad channel in all trials, you have to do this before the epoching using Tools  Interpolate electrodes 26
  • 27. Final datasets • When you interpolated bad channels, you can delete the trials containing artefacts • In EEGLAB: Edit  Select data  Epoch range fill in trials to reject e.g. [1 10] Click remove these and ok • Save as P5_Final.set 27
  • 28. Create ERP • File  Create study  Simple ERP study • Load in all final datasets • One row means the same subject, so two files on the same row means a within subject design, where each subject on a seperate row means a between subject design 28
  • 29. ERP Statistics • Download the Fieldtrip toolbox and save it in your path • Or go to File  Manage EEGLAB extensions  Data processing extensions  Fieldtrip-lite • Choose the “Montecarlo/Permutation based” statistics with “Cluster correction (CC)” 29
  • 30. Sources Discovering Statistics Using SPSS, Andy Field, 3rd edition, 2009, SAGE Publications Ltd. Discovering Statistics Using R, Andy Field, 1st edition, 2012, SAGE Publications Ltd. https://ch.mathworks.com/help/matlab/matlab_prog/loop- control-statements.html https://sccn.ucsd.edu/eeglab/downloadtoolbox.php http://www.fieldtriptoolbox.org/download

Editor's Notes

  1. vector is just one row or column containing data (1D). A Variable is capital sensitive and can contain multiple characters. MATLAB license problem? Make sure you’re connected to the Unifr network via secure-uni WLAN or the Cisco VPN.
  2. The ground is used for common mode rejection. The primary purpose of the ground is to prevent power line noise from interfering with the small biopotential signals of interest. By design, amplifiers should not be affected by large changes in potential at both the active and reference sites. A ground electrode for EEG recordings is often placed on the forehead (but could be placed anywhere else on the body; the location of the ground on the subject is generally irrelevant). https://www.biopac.com/knowledge-base/ground-vs-reference-for-eeg-recording/
  3. The ground is used for common mode rejection. The primary purpose of the ground is to prevent power line noise from interfering with the small biopotential signals of interest. By design, amplifiers should not be affected by large changes in potential at both the active and reference sites. A ground electrode for EEG recordings is often placed on the forehead (but could be placed anywhere else on the body; the location of the ground on the subject is generally irrelevant). https://www.biopac.com/knowledge-base/ground-vs-reference-for-eeg-recording/
  4. The ground is used for common mode rejection. The primary purpose of the ground is to prevent power line noise from interfering with the small biopotential signals of interest. By design, amplifiers should not be affected by large changes in potential at both the active and reference sites. A ground electrode for EEG recordings is often placed on the forehead (but could be placed anywhere else on the body; the location of the ground on the subject is generally irrelevant). https://www.biopac.com/knowledge-base/ground-vs-reference-for-eeg-recording/
  5. The ground is used for common mode rejection. The primary purpose of the ground is to prevent power line noise from interfering with the small biopotential signals of interest. By design, amplifiers should not be affected by large changes in potential at both the active and reference sites. A ground electrode for EEG recordings is often placed on the forehead (but could be placed anywhere else on the body; the location of the ground on the subject is generally irrelevant). https://www.biopac.com/knowledge-base/ground-vs-reference-for-eeg-recording/
  6. The ground is used for common mode rejection. The primary purpose of the ground is to prevent power line noise from interfering with the small biopotential signals of interest. By design, amplifiers should not be affected by large changes in potential at both the active and reference sites. A ground electrode for EEG recordings is often placed on the forehead (but could be placed anywhere else on the body; the location of the ground on the subject is generally irrelevant). https://www.biopac.com/knowledge-base/ground-vs-reference-for-eeg-recording/