<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="">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=""><img apple-inline="yes" id="4376CA29-1225-48B6-BFFA-494A2FEB9A20" src="cid:DEB249F9-4C9E-4D05-AF12-C0105776ABBD" class=""></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="color: #000000" class="">cfg.channelcmb = {</span>'MEG'<span style="color: #000000" class=""> </span>'EMGlft'<span style="color: #000000" class="">; </span>'MEG'<span style="color: #000000" class=""> </span>'EMGrgt'<span style="color: #000000" 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=""><img apple-inline="yes" id="2810B8DA-1992-4B74-B3B9-A6A99E4D76C7" src="cid:869DA8BB-BF23-4206-AE0D-2B53D4472004" class=""></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=""><img apple-inline="yes" id="5FF90522-FA88-466E-BBDB-1BC6B2192EBD" src="cid:028C0A24-260D-463D-9B4B-5E55E61A9EE8" 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; 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></body></html>