EEG Preprocessing for ICA - sccn.ucsd.edu

64
EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing EEG Preprocessing for ICA 25 th EEGLAB Workshop JAIST Tokyo Satellite, Japan Day 1 John Iversen 1

Transcript of EEG Preprocessing for ICA - sccn.ucsd.edu

Page 1: 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

Page 2: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 3: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 3

The EEGLAB Matlab software

main graphic interface

Page 4: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 5: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 6: EEG Preprocessing for ICA - sccn.ucsd.edu

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)

Page 7: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 8: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 8

Imported EEG data

Page 9: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Comments and dataset history

9

Also:>> EEG.comments

and>> EEG.history

Page 10: EEG Preprocessing for ICA - sccn.ucsd.edu

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)

Page 11: EEG Preprocessing for ICA - sccn.ucsd.edu

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)

Page 12: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Appearance of an event channel in raw data

12

Page 13: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 14: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 15: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Import channel locations

7 file formats supported (Polhemus, BESA, …)

15

Page 16: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Import channel locations

EEG

16

Page 17: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 17

Page 18: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Imported channel locations

18

Page 19: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Remove unwanted channels

19

Page 20: EEG Preprocessing for ICA - sccn.ucsd.edu

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)

Page 21: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 22: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 23: EEG Preprocessing for ICA - sccn.ucsd.edu

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)

Page 24: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Cleanline

24

Tim Mullen

Qusp CEO

Page 25: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Remove line noise (Cleanline)

25

check

Page 26: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 27: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 27

Data Cleaning for ICA

1. Continuous Data

Page 28: EEG Preprocessing for ICA - sccn.ucsd.edu

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)

Page 29: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Manually identifying bad channels

1) Identify bad channel

29

Page 30: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Manually identifying bad channels

30

Page 31: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Manually identifying bad channels

31

Page 32: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 33: EEG Preprocessing for ICA - sccn.ucsd.edu

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)

Page 34: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Plot channel spectra

34

Page 35: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 35

Scroll channel data

Alternate GUI option, same function

Page 36: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 37: EEG Preprocessing for ICA - sccn.ucsd.edu

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)

Page 38: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Reject continuous data

Equivalent

38

Page 39: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 40: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 41: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Fast (but sloppy) artifact rejection

41

Page 42: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 42

Fast (but sloppy) artifact rejection

Page 43: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 43

Data Cleaning for ICA

Variant 2: Epoched Data

Page 44: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 44

>> eeg_eventtypes(EEG)

1 140

2 60

201 60

Extract epochs

Page 45: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 45

Extract epochs

Page 46: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 47: EEG Preprocessing for ICA - sccn.ucsd.edu

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'

Page 48: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Scroll (epoched) channel data

48

Page 49: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 50: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 50

Reject data epochs

Page 51: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 52: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 52

Reject data epochs

Exceeds channel standard dev. max

Page 53: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 53

Reject data epochs

Page 54: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Visualize ERP in rectangular array

54

Page 55: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Visualize ERP in topographic array

55

Page 56: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Visualize ERP scalp distribution

56

Page 57: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Visualize channel ERPs in 2D

57

Page 58: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 58

Visualize channel ERPs in 3D

Page 59: EEG Preprocessing for ICA - sccn.ucsd.edu

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)

Page 60: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing

Re-reference data (if necessary/desired)

average reference

60

Page 61: EEG Preprocessing for ICA - sccn.ucsd.edu

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

Page 62: EEG Preprocessing for ICA - sccn.ucsd.edu

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…

Page 63: EEG Preprocessing for ICA - sccn.ucsd.edu

EEGLAB Workshop XXV, Sep 26-29, 2017, Tokyo, Japan – John Iversen – Preprocessing 63

END

Page 64: EEG Preprocessing for ICA - sccn.ucsd.edu

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