<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Dear Robert,<br><br>Thank you to put in our problem from the first question, yes we want to localize the contractions of the uterus, and thank you to provide me with the careful consideration of the inverse model assumptions for this case. <br><br>I have looked at <a href="http://www.fieldtriptoolbox.org/dataformat," target="_blank">http://www.fieldtriptoolbox.org/dataformat,</a> but the data what I have is: 1- a real signal generated from 16 electrodes saved as ".mat", 2- the meshes as ".off"( I seperated the points and faces and I saved each one on ".mat") it is already segmented, and 3- the simulated potential (99084x201) given from our team who works on the model and I want to convert it to in the form of signal collected from the 16 electrode (16x201). <br><br> The algorithm of my colleague was as below, but I didn't convinced in the computation of the inverse problem using the gain matrix not the lead field, it is possible to use the gain matrix as done below in the bold inverse problem part or in another word what does gain represent?<br><br><b><font style="font-size: 8pt;" size="1">% Set the radius and conductivities of each of the compartments</font></b><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"></font><font style="font-size: 8pt;" size="1">addpath(cd) </font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">% 3 Layers</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">r = [0 0.936 2.068 2.268];</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">c = [0.2 0.3 0.04 0.5];</font><font style="font-size: 8pt;" size="1"><br></font><b><font style="font-size: 8pt;" size="1">%% Description of the spherical mesh</font></b><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">pnt=point_square(:,2:4);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">tri=faces_square(:,3:5);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%% Create a set of electrodes on the outer surface</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">% sensor = [pnt(10201,:);pnt(17376,:);pnt(24756,:);pnt(31931,:);pnt(10166,:);pnt(17341,:);pnt(24721,:);pnt(31896,:);pnt(10130,:);pnt(17305,:);pnt(24685,:);pnt(31860,:);pnt(10095,:);pnt(17270,:);pnt(24650,:);pnt(31825,:)];</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">sensor = [pnt(664,:);pnt(1080,:);pnt(1600,:);pnt(2016,:);pnt(656,:);pnt(1072,:);pnt(1592,:);pnt(2008,:);pnt(646,:);pnt(1062,:);pnt(1582,:);pnt(1998,:);pnt(638,:);pnt(1054,:);pnt(1574,:);pnt(1990,:)];</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">sensor(:,3)=sensor(:,3)+max(r)+0.1;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">sens.elecpos = sensor;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">sens.label = {};</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">nsens = size(sens.elecpos,1);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">for ii=1:nsens</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> sens.label{ii} = sprintf('vertex%03d', ii);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">end</font><font style="font-size: 8pt;" size="1"><br></font><b><font style="font-size: 8pt;" size="1">%% Set the position of the probe dipole</font></b><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%%Un source</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">pos = pnt(1326,:);%[5 5 0] maillage complet</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">pos(:,3) = pos(:,3)+0.1;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%%Deux source</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">% S1 = pnt(10609,:);%[2.5 2.5 0] maillage complet</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">% S1(:,3) = S1(:,3)+0.1;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">% S2 = pnt(31417,:);%[7.5 7.5 0] maillage complet</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">% S2(:,3) = S2(:,3)+0.1;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">% pos=[S1;S2];</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%%All the uterine muscle mesh</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%S=pnt(:,:,:);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%S(:,3) = S(:,3)+0.1;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%pos=S;</font><font style="font-size: 8pt;" size="1"><br></font><b><font style="font-size: 8pt;" size="1">%% Create a BEM volume conduction model</font></b><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">vol = [];</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">for ii=1:length(r)</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> uterus=pnt;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> uterus(:,3)=uterus(:,3)+r(ii)+0.1;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> vol.bnd(ii).pnt = uterus;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> vol.bnd(ii).tri = fliplr(tri); % pointing inwards!!!</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">end</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">vol.cond = c;</font><font style="font-size: 8pt;" size="1"><br></font><b><font style="font-size: 8pt;" size="1">%% Compute the BEM</font></b><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">cfg=[];</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">cfg.method = 'bemcp';</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">vol = ft_prepare_headmodel(cfg, vol);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">cfg.vol = vol;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">cfg.grid.pos = pos;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">cfg.elec = sens;</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">[grid,gain] = ft_prepare_leadfield(cfg);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">lf_openmeeg = grid.leadfield{1};</font><font style="font-size: 8pt;" size="1"><br></font><b><font style="font-size: 8pt;" size="1">%% Inverse problem</font></b><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%load data</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1"> data_simulated = hdf5read('Sources_EHG_1.hdf5','/surface/EHG');</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%real=load('W4_P_27_07_10_CTMono3_deb.mat');</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">%data_real=real.XXF2D1;</font><br><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif">%MNE</font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"><br></font><b><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif">lambda = 1e-1;</font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"><br></font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif">% </font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"><br></font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"> MNE_1 = inverse_operator_MNE(gain,lambda); % A: Gain matrix</font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"><br></font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"> S_MNE_1 = bayesian_inverse_solution(data_simulated',MNE_1); % X: Signal</font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"><br></font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"> mean_S_MNE_1=mean(S_MNE_1,2);</font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"><br></font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif">% </font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"><br></font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif">% MNE_2 = inverse_operator_MNE(gain,lambda); % A: Gain matrix</font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"><br></font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif">% S_MNE_2 = bayesian_inverse_solution(data_real',MNE_2); % X: Signal</font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif"><br></font><font style="font-size: 10pt;" size="2" face="Courier New,sans-serif">% mean_S_MNE_2=mean(S_MNE_2,2);</font></b><br><br><font style="font-size: 8pt;" size="1"> bnd = struct('pnt', pnt, 'tri', tri);</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">figure;ft_plot_mesh(bnd, 'vertexcolor', mean_S_MNE_1(1:size(pnt,1)));</font><font style="font-size: 8pt;" size="1"><br></font><font style="font-size: 8pt;" size="1">% figure;ft_plot_mesh(bnd, 'vertexcolor', mean_S_MNE_2(1:size(pnt,1)));</font><br><br>To be more accurate I want to use your algorithm in: <a href="http://www.fieldtriptoolbox.org/tutorial/minimumnormestimate?s[]=mne" target="_blank"></a><a href="http://www.fieldtriptoolbox.org/tutorial/minimumnormestimate?s[]=mne" target="_blank">http://www.fieldtriptoolbox.org/tutorial/minimumnormestimate?s[]=mne</a> but my obstacle was cfg.dataset = 'Subject01.ds'; I didn't <br>know in our cases what is the "Subject01.ds", and also the same in: <a href="http://www.fieldtriptoolbox.org/tutorial/beamformer" target="_blank">http://www.fieldtriptoolbox.org/tutorial/beamformer</a>,... <br><br><br><pre>Thank you very much for any suggestions<br><br><br><br>Best regards<br>Saeed<br></pre><br><br><br> </div></body>
</html>