<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Dear Jan-Mathijs,</div><div><br></div><div><br></div><div>thank you for your message.</div><div><br></div><div>when I add the 'tri' field to the input data, FT recognizes that data is a mesh (<i><font color="#0000ff">the input is mesh data with 8196 vertices and 16384 triangles</font></i>),</div><div>but it keep throwing the same <i>spm_bwlabel</i> error message.<br></div><div><br></div><div>This is the current input data (that's what you meant, right?):</div><div><br></div><div><div>varargin{1}:</div><div> cfg: [1x1 struct]<br></div><div> inside: [8196x1 logical]</div><div> pos: [8196x3 double]</div><div> time: 0.1000</div><div> pow: [8196x1 double]</div><div> tri: [16384x3 uint16]</div><div> dimord: 'chan_time'</div></div><div><br></div><div><br></div><div>If I don't average over time, and the size of varargin{1}.pow equals e.g., [8196 73], then datsiz == 8196. </div><div>That's because dimsiz == [8196 73], but datdim == 1 (ft_sourcestatistics, lines 131-132).</div><div><br></div><div>That leads to the following error:</div><div><div><font color="#ff0000">Error using ft_sourcestatistics (line 205)</font></div><div><font color="#ff0000">the length of the design matrix (2) does not match the number of observations in the data (3358)</font></div></div><div><br></div><div><br></div><div>Best regards,</div><div>Malgorzata</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Subject: Re: [FieldTrip] source statistics - spm_bwlabel error<br>
<div style="word-wrap:break-word">
Hi Malgorzata,<br>
<div>
<div style="word-wrap:break-word">
<div><br>
</div>
<div>Could you try to add the original ‘tri’ field to each of your varargins, and check whether the problem persists?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Jan-Mathijs</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<blockquote type="cite">
<div>On 26 May 2017, at 11:52, Malgorzata Wislowska <<a href="mailto:malgorzata.wislowska@gmail.com" target="_blank">malgorzata.wislowska@gmail.<wbr>com</a>> wrote:</div>
<br class="gmail-m_1273669177798632914Apple-interchange-newline">
<div>
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div>Dear Julian,</div>
<div><br>
</div>
<div><br>
</div>
<div>thank you very much for your prompt response.</div>
<div><br>
</div>
<div>Yes, my numdims == 2 because my cfg.dim == [8196 1]</div>
<div>which comes from ft_sourcestatistics.m (code lines 131-132)</div>
</div>
</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div class="gmail_extra">
<div class="gmail_quote">
<div>
<div><font color="#0000ff">datdim = find(~strcmp(dimtok, 'subj') & ~strcmp(dimtok, 'rpt') & ~strcmp(dimtok, 'rpttap'));</font></div>
</div>
</div>
</div>
<div class="gmail_extra">
<div class="gmail_quote">
<div>
<div><font color="#0000ff">datsiz = dimsiz(datdim);</font></div>
</div>
</div>
</div>
</blockquote>
<font>calculated on the following input data:</font>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div>
<div><font color="#0000ff">varargin{1}:</font></div>
</div>
<div>
<div><font color="#0000ff"> cfg: [1x1 struct]</font></div>
</div>
<div>
<div><font color="#0000ff"> inside: [8196x1 logical]</font></div>
</div>
<div>
<div><font color="#0000ff"> pos: [8196x3 double]</font></div>
</div>
<div>
<div><font color="#0000ff"> time: 0.1750</font></div>
</div>
<div>
<div><font color="#0000ff"> pow: [8196x1 double]</font></div>
</div>
<div>
<div><font color="#0000ff"> dimord: 'chan_time'</font></div>
</div>
</blockquote>
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<div>The above source level structure comes from ft_sourceanalysis calculated with cfg.method = 'mne'.</div>
<div><br>
</div>
<div>Averaging over time unfortunately doesn't help - the same error continues to occur:</div>
</div>
</div>
</div>
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<div>But data that is not averaged over time has numdims == 2 too, because length(cfg.dim) == 2, even though that cfg.dim itself is different (for not averaged data it's e.g cfg.dim == [8196 61], whereas for averaged data it's cfg.dim == [8196 1]),</div>
<div><br>
</div>
<div>
<div>It helps (well, the function runs through without errors and produces some output) if the line:</div>
</div>
</div>
</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div class="gmail_extra">
<div class="gmail_quote">
<div>
<div><font color="#0000ff">if numdims == 2 || numdims == 3 </font>
<font color="#999999">% if 2D or 3D data</font></div>
</div>
</div>
</div>
</blockquote>
<div class="gmail_extra">
<div class="gmail_quote">
<div>gets replaced with:</div>
</div>
</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div class="gmail_extra">
<div class="gmail_quote">
<div>
<div><font color="#0000ff">if numdims == 3</font></div>
</div>
</div>
</div>
</blockquote>
<div class="gmail_extra">
<div class="gmail_quote">
<div>In clusterstat.m, code line: 318 (and also 269, 215, 184)</div>
<div><br>
</div>
<div>Do you (or anybody else) have maybe any better idea how to fix it?</div>
<div><br>
</div>
</div>
</div>
<div class="gmail_extra">
<div class="gmail_quote">
<div><span class="gmail-m_1273669177798632914m_-5705521512588756773gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal"><br>
</span></span></div>
<div><span class="gmail-m_1273669177798632914m_-5705521512588756773gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal">Thanks
and best regards,</span></span></div>
<div><span class="gmail-m_1273669177798632914m_-5705521512588756773gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal">Malgorzata,</span></span></div>
<div><span class="gmail-m_1273669177798632914m_-5705521512588756773gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal">University
Salzburg</span></span></div>
<div><span class="gmail-m_1273669177798632914m_-5705521512588756773gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal"><br>
</span></span></div>
<div><span class="gmail-m_1273669177798632914m_-5705521512588756773gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal"><br>
</span></span></div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Subject: Re: [FieldTrip] source statistics - spm_bwlabel error<br>
</blockquote>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
</blockquote>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="word-wrap:break-word">Dear Malgorzata,
<div><br>
</div>
<div>from a quick glance, it appears that in the call to spm_bwlabel "numdims" should be 3 to give you 2*numdims = 6.</div>
<div>So, could you check what numdims is in your case?</div>
<div>I suspect that you have 4-dimensional data (time by 3 spatial dimensions), so it might help to check where the dimensions are coming from and what happens if you average over time.</div>
<div><br>
</div>
<div>Good luck,</div>
<div><br>
</div>
<div>Julian</div>
<div><br>
<div>
<div>Am 24.05.2017 um 16:34 schrieb Malgorzata Wislowska:</div>
<br class="gmail-m_1273669177798632914m_-5705521512588756773gmail-m_-7432650842458017701Apple-interchange-newline">
<blockquote type="cite">
<div dir="ltr">Dear FT-community,
<div><br>
</div>
<div><br>
</div>
<div>when calculating cluster permutation statistics on the source level, I receive the following error:</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div>
<div><font color="#ff0000">Error using spm_bwlabel</font></div>
</div>
<div>
<div><font color="#ff0000">spm_bwlabel: CONN must be 6, 18 or 26</font></div>
</div>
<div>
<div><font color="#ff0000"><br>
</font></div>
</div>
<div>
<div><font color="#ff0000">Error in clusterstat (line 319)</font></div>
</div>
<div>
<div><font color="#ff0000"> [negclusrnd, negrndnum] = spm_bwlabel(tmp, 2*numdims); % use spm_bwlabel for 2D/3D to avoid usage of image toolbox</font></div>
</div>
<div>
<div><font color="#ff0000"><br>
</font></div>
</div>
<div>
<div><font color="#ff0000">Error in ft_statistics_montecarlo (line 347)</font></div>
</div>
<div>
<div><font color="#ff0000"> [stat, cfg] = clusterstat(cfg, statrand, statobs);</font></div>
</div>
<div>
<div><font color="#ff0000"><br>
</font></div>
</div>
<div>
<div><font color="#ff0000">Error in ft_sourcestatistics (line 218)</font></div>
</div>
<div>
<div><font color="#ff0000"> [stat, cfg] = statmethod(cfg, dat, design);</font></div>
</div>
</blockquote>
<div><br>
</div>
<div>I used MNE method for the inverse problem. I have 8196 grid points 1555 time points.</div>
<div>But the error occurs also when I average across the time.</div>
<div><br>
</div>
<div>Here is my configuration structure for the source analysis:</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><font color="#0000ff"><br>
</font></div>
<div>
<div><font color="#0000ff">design = zeros(2, nb_of_sbj*2);</font></div>
</div>
<div>
<div><font color="#0000ff">design(1,:) <span class="gmail-m_1273669177798632914m_-5705521512588756773gmail-m_-7432650842458017701gmail-Apple-tab-span" style="white-space:pre-wrap">
</span>= [1:nb_of_sbj 1:nb_of_sbj];</font></div>
</div>
<div>
<div><font color="#0000ff">design(2,:) <span class="gmail-m_1273669177798632914m_-5705521512588756773gmail-m_-7432650842458017701gmail-Apple-tab-span" style="white-space:pre-wrap">
</span>= [ones(1,nb_of_sbj) ones(1,nb_of_sbj)*2];</font></div>
</div>
<div>
<div><font color="#0000ff"><br>
</font></div>
</div>
<div>
<div><font color="#0000ff">cfg = [];</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.method = 'montecarlo';</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.statistic = 'ft_statfun_depsamplesT';</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.parameter = 'pow';</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.correctm = 'cluster';</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.clusterstatistic = 'maxsum';</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.design = design;</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.ivar = 2;</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.uvar = 1;</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.numrandomization = 5000;</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.tail = 0;</font></div>
</div>
<div>
<div><font color="#0000ff">cfg.alpha = 0.025;</font></div>
</div>
<div>
<div><font color="#0000ff"><br>
</font></div>
</div>
<div>
<div><font color="#0000ff">[stat] = ft_sourcestatistics(cfg,avg_co<wbr>n_sel{:},avg_incon_sel{:});</font></div>
</div>
</blockquote>
<br>
<div>As far as I can see somebody had asked the same question last year, but the post doesn't seem to have been addressed:<br>
<a href="https://mailman.science.ru.nl/pipermail/fieldtrip/2016-August/010762.html" target="_blank">https://mailman.science.ru.nl/<wbr>pipermail/fieldtrip/2016-Augus<wbr>t/010762.html</a><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Thank you for your help in advance.</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Malgorzata Wislowska,</div>
<div>University of Salzburg</div></div></blockquote></div></div></div></blockquote></div></div></div></div></div></blockquote></div></div></div></div></div></blockquote></div><br></div></div>