Source simulation

Hi all,

I would like to simulate a dipole and do the inverse solution. For this I tried to note down the vertex number so as to edit the ImageGridAmp matrix setting everything to zero except the vertex of interest.

But after exporting it to MATLAB the ImageGridAmp has no value in it. It’s empty.

Can anyone suggest me how to solve this and even if there’s other solution to simulate a dipole.

Looking forward for the response.

Best regards,

Hi Kidist,
The method is correct: export the sources to Matlab, select one dipole of interest and set everything else to zero in ImageGridAmp, re-import it in the database, right-click on the file > Method evaluation > Simulate recordings.

The only thing you need to do is to calculate the initial source file using the option “Full sources” (expert mode, in the options window). For details about the meaning of ImageGridAmp and ImagingKernel, please read again the source estimation tutorial:


Hi Francois,

The option “Full results (Kernel*Recordings)” is inactive that I can’t select it.

Best regards,

Because your are trying to calculate a “shared kernel”, you need to compute your sources for one specific data file (or a few specific data files).
Please read again the tutorial if this is unclear.

There’s only one specific data file that I am using. I’m not sharing anything.

My functional database explorer looks like this:

-(common files)
Neuroscan Quick-cap(44)
3-shell sphere
Noise covariance

If you right-click on P4/Raw > Compute sources, you don’t have the “Full sources” option enabled?

After restarting the software the “Full sources” option is now enabled.

So I set everything to zero except the dipole (vertex number) that I’ve selected
Re-import and clicked the simulate recordings then I get the following error of mismatch :

** Error: Line 87: bst_simulation at 87
** Number of sources in the head model (15266) and the inverse model (1) do not match.
** Call stack:
** >bst_simulation.m at 87
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@bst_simulation,filenameRelative) at 1385

In the edited source structure, the size of ImageGridAmp should be [Nsources x Ntime], with Nsources=15266
ImagingKernel must be set to the empty matrix [].

The error message tells you that in your case, Nsources = 1.

The vertex number I would like to simulate is let’s say 1304.
ImageGridAmp = 15266*2001
So I thought that all sources should be set to zero except for this particular source making the Nsources=1

So which rows do I need to edit from the ImageGridAmp matrix? The ImagingKernel matrix is already empty from the beginning.

This way we wouldn’t have a way to track what source index it is.
Setting to zero means keeping the values but making them equal to zero.

Example, with old=computed file and new=edited file:
Nsources = 15266;
Ntime = 2001;
iDipole = 1304;
new.ImageGridAmp = zeros(Nsources, Ntime);
new.ImageGridAmp(iDipole,:slight_smile: = old.ImageGridAmp(iDipole,:);

This was my mistake “Setting to zero means keeping the values but making them equal to zero.”

Problem solved now thanks!!!

Hi Francois,

The option “right-click on the file > Method evaluation > Simulate recordings” is inactive that I can’t select it, when I work with sLoreta.

Best regards,


I have other question. It is equivalent this process to mark a Scout and them “Scout options > Sources > Simulate recordings”?

Best regards,

I never had this issue. Maybe can you try to do it in the process box below, and check if the option [I]Full results[/I] is active there?

Hi Federico,

The popup menu “Model evaluation > Simulate recordings” and the menu “Sources > Simulate recordings” in the scout tab are indeed calling the same function bst_simulation.m.
In the first case (from the database explorer), it uses the sources of the whole brain.
In the second case (scout options), it uses only the sources from the selected scouts. If there are no selected scouts (or no scouts at all), it uses the entire cortex surface, as in the first case.

This function simulates MEG/EEG recordings by multiplying the MNE source time series by the forward model. If ForwardMat represents the head model file structure, InverseMat the full source file, and iVertices the sources used for the simulation:
SimulatedRecordings = ForwardMat.Gain(:,iVertices) * InverseMat.ImageGridAmp(iVertices,:);

This menu is available only for the original wMNE results. The dSPM and sLORETA are additional statistics calculated from the wMNE results.


Hi Francois,

Thank you for your response, it has been very helpful!

But I have other query.
When you set ImageGridAmp matrix everything to zero except the vertex (a particular scout) of interest and them you select popup menu “Model evaluation > Simulate recordings”, is the same to put “Sources > Simulate recordings” in the scout tab (in the same scout, obviously) ?


Yes, it should produce the same results.
However, I haven’t used those functions in a while, there might be some small hidden bugs.
You could try both approaches for one file and make sure they give the same thing, just to make it works properly.

Thank you very much for your answer!