# [FieldTrip] Dipole Moment Question from forward simulated data example

Simon Homolle s.homolle at donders.ru.nl
Wed Mar 23 10:35:10 CET 2016

```Dear Srinivas Kota,

So what you did here is simulate a dipole which changes its moment over time (refer to help ft_dipolesimulation)

So the resulting dipole position it computed is something like [5.2523e-08 0.5000 0.3000]. However if you look at dip1.dip.mom you see it as [3x250 double] matrix. The first entry is the [1 0 0] which you were looking for and all the the other describe the moment at a different timepoint. If you have a quick look at plot(dip1.dip.mom(1,:)) you see the oscillation of the dipole.

Bests,

Simon Homölle
PhD Candidate
Donders Institute for Brain, Cognition and Behaviour
Centre for Cognitive Neuroimaging
Phone: +31-(0)24-36-65059

> On 22 Mar 2016, at 20:09, Srinivas Kota <svkotak at yahoo.com> wrote:
>
> I am working on simulated data example provided in the fieldtrip toolbox webpage. When I find the dipole moment after dipole fitting is [-1 0 0], where as original dipole mom was [1 0 0]. I was not sure if I am calculated dipole moment correctly. Any help would be appreciated.
> Thank you.
> Srinivas
>
> % http://www.fieldtriptoolbox.org/example/compute_forward_simulated_data_and_apply_a_dipole_fit
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> % 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
>
> vol = [];
> vol.r = [0.88 0.92 1.00]; % radii of spheres
> vol.cond = [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 = 1;
> cfg.triallength = 1; % seconds
> cfg.fsample = 250; % Hz
> raw1 = ft_dipolesimulation(cfg);
> avg1 = ft_timelockanalysis([], raw1);
> plot(avg1.time, avg1.avg); % plot the timecourse
> % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> % 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 = ft_dipolefitting(cfg, avg1);
> [u,s,v] = svd(dip1.dip.mom);
> if s(1,1) > s(2,2)
> dipole_orientation = u(:,1);
> end
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

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