<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 Chris,
<div class=""><br class="">
</div>
<div class="">I notice that you only have a single trial in your data. In Fieldtrip, the unit-of-observation that goes into the coherence computation is the so-called ‘rpttap’ dimension, which is the number of trials times the number of tapers applied. If this
 number is 1, then the coherence will be 1, by mathematical definition. </div>
<div class=""><br class="">
</div>
<div class="">When the trial length is 0.7 seconds, the specification of tapsmofrq leads to 6 Slepian tapers to be applied (i.e. 2*0.7*5-1), thus to a rpttap of 6 times the number of trials. This brings down the coherence values (but will no doubt still lead
 to quite biased estimates, because your input just contains a single trial). With only a 0.2 s window selected, the number of tapers will be 1: (2*0.2*5-1), and thus coherence will indeed trivially go to 1 all over the place. I don’t know what happens in the
 0.5 s case, though, provided your reported all-ones in this case are indeed observed in this situation as well.</div>
<div class=""><br class="">
</div>
<div class="">Long story short, you should increase the number of trials in your computation, or ramp up the smoothing parameter (the latter makes you lose spectral resolution, so probably that’s undesired).</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 29 Apr 2021, at 09:24, Christodoylos Karittevlis <<a href="mailto:christodoylos_k@hotmail.com" class="">christodoylos_k@hotmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="WordSection1" style="page: WordSection1; 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;">
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Dear Fieldtrip Community,</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
I am using the function ft_freqanalysis to calculate power spectrum and cross spectrum and after that I calculate the Magnitude Squared Coherence.</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
The trials are defined to start from -0.200s up to +0.500s .</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
When I use the function ft_freqanalysis on the whole trial it works fine , Coherence gives values from 0 to 1.</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
But when I try to use it only for the prestimulus period (e.g -0.2s – 0s ) or only to the poststimulus period (e.g 0 : 0.5s) , I think it does not work correctly because the Magnitude Squared Coherence is equal to 1 for all the pairs of channels .</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Do you know if I can calculate the power spectrum and cross spectrum only for prestimulus period or only to the poststimulus period ?</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
This is the script that I am using :</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg            = [];<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg.output     = 'powandcsd';<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg.method     = 'mtmfft';<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg.foilim     = [5 100];<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg.pad        ='nextpow2';<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg.tapsmofrq  = 5;<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg.keeptrials = 'yes';<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg.trials     = [1] ;<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">freq          = ft_freqanalysis(cfg, data );<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
data have the structured as the output of ft_preprocessing.</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
When I want to select only the prestimulus or post stimulus period I am using :</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg = [];<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg.latency = [-0.2 0] ;<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">data_pre = ft_selectdata(cfg,data) ;<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">% select only the post stimulus period 0:0.2<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg = [] ;<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">cfg.latency = [0 0.5];<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="color: rgb(68, 114, 196);" class="">data_post = ft_selectdata(cfg,data) ;<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Thank you in advance!</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Kind regards,</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Chris</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Sent from<span class="Apple-converted-space"> </span><a href="https://urldefense.com/v3/__https://go.microsoft.com/fwlink/?LinkId=550986__;!!HJOPV4FYYWzcc1jazlU!qTYweIa9rVq5IOMpogVpem_hxn63jpoEOR2mm9J786hT9C72LMok_ZxRD46-sN2WZAUbq-_B$" style="color: blue; text-decoration: underline;" class="">Mail</a><span class="Apple-converted-space"> </span>for
 Windows 10</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></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="color: blue; text-decoration: underline; 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!qTYweIa9rVq5IOMpogVpem_hxn63jpoEOR2mm9J786hT9C72LMok_ZxRD46-sN2WZE6-sjJY$" style="color: blue; text-decoration: underline; 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!qTYweIa9rVq5IOMpogVpem_hxn63jpoEOR2mm9J786hT9C72LMok_ZxRD46-sN2WZE6-sjJY$</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>