<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Anna-Maria,
<div class=""><br class="">
</div>
<div class="">There are 2 issues at hand here.</div>
<div class=""><br class="">
</div>
<div class="">In principle it should be possible to (1) hand-craft a data structure such that ft_freqstatistics/(or ft_timelockstatistics) swallows it, in order to do inferential statistics. If - on top of that - you wish (2) to use a cluster-heuristic to address
 the multiple comparison problem, it would in addition require a defendible adjacency matrix for the edges in your graph. Neither of these 2 points have a ready made solution in FieldTrip, so it would require to make your hands dirty.</div>
<div class=""><br class="">
</div>
<div class="">w.r.t. point (1), you could create for each subject and condition a data structure that has the (lower triangle) of the connectivity matrices, as a function of frequency. In order for FieldTrip to ‘understand’ these data structures, you’d need
 to make them internally consistent, i.e. have the freq.dimord to be ‘chan_freq’, and have a freq.label field to be a  N(N-1)/2 x 1 cell-array containing the names of the channels. In this case you could e.g. combine the two labels of the channels that constitute
 a pair:</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">for k = 1:numel(freq.freq)</div>
<div class="">  C(:,k ) = tril(freq.cohspctrm(:,:,k), -1);</div>
<div class="">end</div>
<div class=""><br class="">
</div>
<div class="">% and</div>
<div class=""><br class="">
</div>
<div class="">for k = 1:numel(freq.label)</div>
<div class="">  for m = (k+1):numel(freq.label)</div>
<div class="">    L{k,1} = sprintf(‘%s_%s’, freq.label{k}, freq.label{m});</div>
<div class="">  end</div>
<div class="">end</div>
<div class=""><br class="">
</div>
<div class="">freqnew = [];</div>
<div class="">freqnew.powspctrm = C;</div>
<div class="">freqnew.label = L;</div>
<div class="">freqnew.dimord = ‘chan_freq’;</div>
<div class="">freqnew.freq = freq.freq; % plus perhaps some other stuff is needed, but I am not sure</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">w.r.t. point(2), this is more tricky. Conceptually, you’d need an adjacency matrix of size  N(N-1)/2 x N(N-1)/2 that defines which channel pairs are each others’ neighbours. There is no straightforward way to define this in terms of a ’neighbours’
 struct-array in the same way as this can be done for univariate data (i.e. by calling ft_prepare_neighbours or so). However, the ft_<something>statistics functions allow for the use of a cfg.connectivity field, which is a boolean adjacency matrix, that will
 be used for the clustering (in fact, the cfg.neighbours structure will be converted into such a matrix in the lower-level code). In itself, the use of the cfg.connectivity directly should be done with care, because there is no internal check w.r.t. the consistent
 ordering and identity of the channels in this matrix with respect to the data (which is different from when the cfg.neighbours are used). If however the order and identity of the channels in all data arguments into the function are consistent, and this order
 is also maintained in the cfg.connectivity matrix, then using the cfg.connectivity matrix would be OK. The minor detail left is then how to hand-craft such an adjacency matrix. One possible way forward could be to define as neighbouring edges those channel
 pairs for which one of the two channels are each other’s first order neighbours:</div>
<div class=""><br class="">
</div>
<div class="">for instance, if ‘a’ ‘b’ and ‘c’ are local neighbours, and ‘p’ ‘q’ and ‘r’ as well, then one could define ‘a-p’ as a neighbour to ‘a-q’, (and ‘b-p’ as a neighbour to ‘a-p’). The question is whether ‘a-p’ should be a neighbour to ‘b-q’, but I leave
 that up to you to think about it, and to consider whether you’d really need clustering for your statistical inference.</div>
<div class=""><br class="">
</div>
<div class="">An alternative approach could be to do statistics on (the difference between) derived graph metrics of your coherence matrices, or of a graph metric derived from the coherence difference matrix. This would give you a univariate channel by frequency
 metric that can be subjected to the traditional spatial clustering.</div>
<div class=""><br class="">
</div>
<div class="">I hope this helps, and keep up the good work,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On 9 May 2023, at 18:46, Grob, Anna-Maria 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 id="divtagdefaultwrapper" dir="ltr" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class="">
<p style="margin-top: 0px; margin-bottom: 0px; font-family: "TheSans UHH", Calibri; line-height: 16.133333206176758px; font-size: 11pt;" class="">
<font size="3" face="Calibri,Helvetica,sans-serif" style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont;" class=""><span id="divtagdefaultwrapper" style="font-size: 12pt;" class=""></span></font></p>
<font size="3" face="Calibri,Helvetica,sans-serif" style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont;" class="">
<div style="margin-top: 0px; margin-bottom: 0px;" class="">Dear FieldTrip community,<span class="Apple-converted-space"> </span><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">I have computed the coherence between all channels for a specific stimulus and would now like to compare the output matrix (maybe just the upper triangle) between two groups (Sham vs. TMS). What would
 you suggest?<span class="Apple-converted-space"> </span><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">I have tried tweaking the matrix into a single vector to input it into the ft_timelockstatistics, but this did not rally work - also the neighbours file obviously does not fit anymore, since i now have
 a Channel x Channel matrix and its not ordered by single channels, if this makes sense.<span class="Apple-converted-space"> </span><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">Here is a picture of the coherence matrix of one participant:<span class="Apple-converted-space"> </span><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><span id="cid:d94e2244-d961-455b-9810-e3d46ef65765"><pastedImage.png></span></div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">Best,<span class="Apple-converted-space"> </span><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">Anna-Maria<br class="">
</div>
</font><span class="addresses"><a class="link emil" href="mailto:anna-maria.grob@uni-hamburg.de" id="LPNoLP"><span class="d"></span></a></span><br class="">
<br class="">
<br class="">
<p style="margin-top: 0px; margin-bottom: 0px;" class=""></p>
<div id="Signature" class="">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" class="">
<br class="">
<p style="margin-top: 0px; margin-bottom: 0px;" class=""></p>
</div>
</div>
</div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">fieldtrip
 mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: 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; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!5CAhodCyjiIwCfEeVK_b1ynuo37Xyw-kDXBcpZNVRsHcCCl7XuUGUXhPXVfVfLpAeM9QFeszVKqeGwFtZf37TYu30Im3RU0czxymSw$" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: 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; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!5CAhodCyjiIwCfEeVK_b1ynuo37Xyw-kDXBcpZNVRsHcCCl7XuUGUXhPXVfVfLpAeM9QFeszVKqeGwFtZf37TYu30Im3RU0czxymSw$</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""></span></div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>