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.
Dear Steven
I tried to create leadfield matrix using your semi code and also several different ways but I couldn't
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.
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)) ;
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:
scout seed number as "scout"
simulated signal (Data(1,i) = sin(f12pi*t(I)) ) as "row_signal"
OpenMEEG BEM (volume) as "Head_Model"
simulated signal as "Simulated_Recording" for result comparing.
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
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.