[FieldTrip] EEG source reconstruction with template - elec file

Silvia Formica Silvia.Formica at UGent.be
Mon Jan 14 10:39:17 CET 2019

Thank you all for your very useful contributions!

I noticed that in my case the method "project" gives nice results, so I'm currently using that one.



From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Homölle, S. (Simon) <S.Homolle at donders.ru.nl>
Sent: 10 January 2019 17:12
To: FieldTrip discussion list
Subject: Re: [FieldTrip] EEG source reconstruction with template - elec file

Dear Silvia,

I also can suggest you look at some of the tutorials here <http://www.fieldtriptoolbox.org/tutorial/headmodel_eeg_bem/> and here​<http://www.fieldtriptoolbox.org/tutorial/headmodel_eeg_fem/>.

Especially the latter part of both tutorials deal with your current problem!


Simon Homölle
PhD Candidate
Donders Institute for Brain, Cognition and Behaviour
Centre for Cognitive Neuroimaging
Radboud University Nijmegen
Phone: +31-(0)24-36-65059
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Silvia Formica <Silvia.Formica at UGent.be>
Sent: Thursday, January 10, 2019 4:05 PM
To: FieldTrip discussion list
Subject: Re: [FieldTrip] EEG source reconstruction with template - elec file

Dear Julian,

thanks for your quick response!

You are absolutely right, my problem was that I was not creating the elec file correctly as a struct with the fields chanpos, elecpos and label.

I'm now facing another problem, though. I'm trying to use ft_electroderealign, but I can't seem to achieve a satisfying result. Here is what I am doing:

cfg = [];
cfg.method    = 'headshape';
%     cfg.warp        =
cfg.elec      = elec;
cfg.headshape = vol.bnd(1);
elec_new = ft_electroderealign(cfg);

I then try to plot overlaid the skin surface as loaded from 'standard_skin_14038.vol' and the new electrode location but I get inconsistent results, the electrodes are always inside the head. I tried different warping methods without success. This is the closest I managed to get:


Do you have any recommendation on how to better align the electrodes to the template?



From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Julian Keil <julian.keil at gmail.com>
Sent: 10 January 2019 11:58
To: FieldTrip discussion list
Subject: Re: [FieldTrip] EEG source reconstruction with template - elec file

Dear Silvia,

how is the electrode location information from the BioSemi website not enough?
Basically, you can create your own electrode definition by giving the labels and locations to a structure, e.g.
elec.label{1} = 'Fp1';
elec.chanpos(1,:) = [-27.0333934563814, 83.2002299946862, -3.05493522574547];

or for all your electrodes in one go:
elec.label = {'Fp1','AF7','AF3','F1','F5'};
elec.chanpos = [-27.0333934563814, 83.2002299946862, -3.05493522574547;...
-51.4205700085246, 70.7743429000555, -3.05493522574547;...
-35.5608995849164, 76.2605952593987, 24.1279774030766;...
-25.1195714566887, 62.1731210759014, 56.2665567427342;...
-47.7073482911603, 58.9136687505812, 43.7676114900325];


or of course read them more elegantly from a text file ;-)

It might be a good idea to double check the alignment with the template headmodel afterwards using ft_electroderealign
You can then use this elec structure in all subsequent analyses.

I hope that helps,


On Thu, Jan 10, 2019 at 10:59 AM Silvia Formica <Silvia.Formica at ugent.be<mailto:Silvia.Formica at ugent.be>> wrote:

Dear all,

I have a EEG dataset, collected with a Biosemi system with 64 channels. I don't have the individual anatomical data for each participant, but I want to perform source reconstruction to have at least a rough localization of the activation I find.

Therefore, I intend to use the templates provided by fieldtrip. If I understand correctly, independently of the source modelling technique that I will choose to use, I need the following information:

1) the head model : this would be the template 'standard_bem'

2) the source model : the template 'cortex_5124.surf.gii'

3) the elec information :​ this file should describe the spatial configuration of the electrodes, but I can't retrieve it. I don't think any of the templates available fits my data (they all have more than 64 channels and different configurations).

I tried to use the function ft_read_sens on my data but I get the following error

elec    = ft_read_sens([data_filt5.mat'],'senstype','eeg');

Undefined function or variable 'lab'.

Error in channelposition (line 316)
n   = size(lab,2);

Error in ft_datatype_sens (line 349)
        [chanpos, chanori, lab] = channelposition(sens);

Error in ft_datatype_sens (line 158)
    sens = ft_datatype_sens(sens, 'version', '2011v2');

Error in ft_read_sens (line 380)
sens = ft_datatype_sens(sens);

I found the cartesian coordinates of the electrodes on the Biosemi website, with the x y z coordinates for each electrodes (as the little example I'm giving below, but that's not enough.

Channel             x                                        y                                        z
Fp1                 -27.0333934563814 83.2002299946862 -3.05493522574547
AF7                 -51.4205700085246 70.7743429000555 -3.05493522574547
AF3                 -35.5608995849164 76.2605952593987 24.1279774030766
F1                     -25.1195714566887 62.1731210759014 56.2665567427342
F5                     -47.7073482911603 58.9136687505812 43.7676114900325

...                   ​    ...                                        ...                                    ...

Do you have any suggestions on how to create a correct elec file fitting my data?

Any help would be highly appreciated!


fieldtrip mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190114/93bdbd1a/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 82198 bytes
Desc: pastedImage.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190114/93bdbd1a/attachment-0002.png>

More information about the fieldtrip mailing list