Ressources numériques en sciences humaines et sociales OpenEdition Nos plateformes OpenEdition Books OpenEdition Journals Hypothèses Calenda Bibliothèques OpenEdition Freemium Suivez-nous

Pre-processing for ERP Analysis

The Principle of Event-Related Potentials (ERPs)

In EEG research, the most common type of analysis concerns small voltages that are time-locked to an eliciting event, these small voltage deflections are referred to as Event-Related Potentials (ERPs). Experimental psychologists and neuroscientists have defined a number of ERPs with specified latency (time interval after an event or stimulus), such as the P3 or N400. ERPs are thought to reflect the processing of stimuli and can be modulated by changes in attention, in expectation, in the recruitment of memory processes or by changes in mental state.

Some ERPs are more robust and easier to elicit than others but all are small compared to the various types of noise and spontaneous EEG that forms part of the EEG signal. Therefore, to deal with this, EEG experiments typically involve the repeated presentation of an eliciting stimulus or event so that the voltage changes in the EEG signal time locked to this event can be averaged together; this averaging has the effect of cancelling out unwanted, random noise and revealing the ERPs.

While averaging will cancel out a large part of the random noise that is inherent in the EEG signal, it is not sufficient to deal with certain  artefacts that contaminate the EEG signal. This can be due either to their large amplitude or to their regularity in time. Such artefacts can be physiological such as eye-blinks, horizontal and vertical ocular movements (HEOG and VEOG, respectively), cardiac rhythm and artefacts related to movement, or they can be environmental such as the line noise (50-60Hz).  This means that any reliable analysis and interpretation of ERP effects must be preceded by an initial “pre-processing” stage, in which artefacts are removed. In the following, the various crucial stages of the pre-processing pipeline for ERP analysis will be described in the context of the EEGLAB toolbox (Delorme & Makeig, 2004) , a Matlab toolbox dedicated to the processing and analysis of EEG data.

The following presents an outline of the pre-processing pipeline. For each stage, links are provided to the relevant Matlab code, which can be used to create ones own pre-processing script as wellas to a page in which the pre-processing stage is discussed in greater detail. The pre-processing stages presented are:

  1. Importing raw data and Rereferencing
  2. Resampling
  3. Filtering
  4. Detection of bad channels
  5. Detection of high amplitude noise
  6. Independent Components Analysis (ICA)
  7. Epoching of the continuous data
  8. Epoch rejection
  9. Subject-level Average & Grand Average

EEGLAB – A General Introduction

The EELAB toolbox (Delorme & Makeig, 2004) facilitates the analysis of single-trial data by including data analysis techniques such as ICA and spectral analysis techniques. In addition, it includes a range of signal processing functions permitting the pre-processing of EEG data as well as functions for the visualisation of multi-trial data. And although it was originally aimed at the analysis of single trial data, it does allow trial averaging. For those users not familiar with Matlab programming, EEGLAB has a simple graphical user interface.

Step 1: Importing Raw files into EEGLAB and Re-Referencing

EEGLAB permits the importing of various formats. A very widely used format is *.bdf (Biosemi data file), which can be imported with the Biosig plugin option:

EEGLAB_import2
Figure 1: Import Biosemi *.BDF file
EEGLAB_importB
Figure 2: Import *.BDF file and define reference electrode/s.

File >> EEGLAB functions and plugins >> From Biosemi BDF file (BIOSIG toolbox)

 Link to script of importing *.BDF file into EEGLAB and re-referencing to the linked mastoids here:

ImportBDF_Rereference

Click here for more détails on re-referencing your EEG data.

Step 2: Re-Sampling Continuous Data

If you recorded your EEG data using a Biosemi system, the default sampling frequency is 2048Hz. Such a high sampling rate is unnecessary for ERP analysis, which is generally interested in frequency range below 40Hz. Therefore, to decrease the size of your datafile and facilitate quicker processing of your data, you should resample your data.

From the EEGLAB GUI:

Tools >> Resample

Scripted form provided via the following link :

Downsample_Data 

Click here for more details on resampling your EEG data

Step 3 : Filtering the Continuous Data

Filtering transforms the signal, so in an ideal world we would prefer not to filter. However, filtering is often a necessary step in our preprocessing pipeline due to several factors:

  • Presence of 50Hz line noise (or 60Hz if you are in the USA)
  • Removal of the 0Hz offset.
  • Suppression of high frequency noise.
  • Suppression of very low frequency noise.

If you are working with a more recent version of EEGLAB, e.g. v.13.3.2, the default filter used is a hamming windowed sinc FIR (Finite Impluse Response) filter. To use this new default filter (pop_eegfiltnew()) the firfilt (Andreas Widmann)  toolbox is required.  As it is a Type 1 FIR filter, it has linear phrase but it achieves zero phase by shifting the signal by the filter’s group delay.

There are other filter options available, which are described further in the section, Filtering in EEGLAB. The guidelines given in this section are based on the use of the default filter (eegfiltnew()).

From the EEGLAB GUI:

Tools >> Filter the data >> Basic FIR filter

In the resulting popup window (see figure 3) , the following information needs to be inserted:

  • Lower edge of the frequency pass band (Hz)
  • Upper edge of the frequency pass band (Hz)
  • FIR filter order
pop_eegfiltnew_pic
Figure 3: pop_eegfiltnew()

The upper and lower limits of the filter depend on why you are filtering and what frequency band you are interested in. Generally, if the aim is to carry out ERP analysis, the lower and upper filter edges are defined as 0.1Hz and 40Hz, respectively. These exact values can vary. This bandpass filtering serves the purpose of suppressing the 0Hz offset and the 50Hz DC line noise.

The filter order determines the width of the transition band. It does not determine the attenuation of the signal in the stopband. The filter order determines the number of filter coefficients and is one less than the filter length. The filter order needs to be an even number. If you leave the “FIR filter order” box empty, the filter order will be determined automatically. The higher the filter order, the steeper the rolloff slope of your filter and, therefore, the narrower the transition band between the filter pass-band and stop-band. So, to define the filter order, you need first to define the desired characteristics of the transition band of your filter.

Specific guideline for bandpass filtering using the default FIR filter

If you wish to apply a bandpass filter with a large bandwidth, such as a filter with a lower cutoff frequency of 0.1Hz and an upper cutoff frequency of 30Hz, it is best to do this in two steps:

  1. Apply the lowpass filter – define the upper cutoff frequency of 30Hz.
  2. Then, apply the highpass filter – define the lower cutoff frequency of 0.1Hz.

If you try to apply the bandpass filter in a single step, your computer is likely to bug (unless you are lucky enough to own a super computer!). This occurs because filtering using the default FIR filter is computationally very costly as the filter length required is very long.

 Step 4: Detection of Bad Electrodes

To detect bad electrodes and decide which electrodes should be rejected, several methods can be used. The methods used for their detection can combine visual detection, statistical measures of the “behaviour” of signals for each electrode and analysis of their spectral properties. Thus, this part of the pre-processing pipeline is best carried out in a semi-automatic manner. EEGLAB provides several tools for the detection of bad electrodes.

Electrodes can be rejected based on the continuous or epoched data. However, if you intend carrying out an Independent Components Analysis (ICA) on your continuous data, it is a good idea not to include electrodes that are very noisy as they will likely prevent a good separation of your data. In general, if, in the continuous data, an electrode should be rejected if it is clearly very noisy throughout the entire recording. If an electrode is periodically noisy, it may be better to investigate its effect on epoch rejection before deciding to exclude it, in which case we can look at the effect of an electrode on epoch rejection.

Visual detection :

To get a general idea of the quality of your data it is always good to look at it. To visualise your data :

>> Plot >> Channel data (scroll)

If you are visualising your data before filtering, you may want to remove the 0Hz offset.  In the eegplot window (see figure  :

>> Display >> Remove DC offset

<insert figure here>

To visualise the data as a butterfly, select the “Stack” option.  This is a good way of checking for bad electrodes and for periods of noisy data.

Statistical measures :

EEGLAB provides a function for the automatic detection of bad electrodes in  data using higher order statistical measures, Kurtosis and Probability. This function is accessed via the GUI by :

>> Tools >>  Automatic channel rejection

Kurtosis

This statistical measures quantifies the extent to which the distribution of the signal, which describes its trend, departs from normality. A signal with normal distribution has a kurtosis value near to 0.  If the kurtosis is high, it implies that most of the variance in the signal is the result of random large deviations. To highlight those electrodes whose kurtosis value is atypical, the kurtosis value is expressed as z-score. The default z-score limit is 5 but the user can define a threshold z-score, above which electrodes are defined as bad.

Probability

This quantifies the time course of the electrode signals and is based on the assumption that noisy electrodes will have unusual time courses.

Spectral measures :

A spectral measure will reveal those electrodes that are contaminated by noise that has a characteristic frequency or frequency range, such as line noise (50Hz), muscle artefacts characterised by high frequency, slow drift caused by skin potentials, which are characterised by low frequency activity. The following function, PSD_calc(),  calculates the Power Spectral Density (PSD) for each electrode of the input EEG dataset using the pwelch method. It is works best on continuous data. The user can identify potential bad electrodes from the resulting PSD plot; bad electrodes are typically characterised by greater activity in the low frequency range or by a lower amplitude at all frequencies than the other electrodes. It is possible to click on plotted PSDs to highlight the corresponding electrode and to display its label display in the Matlab command window.

PSD_image1
Figure 4: Plot of Power Spectral Density (PSD) using the function PSD_calc.m

Function available by selecting the following link. Note that this function requires the smooth.m function, which is also available via the :

Link to function PSD_calc() in Github

Scalp Topography :

Another very good way to detecting the presence of bad electrodes is to plot the topography. However, the topography only corresponds to a specific time interval and so will not necessarily reveal if a channel is bad for all temporal points. From the eegplot() window, the topography for a particular time point can be visualised by right clicking on the window at the time point of interest.

 

Detecting Bad Electrodes in Epoched Data

As mentioned above, it is always preferable to conserve all our electrodes, especially when the number of electrodes is small (64 or less). So one way to decide whether or not to discard an electrode is to take into account its effect on the number of rejected epochs. If the presence of a particular noisy electrode means that we need to reject more than ,say,  10% of our epochs, we may consider excluding this electrode.

The following is a link to a simple function for detecting bad electrodes and noisy epochs in segmented data. It allows the user to inspect the data visually and to see, at a glance, the electrodes that are consistently noisy as well as those epochs in which a large number of electrodes present activity that exceeds a predefined threshold (e.g. 100mV). The electrodes are plotted as a function of trial number and the colour indicates the voltage. The user can inspect the data by clicking on the map to reveal the electrode label and the trial number of the selected point displayed as a datatip.

Link to Figure 4:  Visualising electrodes and trials and detecting bad electrodes and trials interactively using function EpochChan_Reject.m

From figure 4, we can see that, upon inspection (using the datatips), several frontal electrodes are “above-threshold” in trial 52. It is also evident that, in general, the frontal electrodes of both hemispheres are noisy, in particular the Fz, Fp1 and Fp2.

In addition, the user can specify the threshold voltage and the number of “bad” electrodes per trial above which the trial is considered as bad. Based on this data, the “bad” trials are plotted and the “above-threshold” electrodes are highlighted in red.

Link to Figure 4: Visualing potentially bad trials detected by the function EpochChan_Reject.m.

Link to functions EpochChan_dlg.m and EpochChan_Reject.m in Github

The function is called by typing the following in the Matlab command window:

>> EpochChan_dlg(EEG)

Where EEG is the EEGLAB data structure. In a future update, the function will be adapted to include data that is not necessarily configured as an EEGLAB structure.

 

 

Removing bad channels 

Via the GUI :

>> Edit >> Select Data

 

TO BE CONTINUED…

Blog du Centre de Ressources pour l'Expérimentation de l'ILCB