This is a collaborative space. In order to contribute, send an email to maximilien.chaumon@icm-institute.org
On any page, type the letter L on your keyboard to add a "Label" to the page, which will make search easier.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Prerequisite

For ERP computation, you need the following:

- matlab

- fieldtrip (see here for how to initialize fieldtrip)

Before computing ERPs, you should have performed the following operations on your data:

- preprocessed the continuous data (Maxfilter, re-referencing, filtering)

- detected artefacts

Goal of this tutorial

This tutorial teaches you how to go from your continuous recording to the average evoked response (ERP/ERF).

This tutorial will follow the fieldtrip tutorials on ERP computation, and will give some additional information.

See the following fieldtrip tutorials: 'Preprocessing - reading continuous EEG data' and 'Preprocessing of EEG data and computing ERPs'

Step-by-step guide

 

 

1. Dealing with events

a. Events in original fif format

If you are reading your events directly from the fif file, you can use the ft_read_event function. This will give you a data structure, with all the triggers found in the data. For each trigger, you will have the following fields: the type (can be the channel where triggers were recorded, or the name of the event), the sample number, the value of the trigger, the offset and the duration. These are the basic triggers you sent during recording.

b. Events in .mrk file

If your events have been read, modified or added with dataHandler or Muse, you have a '_trans_tsss.mrk' file with all the occurrences of the events. The advantage of having such a file is that Muse will automatically read the events and plot them together with your continuous data.

You can open this file using a terminal, with the following command:

gedit run01_trans_tsss.mrk

To read these events on matlab, you can use the inhouse function my_ft_read_event.m:

Events = my_ft_read_event('run01_trans_tsss.mrk');

You will obtain a structure containing all the events found in the data, in the correct fieldtrip format (as in 1.a). For each trigger, you will have the following fields: the type (the name of the event), the value (possibly empty), the sample number, the duration and the offset.


c. Creating and reading events of interest

You can then rename the events (by writing a meaningful string in the field .type, for example 'StimPresentation'), create new events and add them to this structure or create new structures with subsets of events. For example, you can create new events corresponding to specific combinations of conditions or corresponding to clean data (ex: StimPresentation_noEOG, meaning that there are no EOG events in a time window of interest around the event StimPresentation). Creating specific events, corresponding to clean data, will make your life easier, because you can directly create your final epochs based on those events.

See here for tricks you can do to read and extract information from the events structure.

 

If you downsample your data, make sure the event sample numbers correspond to the new data sampling!

2. Epoching the data

Now that you have your events, you can epoch, e.g extract the data around the event of interest.

Check out the fieldtrip tutorial, here. 

Briefly, you epoch the data in two steps:

- you first define the epoch timings relative to the continuous data, using ft_definetrial. This function creates a Nx3 matrix where the first column is the first sample of each of the N epochs, the second column in the last sample of each epoch and the third sample is the offset. You can also create this matrix manually, if your epoch definition is more complex (ex: epochs with different lengths).

- you then use ft_redefinetrial to cut the data according to the epoch definition. This will output a data structure with all your data epochs.

 

Beware that filtering epoched data may lead to edge effets!

 

3. Averaging over trials

Once your data is cut into epochs, you may want to average them. For this, you can use the function ft_timelockanalysis.

You can't average epochs with different lengths, in that case this function will throw an error.

 

4. Averaging over subjects

To average EPRs/ERFs over a group of subjects, use the function ft_timelockgrandaverage.

You can specify

cfg.keepindividual = 'yes'; 

if you want the final data structure to contain the ERPs/ERFs of each subject.

Alternatively, use

cfg.keepindividual = 'no'; 

to get only the grand average ERP/ERF over all subjects.

 

5. Plotting

a. Timecourse of the ERP/ERF

You can use the function ft_singleplotER to plot the timecourse over a single channel or a group of channels (average across selected channels).

 

Example of a timecourse of a single channel:

b. Topography of the ERP/ERF

You can use the function ft_topoplotER to plot the topography of the ERP over a specified time window (data is averaged over this time window).

 

Example of a topography:

c. Multiplot

You can use the function ft_multiplotER to plot the timecourses of all channels, displayed according to their layout.

 

Example of a multiplot:

 

 

Related articles

 

  • No labels