<div dir="ltr"><div><div>Dear Eelke,<br><br></div>Many thank yous - just a follow-up after your response on how to call clusterstat with proper dimensions (days later because it took sometime to compute the statobs and the statrnd)<br><br>Yes it works! :)<br><br></div><div>ps: To make this message less spammy, I will add the things we finally need to consider in case it helps anyone. This assumes you have computed the statobs and the statrnd structure (using whatever statistic you are into, in this case, the interaction effect of two factors within a manova was tested for each time point and channel in -R-). <br><br>Statobs should be Nchan*Ntime and statrnd Nchan*Ntime*Nrand (randomizations performed) <br>Statobs should be converted int oa single vector and statrnd a matrix as long * Nrand<br>Cfg.dim will have the same dimensions and statobs. <br>Use cfg.connectivity by calling ft_channelconnectivity<br>Of course you need to provide clusterstat with the specific critvalue calculated beforehand. <br></div><div>You will encounter that you need to reshape back fields prob and clusterlabelmat (eg: reshape(stat.posclusterslabelmat,[Nchan Ntime]) to make it readable for humans<br></div><div>Last advice: you may be asking yourself why matlab says there is no channelconnectivity functions or clusterstat.m --- they are inside fieldtrip##\private and you may need to includes them in the path/alter the name of the folder<br><br></div><div>Thanks a lot again Eelke,<br></div><div>Tino<br></div><div><br><br><br><br><br><br></div><div><br><br><br></div><br><br><br><div><br><br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-09-01 9:48 GMT+02:00 Eelke Spaak <span dir="ltr"><<a href="mailto:eelke.spaak@donders.ru.nl" target="_blank">eelke.spaak@donders.ru.nl</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear Constantino,<div><br></div><div>First, you need to specify cfg.dim as the size of the data matrix, in your case probably just [102 500], the size(statobs) before reshaping. Note that you need to put in statobs as a vector (statobs(:)) and statrnd as a numel(statobs) X nRand matrix.</div>
<div><br></div><div>Second, I don't know why you are specifying a cfg.layout, this is not used by the function. The same goes for cfg.neighbours, this is also not used. The higher-level statistics functions convert the cfg.neighbours struct-array into a logical connectivity array using the low-level private function channelconnectivity. To use clusterstat (a low-level function) directly, you need to do this beforehand.</div>
<div><br></div><div>So, do something like this:</div><div><br></div><div>cfg = [];</div><div>cfg.neighbours = neighbours;</div><div>cfg.channel = datachannels; % order is important here, must be the same as the data</div>
<div>connectivity = channelconnectivity(cfg);</div><div><br></div><div>cfg = [];</div><div>...</div><div>cfg.dim = size(statobs); % assuming statobs is still a chan X time matrix</div><div>cfg.connectivity = connectivity;</div>
<div><br></div><div>% this assumes statrnd is a chan X time X nRand array</div><div>statrnd = reshape(statrnd, [numel(statobs), size(statrnd,3)]);</div><div><br></div><div>statobs = statobs(:);</div><div>stat = clusterstat(cfg, statrnd, statobs);</div>
<div><br></div><div>Best,</div><div>Eelke</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On 29 August 2014 18:36, Constantino Méndez Bértolo <span dir="ltr"><<a href="mailto:constantino.mendezbertolo@ctb.upm.es" target="_blank">constantino.mendezbertolo@ctb.upm.es</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>Dear Fieldtrippers</div><div><br></div><div>We have a 3x3 design and MEG data, say only mag channels (n102) to simplify.</div>
<div><br></div><div>We want to perform a cluster-based permutation approach but timelockstatistics (cfg.method = 'montecarlo', cfg.correctm = 'cluster', etc) cannot deal with interactions when you have more than three levels (true?)</div>

<div><br></div><div>So we built our 'statobs' and 'statrnd' doing a GLM in -R Statistical Package- and feed 'clusterstat.m' with them</div><div><br></div><div>We have done this with one channel over time with success. However, I am clueless now about how to solve the problem when dealing with the whole channel set.</div>

<div><br></div><div>I wonder what is the nature of the cfg.dim that we need to feed 'clusterstat.m' with.</div><div><br></div><div>Up to now, we use, (cioming out of -R-):</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">

<div>size(statobs) = nchan*ntime % (102*500) % twin = [0 .5] % seconds</div><div>size(statrnd) = nchan*ntime*nrandomizations % (102*500*1000)</div></blockquote><div><br></div><div>and the following presets:</div><div><br>

</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>cfg=[];</div><div>cfg.clustercritval = Fcritmain; % We genereate this before hand</div><div>cfg.tail = 1; cfg.clustertail = 1; cfg.clusterthreshold = 'parametric';</div>

<div>cfg.dim = [1 size(statobs,1) size(statobs,2) ] % <<< The key may be here</div><div>load('neuromag306mag_neighb.mat');</div><div>cfg.neighbours = neighbours;  </div><div>cfg.feedback = 'yes';</div>

<div>cfg.numrandomization = 1000;</div><div>cfg.clusterstatistic = 'maxsum';</div><div>cfg.layout = 'neuromag306mag.lay';</div><div><span style="white-space:pre-wrap">       </span>for i = 1:length(cfg.neighbours)</div>

<div><span style="white-space:pre-wrap">  </span>cfg.channel{i} = cfg.neighbours(i).label;</div><div><span style="white-space:pre-wrap">        </span>end</div><div><br></div><div>stat = clusterstat(cfg,statrnd, statobs)</div>
</blockquote><div><br></div><div>Which lead us to an error within findcluster </div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>Error using findcluster (line 59)</div><div>invalid dimension of spatdimneighbstructmat</div>

<div><br></div><div>Error in clusterstat (line 197)</div><div>            posclusobs = findcluster(reshape(postailobs, [cfg.dim,1]),channeighbstructmat,cfg.minnbchan);</div></blockquote><div><br></div><div>If anybody has got some insigth it would be greatly appreciated. Or any hints. Are the size of my statobs and starnd correct? I can share more information and firstly apologize  if I was not able to describe the problem accurately, I am confused regarding that 'reshape' and the addition of one dimension at "...reshape(postailobs,[cfg.dim,1])...", but the problem arises first when findcluster.m tries to calculate the size of spatdimneighbstructmat</div>

<div><br></div><div>First line of findcluster.m calcualtes 'spatdimlength' by : " spatdimlength = size(onoff, 1);" which in our case is "1", which is obviously wrong?.</div><div><br></div><div>

manythanks&peace2all</div><span><font color="#888888"><div><br></div>-- <br><div><font>Constantino Méndez-Bértolo<br></font></div><div><font>Laboratorio de Neurociencia Clínica,</font><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline"> Centro de Tecnología Biomédica (CTB)</span></font></div>

<p dir="ltr" style="text-align:justify;margin-top:0pt;margin-bottom:0pt"><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline">Parque Científico y Tecnológico d</span></font><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline">e la UPM, </span></font><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline">Campus de Montegancedo</span></font></p>

<p dir="ltr" style="text-align:justify;margin-top:0pt;margin-bottom:0pt"><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline">28223 Pozuelo de</span></font><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline"> Alarcón, Madrid, SPAIN</span></font></p>

<p dir="ltr" style="text-align:justify;margin-top:0pt;margin-bottom:0pt"><br></p><p dir="ltr" style="text-align:justify;margin-top:0pt;margin-bottom:0pt"><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline"><img src="https://docs.google.com/a/ctb.upm.es/uc?id=0B975KkJxc3ZdOGI2ODg4OTItYTYwNC00MDY4LTk0YzQtZDQzYzUwZjQwMWYx&export=download&hl=es" height="40" width="131"></span></font></p>


</font></span></div>
<br></div></div>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">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>
<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><br clear="all"><br>-- <br><div><font>Constantino Méndez-Bértolo<br></font></div><div><font>Laboratorio de Neurociencia Clínica,</font><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline"> Centro de Tecnología Biomédica (CTB)</span></font></div><p dir="ltr" style="text-align:justify;margin-top:0pt;margin-bottom:0pt"><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline">Parque Científico y Tecnológico d</span></font><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline">e la UPM, </span></font><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline">Campus de Montegancedo</span></font></p><p dir="ltr" style="text-align:justify;margin-top:0pt;margin-bottom:0pt"><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline">28223 Pozuelo de</span></font><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline"> Alarcón, Madrid, SPAIN</span></font></p><p dir="ltr" style="text-align:justify;margin-top:0pt;margin-bottom:0pt"><br></p><p dir="ltr" style="text-align:justify;margin-top:0pt;margin-bottom:0pt"><font><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline"><img src="https://docs.google.com/a/ctb.upm.es/uc?id=0B975KkJxc3ZdOGI2ODg4OTItYTYwNC00MDY4LTk0YzQtZDQzYzUwZjQwMWYx&export=download&hl=es" height="40" width="131"></span></font></p>
</div>