Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Prerequisite

For ERP computation, you need the following:

- matlab

- fieldtrip (see here for how to initialize fieldtrip)

...

Prerequisite

Continuous MEG/EEG data has been acquired.

Before following this tutorial, you should have performed the following operations on your data:

...

...

This tutorial uses the FieldTrip toolbox (see here for how to initialize FieldTrip)

Goal of this tutorial

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

This tutorial

...

complements the

...

FieldTrip tutorials on ERP computation

...

('Preprocessing - reading continuous EEG data' and 'Preprocessing of EEG data and computing ERPs'), and will give some additional information specific to the MEEG center.

Step-by-step guide

...

Table of Contents

...

minLevel

...

2

1. Dealing with events

a. Events in original fif format

...

Info
titleevents in FieldTrip

in FieldTrip, events are represented in a MATLAB structure:

For each trigger, you

...

have the following fields:

...

  • type: either the channel where triggers were recorded (e.g. STI101), or the name of the event

...

  • sample: the sample number

...

  • value: the value of the trigger
  • offset: usually an empty field
  • duration: the duration of the trigger (usually empty or a constant number)

a. Events in original .fif format

You can use the ft_read_event function.

This will give you a data structure,

...

with all the triggers found in the data.

These are the

...

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 '

...

.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
Warning
titledon't edit .mrk files by hand

Do not try to edit .mrk files by hand. These files are more intricate than they seem and other software will not be able to read it.

To read these events

...

in MATLAB, you can use the

...

...

  

Events = my_ft_read_event('run01_trans_tsss.mrk');

You will

...

get a structure containing all the events found in the data, in the correct

...

FieldTrip format (as

...

View file
namemy_ft_read_event.m
height150

...

shown above).

c. Editing 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.

 

Info

...

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, i.e.

...

extract the data around the event of interest.

Check out the

...

FieldTrip tutorial, here. 

Briefly, you epoch the data in two steps:

...

  1. Define 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).

...

  1. Use ft_redefinetrial to cut the data according to the epoch definition. This will output a data structure with all your data epochs.

 

Info

Beware that filtering epoched data may lead to edge

...

effects! See this page.

 

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.

Info

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:

Image Added

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:

Image Added

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:

Image Added

 

 

Related articles

Filter by label (Content by label)
cqllabel = "kb-how-to-article" and space = "CENIR" and type = "page"