error in prepare_leadfield

Michiel van Elk m.vanelk at DONDERS.RU.NL
Wed Nov 5 17:08:18 CET 2008

Hi there,

On the basis of the standar BEM model that is available on the Fieldtrip 
website I tried to prepare the grid on the basis of the standard electrode 
positions. The 'prepare_leadfield' seems to run fine, but after a couple of hours 
I get the following error message (note that I removed the 'computing 
leadfield' statements): 

selected 60 electrodes
projecting electrodes on skin surface
combining electrode transfer and system matrix
791211 dipoles inside, 7215640 dipoles outside brain
making tight grid
791211 dipoles inside, 692565 dipoles outside brain
??? SWITCH expression must be a scalar or string constant.

Error in ==> progress at 94
  switch t

Error in ==> prepare_leadfield at 236

Does someone have a clue what could have gone wrong in this analysis? I 
used the following cfg settings (e.g. is it correct to convert the elec.pnt from 
cm to mm?)

cfg                        = [];
cfg.elec                  = GA_CSD_ANIMAL.elec;
cfg.elec.pnt            = cfg.elec.pnt*10;%convert from cm to mm!
cfg.vol                   = vol;
cfg.reducerank        = 2;             = {'EEG'};
cfg.grid.resolution     = 1;
[grid]                    = prepare_leadfield(cfg);


The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also and

More information about the fieldtrip mailing list