<div dir="ltr"><div>Hi Laura,</div><div> </div><div>Does your data have the same channels as the leadfield (as the electrodes that went in to compute the leadfield)? I often see that error when there is a mismatch of channels in that way.</div>
<div> </div><div>Best,</div><div>Johanna</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-05-28 15:29 GMT+01:00 Laura Rueda Delgado <span dir="ltr"><<a href="mailto:Laura.Rueda@faber.kuleuven.be" target="_blank">Laura.Rueda@faber.kuleuven.be</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="NL-BE" vlink="purple" link="blue">
<div>
<p class="MsoNormal"><span lang="EN-US">Dear Fieldtrip users,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">I’m following the tutorial of beamformers (<a href="http://fieldtrip.fcdonders.nl/tutorial/beamformer" target="_blank">Source Analysis: Contrast activity to another interval</a>) to estimate oscillatory sources using DICS. I’ve checked
the surface created after segmentation and the grid generated from the electrode positions and the headmodel. That seems to work ok. However, at the step of source analysis, I get the following error:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Error using * <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Inner matrix dimensions must agree.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Error in beamformer_dics (line 339)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"> filt = pinv(lf' * invCf * lf) * lf' * invCf; % Gross eqn. 3, use PINV/SVD to cover rank<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"> deficient leadfield<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Error in ft_sourceanalysis (line 567)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"> dip(i) = beamformer_dics(grid, sens, vol, [], squeeze(Cf(i,:,:)), optarg{:});<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Does anybody have an idea of what I’m doing wrong?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Thank you in advance for any help or suggestion!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">-----------------------------------------------------------------<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">This is my code:<u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">%% 1 - Preparation of MRI- source space</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% Read MRI</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">mrifile =
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'Subject01\Subject01.mri'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">mri = ft_read_mri(mrifile);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% Reslice to reorient images</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg = [];
</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt">cfg.dim = [256 256 256];
</span><span style="font-family:"Courier New";font-size:12pt"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt">mri = ft_volumereslice(cfg,mri);
</span><span style="font-family:"Courier New";font-size:12pt"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% Segment compartments</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg = [];</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.output = {</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'brain'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">,</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'skull'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">,</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'scalp'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">};</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">segmentedmri = ft_volumesegment(cfg, mri);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% Prepare mesh</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg=[];</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.tissue={</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'brain'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">,
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'skull'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">,</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'scalp'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">};</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.numvertices = [3000 2000 1000];</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">bnd=ft_prepare_mesh(cfg,segmentedmri);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% Prepare headmodel</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg = [];</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.method =</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'bemcp'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">vol = ft_prepare_headmodel(cfg, bnd);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US"></span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">%% 2- Prepare leadfield - Creating grid</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">load
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">elec_aligned2</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">
</span><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% Obtained after adjusting electrodes on scalp surface interactively</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% Three fiducial markers were added to the electrode file, and now they're</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% removed so that the electrode structure has the same number of channels as the data</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">elec_aligned2.chanpos = elec_aligned2.chanpos(1:128, :);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">elec_aligned2.elecpos = elec_aligned2.elecpos(1:128, :);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">elec_aligned2.label = elec_aligned2.label(1:128, :);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg =[];</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.vol = vol;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.elec = elec_aligned2;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.grid.resolution = 10;
</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.grid.unit =
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'mm'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;
</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">[grid] = ft_prepare_leadfield(cfg);
</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">%% 3- Join rest and task data</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% data_rs: resting state data</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% data4: data during task</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">dataAll = ft_appenddata([], data_rs, data4);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg = [];</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.method =
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'mtmfft'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.output =
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'powandcsd'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;
</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.tapsmofrq = 4;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.foilim = [18 18];</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">freqAll = ft_freqanalysis(cfg, dataAll);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">%----------------------------------</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">% all seems normal until here<u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">%----------------------------------<u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:forestgreen;font-family:"Courier New";font-size:10pt" lang="EN-US">%% 4- Estimate source of all data</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">
</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg = [];</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.method =
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'dics'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.frequency = 18;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt">cfg.grid = grid;</span><span style="font-family:"Courier New";font-size:12pt"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt">cfg.vol = vol;</span><span style="font-family:"Courier New";font-size:12pt"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.elec = elec_aligned2;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.dics.projectnoise =
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'yes'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.dics.lambda =
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'5%'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.dics.keepfilter =
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'yes'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">cfg.dics.realfilter =
</span><span style="color:rgb(160,32,240);font-family:"Courier New";font-size:10pt" lang="EN-US">'yes'</span><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">;</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p style class="MsoNormal"><span style="color:black;font-family:"Courier New";font-size:10pt" lang="EN-US">sourceAll = ft_sourceanalysis(cfg, freqAll);</span><span style="font-family:"Courier New";font-size:12pt" lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Cheers,<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></p><span class="HOEnZb"><font color="#888888">
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Laura Rueda Delgado<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</font></span></div>
</div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>