EEG Preprocessing for ICA - sccn.ucsd.edu
Transcript of EEG Preprocessing for ICA - sccn.ucsd.edu
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
EEG Preprocessing for ICA
25th EEGLAB WorkshopJAIST Tokyo Satellite, Japan
Day 1John Iversen
1
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
• Start Matlab• Add the EEGLAB folder to your Matlab path:
2
Installing EEGLAB and data folder
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 3
The EEGLAB Matlab software
main graphic interface
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
“Secrets” to a good ICA decomposition
Garbage in, garbage out (GIGO: it’s not magic)
Remove large, non-stereotyped artifacts
Do you have enough data? (based mostly on time, not frames)
High-pass filter to remove slow drifts (no low-pass filter needed)
Remove bad channels
Data must be in double precision (not single)
4
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
The Goal of Preprocessing
• Create a complete EEGLAB data set with– EEG time series signal– Channel Locations– Event information
• Applying singnal processings on EEG time series to help ICA decompositions– Data ‘cleaning’—artifact rejection.
• Removing noisy channels.• Removing noisy segments of data.
– Applying frequency filter.
5
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Pre-processing pipeline
Import time-seriesdata into EEGLAB
Import event markersand channel locations
High pass filter(~.5 – 1 Hz)
Examine raw data
Reject large artifact time points
Identify/rejectbad channels
6
Remove line noise(if necessary)
Re-reference/down-sample(if necessary)
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 7
Importing a dataset
Tip for Biosemi users:
Use the ‘BDF plugin’ version
of the Biosemi BDF/EDF importer
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 8
Imported EEG data
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Comments and dataset history
9
Also:>> EEG.comments
and>> EEG.history
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Pre-processing pipeline
Import time-seriesdata into EEGLAB
Import event markersand channel locations
High pass filter(~.5 – 1 Hz)
Examine raw data
Reject large artifact time points
Identify/rejectbad channels
10
Remove line noise(if necessary)
Re-reference/down-sample(if necessary)
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 1111
• Import events from Matlab array or ASCII file• Import events from data channel• Import from Presentation event file• Import events from E-Prime event file• Import events from Neuroscan event file
Import data events
73
(Often imported automatically
during data import)
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Appearance of an event channel in raw data
12
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Imported data events
If event import was
successful,
you will see an
appropriate
number here
13
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 14
Sample data: basic P300 paradigm
FileSimpleOddball.set
Data68 channel EEG, 256 Hz sampling rate, Biosemi system, re-referenced during import to averaged left and right mastoid electrodes
Taskspeeded button press response to star shape (noresponse to circle shape), 100 ms presentationduration, 200 trials
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Import channel locations
7 file formats supported (Polhemus, BESA, …)
15
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Import channel locations
EEG
16
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 17
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Imported channel locations
18
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Remove unwanted channels
19
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Pre-processing pipeline
Import time-seriesdata into EEGLAB
Import event markersand channel locations
High pass filter(~.5 – 1 Hz)
Examine raw data
Reject large artifact time points
Identify/rejectbad channels
20
Remove line noise(if necessary)
Re-reference/down-sample(if necessary)
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
High-Pass Filter the data
Reason: To improve data stationarity.ICA is biased to amplitude, and EEG data has 1/f power specrum density.
0.5
High-pass
needed
for ICA
21
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Good resource for learning filters
22
https://sccn.ucsd.edu/wiki/Firfilt_FAQ
https://cloud.github.com/downloads/widmann/firfilt/firfilt.pdf
Andreas Widmann from Leipzig
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Pre-processing pipeline
Import time-seriesdata into EEGLAB
Import event markersand channel locations
High pass filter(~.5 – 1 Hz)
Examine raw data
Reject large artifact time points
Identify/rejectbad channels
23
Remove line noise(if necessary)
Re-reference/down-sample(if necessary)
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Cleanline
24
Tim Mullen
Qusp CEO
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Remove line noise (Cleanline)
25
check
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Filter comparisons
26
0.5 Hz high-pass filter 0.5 Hz high-pass filter50 Hz low-pass filter
0.5 Hz high-pass filterCleanline
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 27
Data Cleaning for ICA
1. Continuous Data
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Pre-processing pipeline
Import time-seriesdata into EEGLAB
Import event markersand channel locations
High pass filter(~.5 – 1 Hz)
Examine raw data
Reject large artifact time points
Identify/rejectbad channels
28
Remove line noise(if necessary)
Re-reference/down-sample(if necessary)
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Manually identifying bad channels
1) Identify bad channel
29
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Manually identifying bad channels
30
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Manually identifying bad channels
31
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Removing channel(s)
If not checked, will result
in dataset with one channel
32
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Pre-processing pipeline
Import time-seriesdata into EEGLAB
Import event markersand channel locations
High pass filter(~.5 – 1 Hz)
Examine raw data
Reject large artifact time points
Identify/rejectbad channels
33
Remove line noise(if necessary)
Re-reference/down-sample(if necessary)
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Plot channel spectra
34
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 35
Scroll channel data
Alternate GUI option, same function
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 36
Scroll channel data
scaling
channels,time,
events
sec/epoch
Scroll buttons
Event markers
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Pre-processing pipeline
Import time-seriesdata into EEGLAB
Import event markersand channel locations
High pass filter(~.5 – 1 Hz)
Examine raw data
Reject large artifact time points
Identify/rejectbad channels
37
Remove line noise(if necessary)
Re-reference/down-sample(if necessary)
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Reject continuous data
Equivalent
38
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Reject continuous data
Click and drag with mouse
over noisy data to reject
39
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Rejecting data for ICA
To prepare data for ICA:
KeepReject
... but keep stereotyped artifacts (like eye blinks)
Reject large muscle or otherwise strange events...
40
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Fast (but sloppy) artifact rejection
41
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 42
Fast (but sloppy) artifact rejection
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 43
Data Cleaning for ICA
Variant 2: Epoched Data
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 44
>> eeg_eventtypes(EEG)
1 140
2 60
201 60
Extract epochs
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 45
Extract epochs
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 46
Select a subset of epochs‘0’ because the subject
did not miss any targets
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 47
Save dataset (optional)
SimpleOddball target epochs
Or save later from menu
'Do not overwrite
current dataset'
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Scroll (epoched) channel data
48
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Reject epochs with artifact
49
1.1 s epoch 1.1 s epoch 1.1 s epoch 1.1 s epoch 1.1 s epoch
Click anywhere within
an epoch to select it
for rejection
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 50
Reject data epochs
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing17th EEGLAB Workshop, Nov. 14-18, 2013, San Diego: Marissa Westerfield – ERP visualization 51
Reject data epochs
visual inspection
probability
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 52
Reject data epochs
Exceeds channel standard dev. max
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 53
Reject data epochs
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Visualize ERP in rectangular array
54
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Visualize ERP in topographic array
55
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Visualize ERP scalp distribution
56
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Visualize channel ERPs in 2D
57
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 58
Visualize channel ERPs in 3D
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Pre-processing pipeline
Import time-seriesdata into EEGLAB
Import event markersand channel locations
High pass filter(~.5 – 1 Hz)
Examine raw data
Reject large artifact time points
Identify/rejectbad channels
59
Remove line noise(if necessary)
Re-reference/down-sample(if necessary)
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Re-reference data (if necessary/desired)
average reference
60
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
On Average Referencing
61
• In theory, positive and negative current across entire head should balance—no net current source or sink: Average referencing enforces this.
• ICA is invariant to re-referencing, except for
• Effect of rank deficiency
• DC difference.
• Average referencing reduces data rank by 1, so you must remove one channel (Cz often) See update below.
https://sccn.ucsd.edu/wiki/Makoto's_preprocessing_pipeline#Re-reference_the_data_to_average
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Resample data (if desired)
62
256
Reason: Reduce space, time. But keep nyquist and
ICA data length requirements in mind…
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 63
END
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing
Exercises (optional homework)
64
• Preprocess data of your choice or load a previously filtered dataset e.g. faces_4.set•Identify and remove non-task portions of continuous data; see if the previously flagged channels are still identified as bad• Epoch on event of interest. Scroll the epoched data and perform visual rejection of epochs