simulation of a dataset with multiple dipoles

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Fri Jul 29 16:45:01 CEST 2005


Hi Florian,

On 28-jul-2005, at 20:21, Florian Ph.S Fischmeister wrote:

> I am trying to simulate an EEG dataset containing multiple dipoles.
> I do
> understand, that I can have a single dipole with a different moment
> and
> time course per trial using cell-arrays. But how can I obtain multiple
> dipoles? Is it correct to simulate one dataset per dipol and than sum
> the different datasets?

Here is some sample Matlab code that hopefully explains step by step
how to construct a forward simulated potential distribution.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
% create a set of electrodes, randomly placed on the sphere
elec = [];
elec.pnt = randn(128,3);
dum = sqrt(sum(elec.pnt.^2,2));
elec.pnt = elec.pnt ./ [dum dum dum];  % scale them to a unit sphere
for i=1:128
   elec.label{i} = sprintf('%03d', i);
end

I suggest that you do not use these electrodes, but instead that you
get more meaningfull electrode locations (see for example http://
oase.uci.ru.nl/~roberto/index.php/electrode/).

% create a concentric 3-sphere volume conductor, the radius is the
same as for the electrodes
vol = [];
vol.r = [0.88 0.92 1.00]; % radii of spheres
vol.c = [1 1/80 1];       % conductivity
vol.o = [0 0 0];          % center of sphere

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
% create a dipole simulation with one dipole and a 10Hz sine wave
cfg = [];
cfg.vol  = vol;             % see above
cfg.elec = elec;            % see above
cfg.dip.pos = [0 0.5 0.3];
cfg.dip.mom = [1 0 0]';     % note, it should be transposed
cfg.dip.frequency = 10;
cfg.ntrials = 10;
cfg.triallength = 1;        % seconds
cfg.fsample = 250;          % Hz
raw1 = dipolesimulation(cfg);
avg1 = timelockanalysis([], raw1);
plot(avg1.time, avg1.avg);  % plot the timecourse

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
% create a dipole simulation with one dipole and a custom timecourse
cfg = [];
cfg.vol  = vol;               % see above
cfg.elec = elec;              % see above
cfg.dip.pos = [0 0.5 0.3];
cfg.dip.mom = [1 0 0]';       % note, it should be transposed
cfg.fsample = 250;            % Hz
time = (1:250)/250;           % manually create a time axis
signal = sin(10*time*2*pi);   % manually create a signal
cfg.dip.signal = {signal, signal, signal};  % three trials
raw2 = dipolesimulation(cfg);
avg2 = timelockanalysis([], raw2);
plot(avg2.time, avg2.avg);    % plot the timecourse

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
% create a dipole simulation with two dipoles and a custom timecourse
cfg = [];
cfg.vol  = vol;    % see above
cfg.elec = elec;   % see above
cfg.dip.pos = [
   0  0.5 0.3       % dipole 1
   0 -0.5 0.3       % dipole 2
   ];
cfg.dip.mom = [     % each row represents [qx1 qy1 qz1 qx2 qy2 qz2]
   1 0 0 0 0 0       % this is how signal1 contributes to the 6
dipole components
   0 0 0 1 0 0       % this is how signal2 contributes to the 6
dipole components
   ]';               % note, it should be transposed
time = (1:250)/250;
signal1 = sin(10*time*2*pi);
signal2 = cos(15*time*2*pi);
cfg.dip.signal = {[signal1; signal2]}; % one trial only
cfg.fsample = 250;                     % Hz
raw3 = dipolesimulation(cfg);
avg3 = timelockanalysis([], raw3);

> Currently I am using a 4 spherical shell model with
>   cfg.vol.r = [71 72 79 85];
>   cfg.vol.c = [0.3300 1 0.0042 0.3300];
>   cfg.vol.o = [0 0 0];
> taken from EEGLAB.
>
> What are the correct steps to obtain a BEM forward head-model based
> on an MRI
> for an individual electrode setting for dipolesimulation.

Fieldtrip does not contain code for segmenting an anatomical MRI in
such a way that one could make a BEM model out of it. Furthermore,
Fieldtrip also does not (yet) contain code for triangulating such a
segmentation and computing the BEM forward model. You can however use
an externally computed BEM model, but the only external software that
is supported is ASA (see http://www.ant-neuro.com/). Perhaps you can
download a demo version of that commercial software there, including
a BEM model that you can use inside Fieldtrip. EEG BEM models is
going to be supported more extensively in Fieldtrip, and also in the
upcoming eeglab- dipfit version 2.0 plugin, but for the moment we
cannot not support more than this yet.

> Finaly, I want to check the simulation using the dipolefitting routine
> included in fieldtrip. Could you please provide some information on
> how
> the appropriate cfg should look like.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
% do a dipole fit of the first simulated dataset
cfg = []
cfg.vol  = vol;         % see above
cfg.elec = elec;        % see above
cfg.dip.pos = [0 0 0];  % initial search position
cfg.gridsearch = 'no';
dip1 = dipolefitting(cfg, avg1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
% or start with an exhaustive search on a coarse grid
cfg = []
cfg.vol  = vol;         % see above
cfg.elec = elec;        % see above
cfg.gridsearch = 'yes';
cfg.xgrid = linspace(-1,1,5);
cfg.ygrid = linspace(-1,1,5);
cfg.zgrid = linspace(-1,1,5);
dip2 = dipolefitting(cfg, avg1);

You should be aware that an exhaustive search only works for a single
dipole, for two dipoles you always have to specify a starting
location for the nonlinear search.

best regards,
Robert

=================================================
Robert Oostenveld, PhD
F.C. Donders Centre for Cognitive Neuroimaging
Radboud University Nijmegen
phone: +31-24-3619695
http://www.ru.nl/fcdonders/



More information about the fieldtrip mailing list