When performing EEG/MEG experiments, the aim is to gain insight into the functioning of the brain while it is engaged in certain activities. When analyzing EEG/MEG data, we hope to identify the aspects of the data that relate to the experimental question. This means that we seek to reduce the data to interpretable concepts or statements regarding hypotheses underlying the experiment. The successful analysis of EEG/MEG data does not only depend on acquiring good quality data, but also on incorporating the researcher's knowledge and assumptions into the analysis protocol.
The analysis protocol includes tools and/or algorithms used, and how they are used. The knowledge or assumptions incorporated by the researcher in the protocols might be:
At a certain time after the presentation of a stimulus, the brain will process the stimulus.
The brain will process repeated stimuli similarly.
Electrical activity generated by the neurons in the brain has certain properties that distinguish it from artifacts, such as amplitude (eye movements result in much larger scalp potentials) or distribution (signals originating from the brain are picked up simultaneously by multiple neighboring electrodes).
The scalp distribution of the EEG/MEG depends on the location of the underlying activity.
Oscillatory activity is produced by certain brain regions.
The aspects of the data known by the researcher relevant to the experimental question should be used to decide which tools to use, and how to use them. In this workshop, we will discuss the use of some of the tools that are available in analyzing EEG/MEG data. These tools can be combined in an analysis protocol that for example looks like Figure 1.
Figure 1; Analysis protocol for Event-Related Potentials (ERPs)
We will use the FieldTrip toolbox for EEG/MEG analysis that is developed within the Donders Centre for Cognitive Neuroimaging (DCCN). This software consists of a set of Matlab functions (a toolbox) that implement the different steps. Each of the FieldTrip functions implements one tool, and by linking them you can perform a complete analysis. For the ERP example, this would result in the following protocol (see Figure 2).
Figure 2; FieldTrip toolbox functions in Matlab
The FieldTrip toolbox consists of functions for preprocessing (filtering, baseline correction, artifact detection, etc.), averaging, FFT frequency analysis, wavelet analysis, independent/principal component analysis, spatiotemporal dipole analysis, beamformer dipole analysis, and much more. It is continuously being developed and extended. An overview of its current functionality is given in figure 3.
Figure 3; All FieldTrip toolbox functions
Each of the functions of the toolbox takes as input the (intermediate) data that was produced by the previous function. Furthermore, you can specify the exact details of each analysis step.
Each function is associated with a configuration structure. The structure defines the parameters used by the functions. Several of these parameters have sensible default settings. The configuration is specified as Matlab scripts. The configuration for ft_definetrial (for ctf data that is recorded in epochs) might look like this:
cfg1 = [];
cfg1.dataset = 'Subject01.ds';
cfg1.trialdef.eventtype = 'backpanel trigger';
cfg1.trialdef.eventvalue = 3; % the value of the stimulus trigger for fully incongruent (FIC).
cfg1.trialdef.prestim = 1;
cfg1.trialdef.poststim = 2;
The function in the FieldTrip toolbox are executed with the configuration structure (“cfg”) and in most cases with a data structure as inputs
Examples:
cfg1 = ft_definetrial(cfg1);
dataPrepro = ft_preprocessing(cfg1);
cfg2 = [];
dataTimelock = ft_timelockanalysis(cfg2,dataPrepro);
The help included in each function will explain the configurable settings and how they should be specified. In Matlab, you can get help for a specific function by typing
help <function name>
e.g.
help ft_preprocessing
How to make analysis protocols for different types of analysis using the FieldTrip toolbox can be found in the tutorials at this website.
TODO complete the description of the main data formats (raw, comp, timelock, freq, source, volume)
The output of a FieldTrip function is a data structure of a particular type. Such data structure consists at least of numeric data specific to that particular datatype, and of descriptive fields which are needed to interpret the data. The different datatypes and their features are listed below:
The raw datatype is sensor level time domain data typically obtained after a call to ft_preprocessing. It contains the following fields:
hdr: [1x1 struct] containing the headerfile information (.res4 in CTF)
label: {307x1 cell} with the channel labels (e.g. 'MRC13')
time: {1x10 cell} with the timeaxis per trial (n=10)
trial: {1x10 cell} containing the samples per trial (n=10); the recorded data
fsample: 600 the samplefrequency
sampleinfo: [10x2 double] with the begin- and endsample of every trial in resp. 1st and 2nd column
grad: [1x1 struct] containing the headposition information
cfg: [1x1 struct] specifying the current and previous configuration
The freq datatype is sensor level frequency domain data obtained after a call to ft_freqanalysis. The cfg.method determines what the 'powspctrm' matrix looks like)
powspctrm: [307x15x600 double] contains the channels x frequency indices x timesamples
dimord: 'chan_freq_time' defines how the data is represented in the powspctrm matrix
label: {307x1 cell} with the channel labels (e.g. 'MRC13')
freq: [2 4 6 8 10 12 14 16 18 20 22 24 26 28 30] are the frequency indices
time: [1x600 double] is the timeaxis
cfg: [1x1 struct] specifying the current and previous configuration
(ft_timelockanalysis)
avg: [307x600 double] is the average amplitude over trials for every channel (n=307) and timesample (n=600)
var: [307x600 double] representing the variance over trials for every sample
fsample: 600, samplefrequency
time: [1x600 double] is the timeaxis of the average
dof: [307x600 double] contains the degrees of freedom (determined by n trials)
label: {307x1 cell} with the channel labels (e.g. 'MRC13')
dimord: 'chan_time' defines how the data is represented in the avg matrix
grad: [1x1 struct] containing the headposition information
cfg: [1x1 struct] specifying the current and previous configuration
* comp (ft_componentanalysis)
fsample: 600. samplefrequency
time: {1x10 cell} with the timeaxis per trial
trial: {1x10 cell} containing the samples per trial; the recorded data
topo: [307x307 double] is an NxN matrix with a component topography in each column
label: {307x1 cell} with the channel labels (e.g. 'MRC13')
topolabel: {307x1 cell} is an Nx1 cell-array with the channel labels
cfg: [1x1 struct] specifying the current and previous configuration
Use ft_rejectcomponent to reject components and backproject to channel level data
* spike
* volume
* source (ft_sourceanalysis)
dim: [6732 1] is the dimensions, the number of voxels
vol: [1x1 struct] contains the volume parameters
cumtapcnt: [10x1 double] has the number of tapers used per trial (n=10)
pos: [6732x3 double] contains the position of every voxel in x-,y-, and z-coordinates
inside: [1x3415 double] represents the voxels that are inside the brain
outside: [1x3317 double] represents the voxels that are outside the brain
method: 'rawtrial' defines how the data is represented
cfg: [1x1 struct] specifying the current and previous configuration
freq: 6, the frequency index
trial: [10x1 struct] contains the voxelpower per trial, when cfg.keeptrials = 'yes';
avg: [1x1 struct] contains the average voxelpower, when cfg.keeptrials = 'no';
FieldTrip is composed of a collection of scripts running in Matlab 7.x. The toolbox is platform independent (i.e. can run under Linux, Mac OS X and Windows). To start Matlab on Linux at the DCCN:
matlab78
It is now possible to execute the Matlab scripts by copying/pasting the relevant text from the tutorials (To copy from a Window browser to Matlab running under Linux from X-Win32, use the mouse to highlight the text in the browser and press Crtl-c. Then use Ctrl-v or the middle mouse button to paste in Matlab).
Make sure that the path is set correctly to the directory of the FieldTrip toolbox and the data. For the tutorials it is recommend to 'cd' to the directory where the data are. Look at this FAQ for more information on how to correctly set your path for FieldTrip.
Back to top