The relation between Scouts and brain grid

Dear Morteza,

No problem, could you show what is different from the BrainStorm results. I would program it more or less like following to make it flexible, note that this is just a general structure and many variables are just named a bit arbitrarily :

time = linspace(0,6,6000); %define timebase
sizegain = size(gain); %get sizes of leadfield matrix
Sources = zeros(sizegain(2),length(time)); % make a source matrix
y = sin(2*pi *time); %arbitrary source
vertexlist = [4900,4963,5001,5005,5072,5079,5111] %vertices of interest
for I = 1:length(vertexlist) %signal on every vertex, note that the x,y,z part was omitted for easier code
Sources(vertexlist(I),: ) = y;
end
SimEEG = Gain * sources; %multiplication

I hope that helps, sorry if my answer is on the long side.

Kind regards,
Steven

1 Like

Dear Steven
I tried to create leadfield matrix using your semi code and also several different ways but I couldn't :pensive:
I think it has a complicated solution. What do you think about it?
I really need to create leadfeild matrix in Matlab, could you please help me more?
I also checked @Francois comment several times, but I can not find the solution.

Best Regard
Morteza

Can you please post a clear summary of what your problem is?
We can only help you with a clear an reproducible example.

Yes, of course!
I'm going to simulate EEG recording by myself in Matlab. For this objective, I've used defult anatomy in BS software and defined:
a point scout (seed:12497) as a source
a simulated generic signal as:
f1 = 2; f2 = 20; f3 = 50;
i =2000:6000;
Data(1,i) = sin(f12pi*t(i)) ;
simulatedsignal

and assigned this signal to the scout. Also, I've used BS's OpenMEEG BEM (volume) to calculate the head model. In this step, "I asked BS to simulate recorded signals in the default 64 channel cap".

I want to do this step (simulate recorded signals in the default 64 channel cap) by myself in Matlab. To do this, I've exported the following cases to Matlab:

  1. scout seed number as "scout"

  2. simulated signal (Data(1,i) = sin(f12pi*t(I)) ) as "row_signal"

  3. OpenMEEG BEM (volume) as "Head_Model"

  4. simulated signal as "Simulated_Recording" for result comparing.

exported1

for simulating recorded signal, I need to know how I can multiple Head_Model with row_signal. @SBeumer gave me very good tips but I've not succeeded to have the same results those are shown by Simulated_Recording yet.
In other words, my problem is how I can convert "Head_Model.Gain" with 64 * (3 x vertexes) in 3 dimensions (x,y,z) to a Head_Model matrix with 64*vertexes.

I hope to describe my problem better
Regards
Morteza

Hi dear @Francois ;
Have I explained clearly or no? Do I need to explain more?

Kind Regards
Morteza

If you obtained what you want from the interface, you just have to follow in the code how it was done.
First you need to create a "full source file" (matrix ImageGridAmp with zero everywhere except where your simulated signal is), and then multiply it with the forward model.

Put a breakpoint at the beginning of the Run() function in process_simulate_recordings.m, start the simulation from the Process1 tab, and when the debugger stops start executing line by line the code, exploring the contents of the variables at each step:
https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/process/functions/process_simulate_recordings.m#L82

If you are not familiar with the Matlab debugger, search first for a tutorial about it, this is a very powerful tool to follow code execution.

1 Like