Creating a volume conduction model of the head for sourcereconstruction of MEG data
Introduction
This tutorial describes how to construct a volume conduction model of the head (head model) based on an indivdual subject’s MRI. We will use the anatomical images that belong to the same subject whose data were analyzed in the preprocessing and averaging tutorials (Triggerbased trial selection, Event related averaging and planar gradient). The corresponding anatomical MRI data is available from the FTP server.
The volume conduction model of the head that will be constructed here is specific to the computation and source reconstruction of MEG data. Different strategies can be used for the construction of head models. The processing pipeline of the tutorial is an example which we think is the most appropriate for the tutorialdataset.
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 eventrelated fields using minimumnorm estimate tutorials.
The volume conduction model created here is MEG specific and cannot be used for EEG source reconstruction. If you are interested in EEG source reconstruction methods, you can go to the corresponding EEG tutorial.
Background
The EEG/MEG signals measured on the scalp do not directly reflect the location of the activated neurons. To reconstruct the location and the timecourse or spectral content of a source in the brain, various sourcelocalization methods are available. You can read more about the different methods in review papers suggested here.
The level of the activity at a source location is estimated from
 the EEG/MEG activity measured on (around) the scalp
 the spatial arrangement of the electrodes/sensors (channel positions),
 the geometrical and electrical/magnetic properties of the head (head model)
 the location of the source (source model)
Using this information, source estimation comprises two major steps: (1) Estimation of the potential or field distribution for a known source and for a known model of the head is referred to as forward modeling. (2) Estimation of the unknown sources corresponding to the measured EEG or MEG is referred to as inverse modeling.
The forward solution can be computed when the head model, the channel positions and the source is given. For distributed source models and for scanning approaches (such as beamforming), the source model is discretizing the brain volume into a volumetric or surface grid. When the forward solution is computed, the lead field matrix (= channels X source points matrix) is calculated for each grid point taking into account the head model and the channel positions.
A prerequisite of forward modeling is that the geometrical description of all elements (channel positions, head model and source model) is registered in the same coordination system with the same units. There are different “conventions” how to define a coordinate system, but the precise coordinate system is not relevant, as long as all data is expressed in it consistently (i.e. in the same coordinate system). Here read more about how the different head and mri coordinate systems are defined. The MEG sensors by default are defined relative to anatomical landmarks of the head (the fiducial coils), therefore when the anatomical images are also aligned to these landmarks, the MEG sensors do not need to be realigned. EEG data is typically not aligned to the head, therefore, the electrodes have to be realigned prior to sourcereconstruction (see also this faq and this example).
Figure 1. Major steps in source reconstruction
This tutorial is focusing on how to build the volume conduction model for the head.
In FieldTrip a volume conduction model is represented as a MATLAB structure which is usually indicated with the variable name vol. It describes how the currents flow through the tissue, not where they originate from. In general it consists of a description of the geometry of the head, a description of the conductivity of the tissue, and mathematical parameters that are derived from these. Whether and how the mathematical parameters are described depends on the computational solution to the forward problem either by numerical approximations, such as the boundary element and finite element method (BEM and FEM), or by exact analytical solutions (e.g. for spherical models).
The more accurate the description of the geometry of the head or the source, the better the quality of the forward model. There are many types of head models which, to various degrees, take the individual anatomy into account. The different head models available in FieldTrip are listed here.
In this specific tutorial we will use a semirealistic head model developed by Nolte (2003) that assumes a realistic information about the interface between the brain and the skull. This outer brain surface will be extracted from the anatomical MRI images of the subject. First, we will use anatomical MRI of the subject to extract the brain surface from the anatomical images, which is termed segmentation. Note that the segmentation procedure is quite time consuming. Following the segmentation of the anatomical images, a description of the surface using vertices and triangles is constructed. Finally, the singleshell head model will be computed.
If an anatomical MRI is not available for your MEG subject, you can consider to use a template MRI or a template head model that is located in the FieldTrip template directory. If you do not have an MRI, but if you do have a measurement of the scalp surface (e.g. with a Polhemus tracker), you can use a local spheres volume conduction model. If you do not want to (or cannot) use any realistic information about the brainsurface or the headshape, you can resort to the single sphere volume conduction model.
Procedure
We will create a head model based on the anatomical mri of the tutorial data set which is available here. The pipeline is depicted in Figure 2.
 First, we will read the anatomical data with ft_read_mri;
 then we segment the anatomical information into different tissue types with ft_volumesegment;
 and create the headmodel with ft_prepare_headmodel.
 Finally, we will check the geometry of the head model by plotting it with ft_plot_headmodel.
Figure 2. Pipeline of creating and visualizing a head model
Reading in the anatomical data
Before starting to use FieldTrip, it is important that you set up your MATLAB path properly. You can read about how to set up your MATLAB path here.
cd PATH_TO_FIELDTRIP
ft_defaults
Then, you can read in the mri data.
mri = ft_read_mri('Subject01.mri');
disp(mri)
dim: [256 256 256]
anatomy: [256x256x256 int16]
hdr: [1x1 struct]
transform: [4x4 double]
unit: 'mm'
coordsys: 'ctf'
The structure of your mri variable contains the following field
 dim: This field gives information on the size (i.e. the number of voxels) of the anatomical volume into each direction.
 anatomy: This is a matrix (with the size and number of dimensions specified in dim) that contains the anatomical information represented by numbers.
 hdr: Header information of the anatomical images.
 transform: A transformation matrix that aligns the anatomical data (in field anatomy) to a certain coordinate system.
 coordsys: The description of the coordinate system which the anatomical data is aligned to.
You can see that the coordsys field of anatomical data that we read in is already aligned to the ctf coordinate system. This can be done using the CTF specific MRIConverter and MRIViewer software as outlined here or using the ft_volumerealign function.
It is also possible to read in anatomical MRI data in other formats, which are defined in a different coordinate system. If your anatomical MRI is not aligned to the ctf coordinate system, it can be aligned using ft_volumerealign function. For this, you will need to align your MRI to the fiducial points.
When you read in your own anatomical data, it may not give information on the coordinate system in which the anatomical data is expressed and/or maybe there is no transformation matrix specified. In this case, you can check the coordinatesystem with the ft_determine_coordsys function.
Segmentation
In this step, the voxels of the anatomical MRI are segmented (i.e. separated) into different tissue types . By default, the gray matter, white matter and the cerebrospinal fluid (csf) compartments are differentiated. Based on these compartments a so called brainmask is created, which is a binary mask of the content inside the skull. All voxels that are inside the skull (i.e. the complete brain) are represented by 1, all other voxels by 0. The function ft_volumesegment will produce the required output.
Note that the segmentation is quite time consuming and if you want you can load the result and skip ahead to the next step. You can download the segmented MRI of this tutorial data from the FTP server (segmentedmri.mat).
cfg = [];
cfg.output = 'brain';
segmentedmri = ft_volumesegment(cfg, mri);
save segmentedmri segmentedmri
disp(segmentedmri)
dim: [256 256 256]
transform: [4x4 double]
coordsys: 'ctf'
unit: 'mm'
brain: [256x256x256 logical]
cfg: [1x1 struct]
The segmentedmri data structure contains the following field

dim

transform

coordsys

unit: unit of measurement of the voxels

brain: binary brainmask

cfg: configuration information of the function which created segmentedmri
The segmentation does not change the coordinate system, nor the size of the volume. You can see this in the first three fields (dim, transform and coordsys) which are the same as the corresponding fields of the input mri data structure. But now, the field transform aligns the matrix in field brain (which contains the brainmask) to the coordinate system defined in the coordsys field.
Alternatively, you can also leave out the definition of the cfg.output. In this case, the function will output the default segmentation that are the probabilistic values of the gray, white and csf compartments. In this case, the brain mask will be automatically created in the next step by the ft_prepare_headmodel function. For further information on the different segmentation options, read the help of ft_volumesegment.
Head model
Once the brain mask is segmented out of the anatomical MRI, a surface description of the brain is constructed and the volume conduction model . We will specify method ‘singleshell’ to build the head model in the cfg.method field using ft_prepare_headmodel.
cfg = [];
cfg.method='singleshell';
vol = ft_prepare_headmodel(cfg, segmentedmri);
save vol vol
disp(vol)
bnd: [1x1 struct]
type: 'singleshell'
unit: 'mm'
cfg: [1x1 struct]
The vol data structure contains the following field

bnd: contains the geometrical description of the head model.

type: describes the method that was used to create the headmodel.

unit: the unit of measurement of the geometrical data in the bnd field

cfg: configuration of the function that was used to create vol
The bnd field describes a surface with vertices and triangles (in the bnd.pnt and bnd.tri fields) as the geometrical description of the volume conductor.
This tutorial does not intend to make a elaborative comparison of the different volume conduction models, nor to discuss their relative merits.
The method used in this tutorial is based on Nolte G. (2003) The magnetic lead field theorem in the quasistatic approximation and its use for magnetoencephalography forward calculation in realistic volume conductors. We recommend this method for most general MEG situations.
The paper Lalancette M, Quraan M, Cheyne D. (2011) Evaluation of multiplesphere head models for MEG source localization discusses another popular method for MEG forward modeling, which is based on fitting local spheres to the surface. This alternative method can be used by specifying ‘localspheres’ as method in ft_prepare_headmodel.
Alternatively, you can also create and use a multiplelayered head model with Openmeeg. For this you can follow the procedure described in the tutorial for creating a volume conduction model for EEG data
Visualization
The head model (vol) contains the brainskull boundary as the geometrical description of the head. You can visualize this using the following code. First, we will plot the sensors (MEG channels) with the ft_plot_sens function. Second, we will plot the head model with ft_plot_headmodel in the same figure with the sensors. In order to plot also the location of the MEG channels, we read in the location of the channels using the .ds file from the tutorial data and the ft_read_sens function. (The .zip file that can be downloaded from the FieldTrip FTP server also contains the .ds file.) The units of the headmodel are defined in ‘mm’, while the units of the sensors are in ‘cm’. When we plot the headmodel together with the sensors, they need to have the same units. Therefore, the units of the headmodel will be converted to ‘cm’ with the ft_convert_units function.
vol = ft_convert_units(vol, 'cm');
sens = ft_read_sens('Subject01.ds', 'senstype', 'meg');
figure
ft_plot_sens(sens, 'style', '*b');
hold on
ft_plot_headmodel(vol);
Figure 3. The geometry of the volume conduction model of the head using method “singleshell”
When the figure is plotted, you can look at the figure from different views using the curved arrow in the MATLAB figure menu. Note that there are 4 channels hovering above the normal channels; those are the MEG reference channels that can be used for environmental noise suppression.
Exercise 1
Create a head model with method ‘singlesphere’ that you fit on the inside brain surface, i.e. using the output of the already made segmentation.
Plot both head models in the same figure, check the help of ft_plot_headmodel for further options of the visualization (e.g. color, transparency) which help to see the two head models together.
What is the difference between the head models?
Exercise 2
In exercise 1, you created a head model with method ‘singlesphere’. How is its geometrical description defined? What is the difference between the fields of the single sphere and singleshell model which contain the geometrical description?
Summary and further reading
In this tutorial, it was explained how to build a volume conduction model of the head using a single subject anatomical mri and the single shell method developed by Nolte (2003). In the exercises, we compared the head model to a single sphere that was fitted on the inside brain surface.
You can read more about specific sourcereconstruction methods in the Localizing oscillatory sources using beamformer techniques and in the Source reconstruction of eventrelated fields using minimumnorm estimate tutorials.
Here are the related FAQs:
 Can I do combined EEG and MEG source reconstruction?
 How is the segmentation defined?
 How to coregister an anatomical MRI with the gradiometer or electrode positions?
and the related examples: