<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p></p>
<div style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe WP", "Segoe UI WPC", Tahoma, Arial, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
Hi Jan-Mathijs,<br>
</div>
<div style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe WP", "Segoe UI WPC", Tahoma, Arial, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe WP", "Segoe UI WPC", Tahoma, Arial, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
Thank you very much for your detailed answer! The issue was exactly in the<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"> size of the onoff variable</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"> in
 findcluster, it turns out there was a line of code that shuffled the dimensions of my input data every time I ran the script. I took care of that and it all works as it should now. </span></div>
<div style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe WP", "Segoe UI WPC", Tahoma, Arial, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe WP", "Segoe UI WPC", Tahoma, Arial, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"></span>All the best,</div>
<div style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe WP", "Segoe UI WPC", Tahoma, Arial, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">
Valentina​<br>
<br>
</div>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<font color="#808080"><font size="2">Valentina Jelinčić, M.Sc.</font> </font>
<div><font size="2" color="#808080">PhD student | Research Group Health Psychology | KU Leuven</font></div>
<div><font size="2" color="#808080">Tiensestraat 102, room 02.86</font></div>
<div><font size="2" color="#808080">3000 Leuven, Belgium</font></div>
</div>
</div>
<div style="word-wrap:break-word; line-break:after-white-space">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> fieldtrip <fieldtrip-bounces@science.ru.nl> on behalf of Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip@science.ru.nl><br>
<b>Sent:</b> 10 March 2022 08:37<br>
<b>To:</b> FieldTrip discussion list<br>
<b>Cc:</b> Schoffelen, J.M. (Jan Mathijs)<br>
<b>Subject:</b> Re: [FieldTrip] Cluster-based permutation - invalid dimension</font>
<div> </div>
</div>
<div>Hi Valentina,
<div class=""><br class="">
</div>
<div class="">Thanks for your quite extensive report. Good that you delved into the code to hunt for the cause of the problem yourself. What’s not clear from your description, is whether the data are consistent with the neighbour specification to begin with.
 Importantly, the data.label needs to overlap with the neighbours.label (and the entries in neighblabel). Only if this condition is fulfilled, FieldTrip will be able to create an channel adjacency matrix from the neighbours structure array. You describe that
 the adjacency matrix is in line with your expectations, i.e. 129x129, so it sounds as if all is good with respect to how the neighbours have been defined.</div>
<div class=""><br class="">
</div>
<div class="">I don’t understand why findcluster wants ’spatdimneighbstructmat’ to be 1x1. This can only be the consequence of the fact that the size of the onoff variable (in findcluster) is not according to the expectations. It might be worthwile to look
 into the consistency of the input data that resulted from the besa2fieldtrip conversion.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 7 Mar 2022, at 11:43, Valentina Jelinčić via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
Hi everyone,<br class="">
</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<br class="">
</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
I am a total beginner in FT and have been trying to run a cluster-based permutation test (between-subjects) on time-frequency data exported from BESA Connectivity. I used the function besa2fieldtrip on .tfc data, which according to this tutorial <a href="https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/getting_started/besa/*reading-in-data-files-from-besa__;Iw!!HJOPV4FYYWzcc1jazlU!_UNNbfTgZEb7EhR4onWzNj91HtI8L0ICGdFK0ymLihNBDFzw_BQoywdnr8TzahzmFsNWb-nrxotaqa2ttdOltX2zSbAMxzn2vPZsCw$" title="https://www.fieldtriptoolbox.org/getting_started/besa/#reading-in-data-files-from-besa
Ctrl+Click or tap to follow the link" class="">https://www.fieldtriptoolbox.org/getting_started/besa/#reading-in-data-files-from-besa</a>should
 produce output similar to ft_freqanalysis. I did have to do some tweaking to get the 2 power spectra to be 4-D matrices with the following dimord: subj_chan_freq_time. I defined my configuration using this tutorial <a href="https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/tutorial/cluster_permutation_freq/*permutation-test__;Iw!!HJOPV4FYYWzcc1jazlU!_UNNbfTgZEb7EhR4onWzNj91HtI8L0ICGdFK0ymLihNBDFzw_BQoywdnr8TzahzmFsNWb-nrxotaqa2ttdOltX2zSbAMxzn0egYfmA$" class="">https://www.fieldtriptoolbox.org/tutorial/cluster_permutation_freq/#permutation-test</a>​,
 leaving almost all the settings as-is.<br class="">
</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<br class="">
</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
When I run ft_freqstatistics, I get the following readout:<br class="">
<br class="">
<div class="">Error using findcluster (line 66)</div>
<div class="">invalid dimension of spatdimneighbstructmat</div>
<div class=""><br class="">
</div>
<div class="">Error in clusterstat (line 214)</div>
<div class="">  posclusobs = findcluster(tmp, connmat, cfg.minnbchan);</div>
<div class=""><br class="">
</div>
<div class="">Error in ft_statistics_montecarlo (line 363)</div>
<div class="">  [stat, cfg] = clusterstat(cfg, statrand, statobs);</div>
<div class=""><br class="">
</div>
<div class="">Error in ft_freqstatistics (line 193)</div>
<div class="">  [stat, cfg] = statmethod(cfg, dat, design);<br class="">
</div>
<br class="">
</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
I turned on debugging, and the error happens on this line:<br class="">
</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
if ~ismatrix(spatdimneighbstructmat) || ~all(size(spatdimneighbstructmat)==spatdimlength)</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
  ft_error('invalid dimension of spatdimneighbstructmat');</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
end<br class="">
</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<br class="">
</div>
<div class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
It seems that findcluster wants the size of my <span class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)">s</span><span class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)">pa</span><span class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)">tdimneighbstructmat
 to be 1 (size assigned to spatdimlength earlier in the function), but it is a 129*129 matrix (EGI 129 channel net). I find this odd, since the function documentation states:<br class="">
</span>
<div class="">"The neighbourhood structure for the first dimension is specified using <span class="" style="font-size:12pt">s</span><span class="" style="font-size:12pt">p</span><span class="" style="font-size:12pt">atdimneighbstructmat, which is a 2D (N1xN1)
 matrix. Each row and each column</span><span class="" style="font-size:12pt"> corresponds to a channel (combination) along the first dimension and along that </span><span class="" style="font-size:12pt">row/column, elements with "1" define the neighbouring
 channel(s) (combinations)."</span></div>
<div class=""><span class="" style="font-size:12pt"><br class="">
</span></div>
<div class=""><span class="" style="font-size:12pt">From that description, it seems that my spatdimneighbstructmat is correct, so I have trouble interpreting this error or figuring out what I should change.</span></div>
<div class=""><span class="" style="font-size:12pt"><br class="">
</span></div>
<div class=""><span class="" style="font-size:12pt">All that said, I will say that I am still unsure what the "data" parameter in ft_prepare_neighbours should be. At the moment, I am putting the channel configuration in there, but this may be wrong. </span></div>
<span class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)"> </span><br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px; font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
Does anyone have experience with BESA data and/or defining neighbour structure for EGI nets, and wouldn't mind having a look at my data/configuration? Thank you very much in advance!<br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px; font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px; font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
All the best,<br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px; font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
Valentina<br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px; font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<br class="">
</div>
<div id="Signature" class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<div name="divtagdefaultwrapper" class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; margin:0px">
<font color="#808080" class=""><font size="2" class="">Valentina Jelinčić, M.Sc.</font></font>
<div class=""><font size="2" color="#808080" class="">PhD student | Research Group Health Psychology | KU Leuven</font></div>
<div class=""><font size="2" color="#808080" class="">Tiensestraat 102, room 02.86</font></div>
<div class=""><font size="2" color="#808080" class="">3000 Leuven, Belgium</font></div>
</div>
</div>
<span class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important">_______________________________________________</span><br class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<span class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important">fieldtrip
 mailing list</span><br class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; background-color:rgb(255,255,255)">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_UNNbfTgZEb7EhR4onWzNj91HtI8L0ICGdFK0ymLihNBDFzw_BQoywdnr8TzahzmFsNWb-nrxotaqa2ttdOltX2zSbAMxznL2SUpwg$" class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; background-color:rgb(255,255,255)">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_UNNbfTgZEb7EhR4onWzNj91HtI8L0ICGdFK0ymLihNBDFzw_BQoywdnr8TzahzmFsNWb-nrxotaqa2ttdOltX2zSbAMxznL2SUpwg$</a><span class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important"><span class="Apple-converted-space"> </span></span><br class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</body>
</html>