<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Malgorzata,<br class="">
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div class=""><br class="">
</div>
<div class="">Could you try to add the original ‘tri’ field to each of your varargins, and check whether the problem persists?</div>
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On 26 May 2017, at 11:52, Malgorzata Wislowska <<a href="mailto:malgorzata.wislowska@gmail.com" class="">malgorzata.wislowska@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="">Dear Julian,</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">thank you very much for your prompt response.</div>
<div class=""><br class="">
</div>
<div class="">Yes, my numdims == 2 because my cfg.dim == [8196 1]</div>
<div class="">which comes from ft_sourcestatistics.m (code lines 131-132)</div>
</div>
</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="">
<div class=""><font color="#0000ff" class="">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 class="">
<div class=""><font color="#0000ff" class="">datsiz = dimsiz(datdim);</font></div>
</div>
</div>
</div>
</blockquote>
<font class="">calculated on the following input data:</font>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">
<div class="">
<div class=""><font color="#0000ff" class="">varargin{1}:</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">       cfg: [1x1 struct]</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">    inside: [8196x1 logical]</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">       pos: [8196x3 double]</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">      time: 0.1750</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">       pow: [8196x1 double]</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">    dimord: 'chan_time'</font></div>
</div>
</blockquote>
<div class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="">The above source level structure comes from ft_sourceanalysis calculated with cfg.method = 'mne'.</div>
<div class=""><br class="">
</div>
<div class="">Averaging over time unfortunately doesn't help - the same error continues to occur:</div>
</div>
</div>
</div>
<div class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="">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 class=""><br class="">
</div>
<div class="">
<div class="">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" class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="">
<div class=""><font color="#0000ff" class="">if numdims == 2 || numdims == 3 </font>
<font color="#999999" class="">% if 2D or 3D data</font></div>
</div>
</div>
</div>
</blockquote>
<div class="gmail_extra">
<div class="gmail_quote">
<div class="">gets replaced with:</div>
</div>
</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="">
<div class=""><font color="#0000ff" class="">if numdims == 3</font></div>
</div>
</div>
</div>
</blockquote>
<div class="gmail_extra">
<div class="gmail_quote">
<div class="">In clusterstat.m, code line: 318 (and also 269, 215, 184)</div>
<div class=""><br class="">
</div>
<div class="">Do you (or anybody else) have maybe any better idea how to fix it?</div>
<div class=""><br class="">
</div>
</div>
</div>
<div class="gmail_extra">
<div class="gmail_quote">
<div class=""><span class="m_-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" class=""><br class="">
</span></span></div>
<div class=""><span class="m_-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" class="">Thanks
 and best regards,</span></span></div>
<div class=""><span class="m_-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" class="">Malgorzata,</span></span></div>
<div class=""><span class="m_-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" class="">University
 Salzburg</span></span></div>
<div class=""><span class="m_-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" class=""><br class="">
</span></span></div>
<div class=""><span class="m_-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" class=""><br class="">
</span></span></div>
<div class=""> </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 class="">
</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" class="">Dear Malgorzata,
<div class=""><br class="">
</div>
<div class="">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 class="">So, could you check what numdims is in your case?</div>
<div class="">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 class=""><br class="">
</div>
<div class="">Good luck,</div>
<div class=""><br class="">
</div>
<div class="">Julian</div>
<div class=""><br class="">
<div class="">
<div class="">Am 24.05.2017 um 16:34 schrieb Malgorzata Wislowska:</div>
<br class="m_-5705521512588756773gmail-m_-7432650842458017701Apple-interchange-newline">
<blockquote type="cite" class="">
<div dir="ltr" class="">Dear FT-community,
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">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" class="">
<div class="">
<div class=""><font color="#ff0000" class="">Error using spm_bwlabel</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class="">spm_bwlabel: CONN must be 6, 18 or 26</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class=""><br class="">
</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class="">Error in clusterstat (line 319)</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class="">        [negclusrnd, negrndnum] = spm_bwlabel(tmp, 2*numdims); % use spm_bwlabel for 2D/3D to avoid usage of image toolbox</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class=""><br class="">
</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class="">Error in ft_statistics_montecarlo (line 347)</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class="">  [stat, cfg] = clusterstat(cfg, statrand, statobs);</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class=""><br class="">
</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class="">Error in ft_sourcestatistics (line 218)</font></div>
</div>
<div class="">
<div class=""><font color="#ff0000" class="">  [stat, cfg] = statmethod(cfg, dat, design);</font></div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">I used MNE method for the inverse problem. I have 8196 grid points 1555 time points.</div>
<div class="">But the error occurs also when I average across the time.</div>
<div class=""><br class="">
</div>
<div class="">Here is my configuration structure for the source analysis:</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">
<div class=""><font color="#0000ff" class=""><br class="">
</font></div>
<div class="">
<div class=""><font color="#0000ff" class="">design          = zeros(2, nb_of_sbj*2);</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">design(1,:)   <span class="m_-5705521512588756773gmail-m_-7432650842458017701gmail-Apple-tab-span" style="white-space:pre-wrap">
</span>= [1:nb_of_sbj 1:nb_of_sbj];</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">design(2,:)    <span class="m_-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 class="">
<div class=""><font color="#0000ff" class=""><br class="">
</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg                     = [];</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.method              = 'montecarlo';</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.statistic           = 'ft_statfun_depsamplesT';</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.parameter           = 'pow';</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.correctm            = 'cluster';</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.clusterstatistic    = 'maxsum';</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.design              = design;</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.ivar                = 2;</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.uvar                = 1;</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.numrandomization    = 5000;</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.tail                = 0;</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">cfg.alpha               = 0.025;</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class=""><br class="">
</font></div>
</div>
<div class="">
<div class=""><font color="#0000ff" class="">[stat]                  = ft_sourcestatistics(cfg,avg_co<wbr class="">n_sel{:},avg_incon_sel{:});</font></div>
</div>
</blockquote>
<br class="">
<div class="">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 class="">
<a href="https://mailman.science.ru.nl/pipermail/fieldtrip/2016-August/010762.html" target="_blank" class="">https://mailman.science.ru.nl/<wbr class="">pipermail/fieldtrip/2016-Augus<wbr class="">t/010762.html</a><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Thank you for your help in advance.</div>
<div class=""><br class="">
</div>
<div class="">Best regards,</div>
<div class="">Malgorzata Wislowska,</div>
<div class="">University of Salzburg</div>
</div>
______________________________<wbr class="">_________________<br class="">
fieldtrip mailing list<br class="">
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank" class="">fieldtrip@donders.ru.nl</a><br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank" class="">https://mailman.science.ru.nl/<wbr class="">mailman/listinfo/fieldtrip</a></blockquote>
</div>
<br class="">
</div>
</div>
<br class="">
______________________________<wbr class="">_________________<br class="">
fieldtrip mailing list<br class="">
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank" class="">fieldtrip@donders.ru.nl</a><br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank" class="">https://mailman.science.ru.nl/<wbr class="">mailman/listinfo/fieldtrip</a><br class="">
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="mailto:fieldtrip@donders.ru.nl" class="">fieldtrip@donders.ru.nl</a><br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
<br class="">
<br class="">
</div>
<br class="">
</body>
</html>