[FieldTrip] strange leadfield for beamforming from template files

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Thu Mar 19 22:18:38 CET 2015

Hi Maurice,
The way in which you visualize the leadfield vectors it is hard to see in which locations the arrows are big. My suspicion is (unless otherwise proven) that you are suffering from numerical problems at dipole positions close to the inner boundary.

On Mar 19, 2015, at 12:34 PM, m.goeldi at psychologie.uzh.ch<mailto:m.goeldi at psychologie.uzh.ch> wrote:

Hi all

I am trying to do beamforming with my EEG data. I am using the template headmodel etc provided in fieldtrip to compute the leadfield.
Since my data looks strange I have visualized the leadfield expecting grid points close to the electrode to have a larger leadfield.
Unfortunately this is not the case. The vectors are all over the place. See figure.

The red circle is the electrode location (Cz).
The field looks (qualitatively) just as wrong for any other electrode.

Below is the code I used to generate & visualize the lead field.

I have used the same code to visualize the leadfield from a example MEG file from the fieldtrip page.
There the result is as expected, so I think the problem lies not in the visualization.

I am using fieldtrip-20150118

I have tried all the standard_sourcemodel3d*mm files. Qualitatively the error remains the same.

My question is, am I doing anything wrong in generating the lead field?
Am I expecting something wrong (i.e. is this a realistidc lead field?)
Does anyones lead field look the same/different when using the template files?

I would appreciate any help with this problem.

Thanks for your thoughts



% load mri
load('C:\Program Files\MATLAB\fieldtrip-20150118\template\headmodel\standard_mri.mat')

% load template sourcemodel
template = load('C:\Program Files\MATLAB\fieldtrip-20150118\template\sourcemodel\standard_sourcemodel3d8mm');

% compute source model
cfg                = [];
cfg.grid.warpmni   = 'yes';
cfg.grid.template  = template.sourcemodel;
cfg.grid.nonlinear = 'yes'; % use non-linear normalization
cfg.grid.resolution = 6;
cfg.mri            = mri;
sourcemodel        = ft_prepare_sourcemodel(cfg);
sourcemodel = ft_convert_units(sourcemodel, 'cm');

% make head model
load('C:\Program Files\MATLAB\fieldtrip-20150118\template\headmodel\standard_bem.mat');
vol = ft_convert_units(vol, 'cm');

%% electrode layout
elec = ft_read_sens('C:\Program Files\MATLAB\spm12\EEGtemplates\egi128_GSN_HydroCel.sfp');
[elec] = removeelectrodes(elec,data.label);    % remove the electrodes that are not in my data
elec = ft_convert_units(elec,'cm');

% lead field
cfg                 = [];
cfg.grid            = sourcemodel;
cfg.elec            = elec;
cfg.vol             = vol;
cfg.channel         = 'all';
[grid] = ft_prepare_leadfield(cfg,freqC1);
grid = ft_convert_units(grid, 'cm');

%%%% visualize leadfield %%%%
channel = 'Cz';

%% electrode position
elecpos = grid.cfg.elec.elecpos(strcmp(grid.cfg.elec.label,channel),:);

%% leadfield positions
leadfieldpos = grid.pos(grid.inside,:);

%% extract leadfield
npts = numel(grid.leadfield);
lead = grid.leadfield(grid.inside);

nchan = find(strcmp(grid.cfg.channel,channel));
for i = 1:numel(lead)
    leadVect(i,:) = lead{i}(nchan,:);

figure; hold on     % plot all objects in one figure
ft_plot_mesh(vol.bnd(3), 'edgecolor','none','facealpha',0.8,'facecolor',[0.6 0.6 0.8]);
ft_plot_mesh(vol.bnd(2), 'edgecolor','none','facealpha',0.8,'facecolor','y');
alpha 0.3
scale = 30;


University of Zürich
Maurice Göldi
Department of Psychology
Binzmühlestr. 14 / Box 5
CH - 8050 Zürich

Tel. +41 (0)44 635 74 55
maurice.goeldi at uzh.ch<mailto:maurice.goeldi at uzh.ch>
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150319/b58e1770/attachment-0002.html>

More information about the fieldtrip mailing list