Scripts to automate the preprocessing and analysis of EEG signals using EEGlab.
These scripts were developed by Ricardo Dominguez Olmedo during a placement at the Physiological Signals and Systems Laboratory, Department of Automatic Control and Systems Engineering, The University of Sheffield.
Main functionality included:
- Preprocessing multiple data files by removing data at the start/end of the experiment, downsampling and bandpass filtering. Refer to convertRawFile2RawData.m and preprocessingICA.m.
- Applying independent component analysis simultaneously to several data files, allowing the bulk of the computation to be performed at once. Thereafter the signal subcomponents of each data file can be examined and rejected if believed to be spurious. Refer to preprocessingICA.m and ICArejectChannels.m.
- Computing automatically the spectral powers of multiple EEG data files. Refer to computeSpectralPowers.m.
Additional functionality included (used to measure cognitive workload):
- Computing average blinking frequency using the Blinker toolbox. Refer to processBlinkData.m.
- Analysing audio of a person counting out loud to measure word frequency and number of errors (not automated). Refer to audioProcessCountingUp.m.
Example of using the scripts to preprocess, apply ICA and extract the spectral powers of EEG signals collected with an Enobio headset.
-
Add the folder containing the
EEGlab
toolbox to the MATLAB path. -
Create a
\data
folder at the base of the MATLAB path. -
Put the
.easy
files collected from the Enobio headset into a new folder (ieData/rawFilesX
). -
Run convertRawFile2RawData.m to create
Data/rawDataX
. Ensure that the folderData
and its subfolders are added to the path. The new folder contains .txt files with only the relevant EEG data as columns. -
Run preprocessingICA.m to preprocess the data and apply independent component analysis. Ensure that the folder
toolboxes/EEGlab
and its subfolders are added to the path. Ensure you have created a file with the EEG channel locations (using the EEGlab GUI Edit/Channel Locations) and said file is located inData/rawDataX
. The folder created/Data/icaX
will contains EEGlab.set
files. -
Run ICArejectChannels.m to reject the individual components extracted using ICA. Individual windows will appear in the screen with information about the components found using ICA. The pruned data will be stored at
/Data/pruneX
. -
Run computeSpectralPowers.m to compute the spectral powers of the clean signals. The values for each dataset are stored at
/Data/powersX
as.txt
files.
Only cognitively related signals should not be rejected.
Rules of thumb to determine if a component is:
-
a) Cognitively related
- Dipole-like scalp maps
- Spectral peaks at typical EEG frequencies (5 to 20 Hz)
- Regular ERP-image plots (meaning that the component does not account for activity occurring in only a few trials).
-
b) Muscle artifact
- Spatially localized
- Show high power at high frequencies (20-50 Hz and above)
-
c) Eye artifact
- Smoothly decreasing EEG spectrum
- Strong far-frontal projection
- Possible to see individual eye movements in the component erpimage.m
-
d) Some other type of artifact
- A single channel goes 'off'
- Line-noise artifacts
- Noise in a certain frequency, specially in specific trials
To make an informed choice look at:
- The scalp map
- The component time course
- The component activity power spectrum
- The erpimage.m
For further information refer to the Swartz Center for Computational Neuroscience wiki.