<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="">
Dear Dengyu,
<div class=""><br class="">
</div>
<div class="">Coherence is by definition a measure that is computed across observations. When computed on a single trial (with only a single degree of freedom, which is usually the case, unless heavy multitapering or Welch type of spectral estimation techniques
 are used: and even then highly biased estimates with poor spetral resolution will be the result), the value of coherence BY DEFINITION will be 1.</div>
<div class=""><br class="">
</div>
<div class="">If you nevertheless insist on a single trial estimate, you could consider using the jackknife (i.e. leave-one-out estimate) to estimate the single trial contribution to the ‘overall coherence’, optionally followed by the computation of so-called
 pseudovalues.</div>
<div class=""><br class="">
</div>
<div class="">See for example this paper for some more inspiration:</div>
<div class=""><br class="">
</div>
<div class=""><a href="https://science.sciencemag.org/content/316/5831/1609.long" class="">https://science.sciencemag.org/content/316/5831/1609.long</a></div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
J.M.Schoffelen, MD PhD<br class="">
Associate PI, VIDI-fellow - PI, language in interaction<br class="">
Telephone: +31-24-3614793</div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Physical location: room 00.028</div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands<br class="">
<br class="">
</div>
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 8 May 2019, at 16:31, Dengyu Wang <<a href="mailto:wangdy1995@gmail.com" class="">wangdy1995@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Dear FieldTrip members,
<div class="">I am using FieldTrip function <span style="font-family: Courier; font-size: 10px;" class="">ft_freqanalysis </span>and<span style="font-family: Courier; font-size: 10px;" class=""> </span><span style="font-family: Courier; font-size: 10px;" class="">ft_connectivityanalysis
</span>to calculate coherence coherence value between two channels, and I am following the tutorial: <a href="http://www.fieldtriptoolbox.org/tutorial/coherence/" class="">http://www.fieldtriptoolbox.org/tutorial/coherence/</a>.</div>
<div class=""><br class="">
</div>
<div class="">The data used in the tutorial is:</div>
<div class=""><span id="cid:DEB249F9-4C9E-4D05-AF12-C0105776ABBD"><Screen Shot 2019-05-08 at 10.18.03 AM.png></span></div>
<div class="">It has 153 channels and 164 trials, and each trial is 1s long (1200 data points).</div>
<div class=""><br class="">
</div>
<div class="">Then the following code is used to calculate the power spectrum and cross-spectral density:</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg            = [];</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.output     = <span style="color: #a020f0" class="">'powandcsd'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.method     = <span style="color: #a020f0" class="">'mtmfft'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.foilim     = [5 100];</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.tapsmofrq  = 5;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.keeptrials = <span style="color: #a020f0" class="">'yes'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.channel    = {<span style="color: #a020f0" class="">'MEG'</span> <span style="color: #a020f0" class="">
'EMGlft'</span> <span style="color: #a020f0" class="">'EMGrgt'</span>};</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(160, 32, 240);" class="">
<span style="" class="">cfg.channelcmb = {</span>'MEG'<span style="" class=""> </span>
'EMGlft'<span style="" class="">; </span>'MEG'<span style="" class=""> </span>'EMGrgt'<span style="" class="">};</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
freq           = ft_freqanalysis(cfg, data);</div>
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div class="">It results in a data like this:</div>
<div class=""><span id="cid:869DA8BB-BF23-4206-AE0D-2B53D4472004"><Screen Shot 2019-05-08 at 10.21.31 AM.png></span></div>
<div class=""><br class="">
</div>
<div class="">The data contains the power spectrum for each channel (n=153) and each trial (n=164), and the cross-spectral density for 302 channel combinations, for each trial (n=164).</div>
<div class=""> </div>
<div class="">And then this data is fed to <span style="font-family: Courier; font-size: 10px;" class="">ft_connectivityanalysis </span>to calculate coherence between channel combinations specified in freq.labelcmb:</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg            = [];</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.method     = <span style="color: #a020f0" class="">'coh'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.channelcmb = {<span style="color: #a020f0" class="">'MEG'</span> <span style="color: #a020f0" class="">
'EMG'</span>};</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fd             = ft_connectivityanalysis(cfg, freq);</div>
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="font-family: Helvetica; font-size: 12px;" class="">And then we get data:</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span id="cid:028C0A24-260D-463D-9B4B-5E55E61A9EE8"><Screen Shot 2019-05-08 at 10.23.56 AM.png></span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""> I found that the resulting fd.cohspctrm has a dimension of ‘chancmb_freq’, and the dimension of “rpt” is gone, so I realize that the coherence here is calculated across trials. </div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">However, I would want to calculate the coherence value for each trial, so that I can have 164 (number of trials) coherence measures between two channels in stead of just one.</div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Could any one give me some suggestion? Or if I misunderstand something could any one point out to me? Thank you very much!</div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Best,</div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Dengyu</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://doi.org/10.1371/journal.pcbi.1002202<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
<br class="">
<br class="">
<div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<br class="">
</div>
</div>
</div>
</div>
</div>
<br class="">
</body>
</html>