Research Article

Forward Field Computation with OpenMEEG

Algorithm 2

Demo script for computing an EEG lead field with OpenMEEG in FieldTrip.
%% The structure for the BEM volume conduction model
% vol.bnd(k).pnt: vertices of the mesh of layer "k"
% vol.bnd(k).tri: triangles of the mesh of layer "k"
% vol.cond    : conductivities of each layer
%% EEG electrodes
% sens.pnt    : locations of the EEG electrodes
%% Positions of the dipoles
% pos         : positions of the dipoles
%% Compute the BEM
% choose implementation (OpenMEEG, BEMCP or Dipoli)
cfg.method = ‘openmeeg’;
% Compute the BEM matrix
vol = ft_prepare_bemmodel(cfg, vol);
cfg.vol = vol;
cfg.grid.pos = pos;
cfg.elec = sens;
% Get the computed leadfield
lf_openmeeg = ft_prepare_leadfield(cfg);