Dear Francois, Sylvain,
I would like to perform a simple simulation to estimate the extent of the projection of a source on the scalp.
To be more specific the idea is the following:
 Generate a source/s current density (it can be distributed or even a single dipole, it does not matter as long as it generates a particular voltage profile on the cortical surface)
 From this source, compute a forward model and obtain the voltage profile on the scalp.
 Estimate the spatial extent and amplitude profile of the scalp projection of the source.
 Repeat for sources of different amplitudes and cortical extent.
I explored some of Brainstorm functions and I think that we could use bst_eeg_sph for the forward modelling part, since we will use a spherical head. Do you think it is a reasonable approach?
Thank you in advance!
Rina
Dear Rina,
It would pretty straightforward to implement what you need in Brainstorm. You can even do it 90% with the graphic user interface, which I would recommend. Do not try to call by yourself functions in the toolbox/forward or toolbox/inverse folders, they are all interdependent and require complex sets of input parameters that are going to be set automatically by the interface.
The way to go is the following:
 Computation of the electromagnetic model:
 Prepare the anatomy of you subject, or use a default brain (tutorial #2)
 Create an empty condition, and import the electrodes positions in it (rightclick on the condition > Import channel file)
 Import a small block of the type of EEG recordings that you would like to simulate (tutorial #3)
 Make sure that you can visualize it properly (tutorial #4)
 Compute a forward model (rightclick on the condition > Compute head model) (tutorial #5)
 Compute sources for the small block of EEG recordings you have (tutorial #6 and #7): In the options, select the “Expert mode” and select the option: “Output mode: Full results (Kernel*Recordings)”
 Use of this model for simulating scalp EEG:

Export the source file to your Matlab workspace: Rightclick on the source file > File > Export to Matlab

From your Matlab command window, edit the following fields:
– ImageGridAmp: Source activity in pA.m (current density, picoAmper.meter) at each source, ie. each vertex of the cortex mesh. You can set only one source to be active. Size of the matrix: [nSources x nTime]
– Time: the size of this field must match the second dimension of ImageGridAmp, and be monotonically increasing
– DataFile: set to [] so that the program does not try to associate this file to anything else in the database

To know what is the index of each source in ImageGridAmp, you can use two methods:
– Open the source file by doubleclicking on it. Rightclick on the figure > Get coordinates > select points at the surface of the brain. At the bottom of the “get coordinates” window, you’d fine the vertex #, which is the same as the row index in ImageGridAmp
– Or: Create a scout on the surface, then access to its contents by typing the following commands in your command window: “global GlobalData; GlobalData.Scouts(1).Vertices”

After you edited the source file, import it back to the database: rightclick on the FOLDER (not on the previous source file) > File > Import from Matlab

Rightright on the NEW source file > Model evaluation > Simulate recordings
Let me know if you need more information or help.
Cheers,
Francois
Dear Brainstorm group
I have simulated EEG.I want to compute Laplacian of interpolated EEG on scalp surface. Would you please help me how I can do it?
Thanks
Ayda
Hi Ayda,
I’m not sure what you exactly want to do. Brainstorm cannot perform correctly a projection of the EEG on the scalp. The menu “Display on scalp” you get when you rightclick on some EEG recordings is performing a very rough 3D interpolation of the values using the function bst_shepards. This is only for illustration purposes, I wouldn’t use it for performing any sort of postprocessing. If you compute a surface Laplacian of this, you would just get one circle around each sensor.
If you are simulating your EEG at the electrodes positions, you can also simulate it at each vertex of the scalp surface, which would give you a much better estimation of the scalp potentials.
I’m not sure how much I can help…
Francois
This is so helpful, thank you, it is just what I was looking for too.
I have two questions to add to the above:
Is the constraint that only one source can be active at a time avoidable? I have a prediction from a computational model that more than one will be active at once and it would be nice to test this.
More trivially, I don’t seem to have the option ‘Export to Matlab’. I am looking in the wrong place? Or is this because I am using the Matlab Compiler Runtime? I suspect I’m missing something obvious…
Many thanks,
Adrian
Hello Ayda:
Brainstorm does not feature the computation of surface Laplacians so far.
The following toolkit does: http://psychophysiology.cpmc.columbia.edu/software/CSDtoolbox/index.html
You can help implementing this feature in brainstorm by looking at this toolkit and letting us know how we can best interface its routines with brainstorm’s.
Hope this helps.
Hello Adrian:
You can have several sources active at once. As Francois mentioned, you can edit all the source time series in the source space of your model. In brainstorm, we essentially use fullcortical source surfaces. Hence you can edit each every time course at each and every cortical location to simulate pretty sophisticated source models. Please let us know if the directions provided by Francois are not clear enough. We’ll have a dedicated web page for that eventually, so feedback is appreciated.
As for your second question, if export to matlab is not featured in your version, make sure you are running brainstorm with Matlab, not the compiled version (which does not require matlab).
Cheers,
Hi Adrian,
[QUOTE=AdrianB;3521]I don’t seem to have the option ‘Export to Matlab’. I am looking in the wrong place? Or is this because I am using the Matlab Compiler Runtime? [/QUOTE]
This menu “Export to Matlab” copies the contents of the selected file into the Matlab workspace, that you can access with the command window of Matlab.
In your case, you are not running the full Matlab environment, so there is no workspace and no command window, hence no “Export to Matlab” menu.
Francois
Dear Francois,
Thanks so much for your response, it was very useful. I generate the sources as you suggested, using scouts, and simulated the scalp EEG.
I have a few questions that I would appreciate if you could address:
Source Simulation

Whitener: I assume that it is created based on the covariance matrix of the block of scalp EEG that I used. Since I’m not interested in keeping those relations, I removed it by Whitener=[]; and seems to be ok. Could you please confirm that it is reasonable to do so?

ImageGridAmp: It seems that units is A.m (for small noise on the scalp, the sources are of order e10), instead of pA.m as indicated below (and displayed in pA.m). Could you please confirm that this is the case?

Is it possible to estimate the voltage amplitude at the cortical surface? (where the sources are).
Scouts
 Is there a logic in the numbering of the vertices? Can this be exploit to programatically generate increasingly bigger scouts? (I assume that is what is being done in the interface)
 Which is the average size of the tessellation triangule in the default subject? (Colin27)
Scalp simulation
 The head model seems to be created from the specified sensors. In the response to Ayda’s question, you mention that you can also simulate it at each vertex of the scalp surface, which would give you a much better estimation of the scalp potentials. Could you specify how to use all the vertex of the scalp for the head model?
Thank you!
Rina
Source Simulation:

Whitener:
This field is created when estimating the sources, using the noise covariance matrix that is saved in your database (can be estimated from the recordings in different ways). Its goal is to clean the data before doing the inversion, the final source time series you get with a wMNE solution is: (InversionKernel * Whitener) * EEG. To make it easier, in the source file, we save ImagingKernel already multiplied by Whitener.
So this field .Whitener is never used anywhere, it is saved in the source file only for bookkeeping, it’s not going to change anything if you modify it.
See function bst_wmne.m for more details.

ImageGridAmp:
Yes, you are right. Almost all the values saved in Brainstorm are in IS units. The values in ImageGridAmp are in A.m, and are usually displayed as pA.m

Voltage: I don’t know. Sylvain?
Scouts:

Numbering: the vertex indices can be totally random. What defines the relationship between two vertices is the Faces matrix, that connects the vertices together. From those two fields, a third information is always computed automatically: VertConn (vertex to vertex connectivity).
This is a huge sparse diagonal [nVertices x nVertices] matrix that has a one for each couple of vertices that are immediate neighbors (that belong to the same face).
To increase the size of a scout, you need to use this VertConn field, that you would find in the cortex surface file. For that you can use or have a look at the function tess_scout_swell.m

The average size of the triangles for the Colin27 cortex tesselation?
I don’t know. You can do that with a small loop on the Faces matrix that calculates the size of each triangle, and average the total.
Scalp simulation:
First thing to keep in mind: Having more points on the surface of the head where you simulate the scalp potential is not going to increase the accuracy of the value at each scalp point, and is not going to any information to you model. I was suggesting that just for specific postprocessing purposes and for visualization.
If you really want to estimate the scalp potentials at more points: just add electrodes to the Channel structure of your channel file. You can even create a Channel entry for each vertex of the scalp surface. I’m not sure it’s interesting for you to do something like that though…
Cheers,
Francois
Hi there:
 Is it possible to estimate the voltage amplitude at the cortical surface? (where the sources are).
Estimating voltage amplitudes at the vicinity of the source is trickier than it seems because numerical models of EEG become inaccurate when the source is too close to the sensor. You can guesstimate the ratio in amplitude by considering it should be relatively equivalent to the ratio in the distances (scalp to cortex). This is valid in an homogeneous medium, but the skull introduces a factor of dampening which is also quite significant. I could get back to you with a more detailed model if that’s necessary. let me know.
Dear Brainstorm group
Thanks to all of you for useful guidance. I am using gain matrix (Normal constrained) using boundary element method model to simulate EEG. My problem is the gain enhances sources instead of attenuating them. For instance, I activated two sinusoids in two different location on the cortex and I get enhancement over all frequencies other than frequency of the sinusoids on the scalp. What are the conditions for leadfield matrix that I need to note?
Thanks
Ayda
Hi Ayda,
The simulation of EEG from sources is a multiplication of the source values with the forward model (which is a linear operator). This is done independently for each time instant. There is no frequency filter of any kind applied during the operation.
Therefore, if you have one single source activated on the cortex, you should observe exactly the same frequency spectrum for this source and all the electrodes that are influenced by this source.
Can you describe your problem with more details, and maybe add a few images to illustrate?
Thanks
Francois
Thanks for your reply. I understand what you are talking about. There is a little misunderstanding.
I should have noted that FFT is not perfiect in a sense that we always have source activation even in frequencies other than frequency of source’s sinusoid.