This page is under construction. Stay tuned!

Creating a sourcemodel for source-reconstruction of MEG or EEG data


In this tutorial you can find information about how to construct a source model that can be used for source reconstruction of EEG or MEG data. The source model describes a set of positions (and possibly orientations) of equivalent current dipoles that are taken into consideration when doing the source reconstruction. Note that not all source reconstruction methods require an explicit definition of a source model. Note also, that by and large source models should have the same specifications, irrespective of whether you are reconstructing EEG or MEG data. In this tutorial we will show how to use subject-specific anatomical data to create different types of source models. Which source model is most appropriate depends on the source reconstruction algorithm used, the additional analysis steps you have in mind, and on your own preferences. The anatomical MRI data is available from the ftp server.

This tutorial will not show how to perform the source reconstruction itself. If you are interested in source reconstruction methods, you can go to the Localizing oscillatory sources using beamformer techniques and to the Source reconstruction of event-related fields using minimum-norm estimate tutorials.


Depending of the source reconstruction algorithm you want to use, you have to a priori specify a model that describes the locations of the sources (and sometimes the orientation) that you want to take into account. Specifically, this pertains to distributed source modelling approaches (e.g. Minimum Norm Estimation procedures), and for scanning approaches (e.g. beamformers). Dipolefitting approaches in general do not require an a priori source model (apart from when you want to use the option 'gridsearch'). In general, one could construct a source model that defines positions of dipoles on a 3-dimensional grid (this is sometimes referred to as a volumetric source model), or on a 2-dimensional surface (typically the cortical sheet).


We will describe a few different ways to create a source model based on the anatomical mri of the tutorial data set which is available here. Some of these procedures can be done entirely using high-level FieldTrip functions. Other procedures require the use of external software, in particular Freesurfer, or HCP-workbench.

  • Construction of a source model based on a regular 3-dimensional grid of dipole positions;
  • Construction of a source model based on a surface description of the cortical sheet;
  • Performing group analysis on 3-dimensional source-reconstructed data.
  • Performing group analysis on cortical-sheet based source-reconstructed data.

Figure 2. Pipeline of creating a sourcemodel

Construction of a source model based on a regular 3-dimensional grid of dipole positions

Content is coming soon!

Construction of a source model based on a surface description of the cortical sheet

Content is coming soon! For now, you can have a look at the source model section of the minimumnormestimate tutorial.

Performing group analysis on 3-dimensional source-reconstructed data

When you are doing a group study, where you want to combine the source-reconstructed data across multiple subjects, you can do in several ways:

  1. Interpolation of functional data followed by volumetric spatial normalization;
  2. Anticipate the spatial normalization, and perform source-reconstruction for each subject on a subject-specific grid, that maps onto a template grid in spatially normalized space.

We recommend the second strategy, but for completeness we also describe the first strategy.

Interpolation, followed by spatial normalization

This is the simplest method, but not the most accurate. You start with a single subject source estimation on a 3D grid that is constructed individually for each subject. After computing the source estimate (i.e. the “functional data”), you interpolate the functional data onto the anatomical data using ft_sourceinterpolate. Subsequently you spatially transform the anatomical and the functional data for each subject to the MNI template using ft_volumenormalise. Having done that for every subject, all data is expressed in MNI coordinates and can be statistically compared between conditions over all subjects.

Subject-specific grids that are equivalent across subjects in normalized space


The idea is to use a template grid that is defined in normalized space, e.g. based on a template anatomical MRI in MNI coordinates. Subsequently, each individual MRI is warped to this template MRI, and the inverse of this warp is applied to the template dipole grid. Hereby the individual subjects' grids are not regularly spaced anymore (meaning the distance between 2 grid points can vary), see figure 1. However, as a consequence of this warping procedure, homologous grid points across subjects are located at exactly the same location in normalized MNI space. As a consequence, the source-reconstructed activity can be directly averaged across subjects. You can either define a template grid yourself, or use one from a set of predefined template grids that are included in fieldtrip: fieldtrip/template/sourcemodel/standard_gridXmm.mat.


fig 1a: Example: the MNI template brain and the brains of 3 subjects


fig 1b: Example: the MNI grid and the grid of 3 subjects, note that each grid point points to the same location in all brains, and that the subjects' grids are not regularly spaced

In the figures above, the spatial deformation of the individual subjects' brains relative to the template brain is exemplified. However, there may be other relevant differences between the coordinate system used for the individual subjects' anatomy and the MNI coordinate system. For example, in MEG-datasets it is custom to use a coordinate system that is defined relative to the three coils that are placed on the nose and the ears, with a specific orientation of the coordinate axes, whereas the MNI/SPM coordinate system is defined in a different way.

First, you need to define a template grid, as mentioned above, and the easiest thing to do so is to load in a pre-existing template grid, like this:

Load a template_grid, recommended
% NOTE: the path to the template file is user-specific
ftpath   = '/home/common/matlab/fieldtrip'; % this is the path to fieldtrip at Donders
load(fullfile(ftpath, 'template/sourcemodel/standard_sourcemodel3d10mm');
template_grid = sourcemodel;
clear sourcemodel;

As an alternative you can create a template grid yourself, like this:

Make a template_grid, only if you really want to
% NOTE: the path to the template file is user-specific
ftpath   = '/home/common/matlab/fieldtrip'; % this is the path to fieldtrip at Donders
template = ft_read_mri(fullfile(ftpath, '/external/spm8/templates/T1.nii'));
template.coordsys = 'spm'; % so that FieldTrip knows how to interpret the coordinate system
% segment the template brain and construct a volume conduction model (i.e. head model): 
% this is needed to describe the boundary that define which dipole locations are 'inside' the brain.
cfg          = [];
template_seg = ft_volumesegment(cfg, template);
cfg          = [];
cfg.method   = 'singleshell';
template_headmodel = ft_prepare_headmodel(cfg, template_seg);
template_headmodel = ft_convert_units(template_headmodel, 'cm'); % Convert the vol to cm, because the CTF convenction is to express everything in cm.
% construct the dipole grid in the template brain coordinates
% the negative inwardshift means an outward shift of the brain surface for inside/outside detection
cfg = [];
cfg.grid.resolution = 1;
cfg.grid.tight      = 'yes';
cfg.inwardshift     = -1.5;
cfg.headmodel       = template_headmodel;
template_grid       = ft_prepare_sourcemodel(cfg);
% make a figure with the template head model and dipole grid
hold on
ft_plot_vol(template_headmodel, 'facecolor', 'cortex', 'edgecolor', 'none');alpha 0.5; camlight;


fig 2: template grid and headmodel, top view

Make the individual subjects' volume conduction model
% read the single subject anatomical MRI, this should be aligned to MEG head coordinates 
% if the MRI is not aligned, you should use ft_volumerealign
mri = ft_read_mri('Subject01.mri');
% segment the anatomical MRI
cfg        = [];
cfg.output = 'brain';
seg        = ft_volumesegment(cfg, mri);
% construct the volume conductor model (i.e. head model) for each subject
% this is optional, and for the purpose of this tutorial only required for
% plotting, later on
cfg        = [];
cfg.method = 'singleshell';
headmodel  = ft_prepare_headmodel(cfg, seg);
Make the individual subjects' grid
% create the subject specific grid, using the template grid that has just been created
cfg                = [];
cfg.grid.warpmni   = 'yes';
cfg.grid.template  = template_grid;
cfg.grid.nonlinear = 'yes';
cfg.mri            = mri;
cfg.grid.unit      ='mm';
grid               = ft_prepare_sourcemodel(cfg);
% make a figure of the single subject headmodel, and grid positions
figure; hold on;
ft_plot_vol(headmodel, 'edgecolor', 'none', 'facealpha', 0.4);


fig 3: template grid in single-subject head coordinates, superimposed onto the headmodel

Keep in mind that the .pos field in the source models are subject specific. When you want to do group analysis across subjects, which now in principle is allowed due to the equivalence of the dipole positions in normalized space, you need to replace the positions with the normalized positions of the template sourcemodel. Otherwise, FieldTrip will throw an error.

Performing group analysis on cortical-sheet based source-reconstructed data

Content is coming soon!

Summary and further reading

In this tutorial, it was explained how to build a sourcemodel that can be used for source-reconstruction of measured EEG or MEG activity.

You can read more about specific source-reconstruction methods in the Localizing oscillatory sources using beamformer techniques and in the Source reconstruction of event-related fields using minimum-norm estimate tutorials.

Here are the related faqs:

and the related example scripts:

tutorial/sourcemodel.txt · Last modified: 2016/12/13 15:51 by robert

You are here: starttutorialsourcemodel
CC Attribution-Share Alike 3.0 Unported Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0
This DokuWiki features an Anymorphic Webdesign theme, customised by Eelke Spaak and Stephen Whitmarsh.
Mobile Analytics Website Security Test