Tags: tutorial source electrode

Localizing electrodes using a 3D-scanner


This tutorial demonstrates how to construct an electrode model based on a single subject’s 3D-scan. This electrode model can be used in combination with a BEM or FEM volume conduction model for source reconstruction.

This tutorial does not cover how to create a 2-D channel layout for plotting, nor how to do the source estimation itself.


The quality of EEG source estimates depends on the accuracy of the volume conduction models and of the sensor positions. The volume conduction model comprises a description of the geometry, of the conductivities and of a computational approach for solving Poisson’s equations. The current golden standard is to measure the head geometry with an MRI and the EEG electrode positions with a Polhemus electromagnetic digitizer. However, the Polhemus device is expensive and measuring the sensor positions with the Polhemus is time consuming, which can make it challenging or even impossible on specific subject groups.

In this tutorial we demonstrate the localization of EEG electrodes based on 3D-scan of a subject’s head. The specific device we are using is the structure sensor by Occipital. However, other 3D scanning devices would also work, as long as you can read the output of the 3D-scanner into MATLAB.

This youtube video shows the procedure that is explained in this tutorial


In this section we describe the procedure to acquire electrode positions with a 3D-Scanner

Recording data

The structure sensor is attached to an iPad mini. We use the Scanner - Structure Sensor Sample application on the iPad which is available from the Apple Store. This application allows us to capture our subjects head surface by just walking around the subject. Here you can download the result of the 3D-scan that we will use in this tutorial.

Loading and coregistering data

Before starting with FieldTrip, it is important that you set up your MATLAB path properly.


Then you can load the data (this might take some time)

head_surface = ft_read_headshape('Model/Model.obj')

      pos: [553494x3 double]
      tri: [800000x3 double]
     unit: 'm'
    color: [553494x3 uint8]

We convert the units to mm.

head_surface = ft_convert_units(head_surface, 'mm');

We visualize the mesh surface


Figure 1: Mesh recorded with 3D-scanner

In the next step we will transform our mesh into CTF coordinates. For this we have to specify the nasion (NAS), left preauricular (LPA) and right preauricular (RPA) points.

cfg = [];
cfg.method = 'headshape';
fiducials = ft_electrodeplacement(cfg, head_surface);

Now that we have the position of the fiducials relative to the original coordinate system of the head surface, we are able to coregister our head surface such that the fiducial positions are along the axes (according to the CTF coordinates). To facilitate the identification of the fiducials in the 3D-scan, you can also mark the locations on your subject with a coloured pen.

Figures: Location of the fiducials

cfg = [];
cfg.method        = 'fiducial';
cfg.coordsys      = 'ctf';
cfg.fiducial.nas  = fiducials.elecpos(1,:); %position of NAS
cfg.fiducial.lpa  = fiducials.elecpos(2,:); %position of LPA
cfg.fiducial.rpa  = fiducials.elecpos(3,:); %position of RPA
head_surface = ft_meshrealign(cfg, head_surface);

Again we visualize the head surface, and now we also plot the axes of the coordinate system along with it.


Figure: Realigned head surface

Identify electrode locations

The previous step ensured that our head surface is in the coordinate system in which we want the electrode positions to be defined. We continue with identifying the electrode locations. With the structure sensor 3D-scanner, the texture mapping (i.e. the photo) is not fitting the structural data (i.e. the geometry), so for identifying the electrode locations we ignore the texture mapping and just rely on the bumps corresponding to the electrodes.

cfg = [];
cfg.method = 'headshape';
elec = ft_electrodeplacement(cfg, head_surface);

Figure: Identifying electrode locations

Assign electrode labels

The next step is to assign the labels to all electrodes. In the specific case, we used an electrode cap from Easycap that has the electrodes in the M10 arrangement.

The call to ft_electrodeplacement returns default electrode labels as ‘1’,’2’,… and so on, which is correct for the first 60 electrodes. To assign the correct labels to the reference, ground and to the anatomical landmarks (NAS, LPA and RPA), we use the following piece of MATLAB code:

elec.label(61:65) = { ...

Visualize the electrodes in 3D

A final visualization shows the electrodes on the colored surface mesh of the subject.


Figure: Head surface with localized electrodes

Moving electrodes inward

The electrode location are now digitized on the outer surface of the scanned surface. In the figures you can see the plastic ring in which the electrodes are plugged. However, the contact with the skin is realized by injecting electrode gel. We can correct for the mismatch between outer surface of the electrode holder and the skin surface by moving the electrode locations inward according to their normals. Usig the following code, we are moving inward by 12 mm.

cfg = [];
cfg.method     = 'moveinward';
cfg.moveinward = 12;
cfg.elec       = elec;
elec = ft_electroderealign(cfg);

Summary and further reading

In this tutorial we demonstrated how to extract electrode positions from a 3D scanned head surface. The resulting electrode model can be used for volume conduction model, or in the construction of a 2D layout for data visualization.

We suggest you read the frequently asked question about coordinate systems to understand the different coordinate systemsin which data can be expressed. Since electrode models are often used in source reconstruction, we also suggest you to read the tutorials about BEM and FEM volume conduction models.