<div dir="ltr">Dear Iman,<div><br></div><div><span style="color:rgb(0,0,0);font-family:'Courier New';font-size:13.3333330154419px">> coherres = sum(alltfX .* conj(alltfY), 3) ./ sqrt( sum(abs(alltfX).^2,3) .* sum(abs(alltfY).^2,3) );</span><br></div><div><span style="color:rgb(0,0,0);font-family:'Courier New';font-size:13.3333330154419px"><br></span></div><div><font color="#000000" face="Courier New">So '</font><span style="color:rgb(0,0,0);font-family:'Courier New';font-size:13.3333330154419px">sum(alltfX .* conj(alltfY), 3)' sums all data points? If so, as long as the number of data points distribute uniformly across all trials, the mean of the mean is the same as the grand mean. Am I wrong? Please correct me.</span></div><div><span style="color:rgb(0,0,0);font-family:'Courier New';font-size:13.3333330154419px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:'Courier New';font-size:13.3333330154419px">Makoto </span></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 23, 2015 at 4:03 PM, Iman Mohammad-Rezazadeh <span dir="ltr"><<a href="mailto:irezazadeh@ucdavis.edu" target="_blank">irezazadeh@ucdavis.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi,
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">The way the code scripted is to calculate the spectrum from the whole data at once
<u></u><u></u></span></p><span>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">[alltfX freqs timesout] = timefreq(X, g.srate, spectraloptions{:})
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
</span><p class="MsoNormal"><a name="14ebd9fd9179867f_14ebd28779a8439e__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Not each epoch separately and then make an average from them. and yes in matters !<u></u><u></u></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Best,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Iman
<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Makoto Miyakoshi [mailto:<a href="mailto:mmiyakoshi@ucsd.edu" target="_blank">mmiyakoshi@ucsd.edu</a>]
<br>
<b>Sent:</b> Thursday, July 23, 2015 3:44 PM<br>
<b>To:</b> Iman Mohammad-Rezazadeh <<a href="mailto:irezazadeh@UCDAVIS.EDU" target="_blank">irezazadeh@UCDAVIS.EDU</a>><br>
<b>Cc:</b> EEGLAB List <<a href="mailto:eeglablist@sccn.ucsd.edu" target="_blank">eeglablist@sccn.ucsd.edu</a>>; Loo, Sandra <<a href="mailto:SLoo@mednet.ucla.edu" target="_blank">SLoo@mednet.ucla.edu</a>>; Scott Makeig <<a href="mailto:smakeig@ucsd.edu" target="_blank">smakeig@ucsd.edu</a>>; Chantelle C Kinzel <<a href="mailto:ckinzel@mednet.ucla.edu" target="_blank">ckinzel@mednet.ucla.edu</a>>; Michelini, Giorgia <<a href="mailto:giorgia.michelini@kcl.ac.uk" target="_blank">giorgia.michelini@kcl.ac.uk</a>><br>
<b>Subject:</b> Re: A tentative issue in coherence calculation in EEGLAB for epoched data<u></u><u></u></span></p><div><div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Dear Iman,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I ask you this without testing it, but does the order of the averaging process makes difference in results?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Makoto<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Mon, Jul 20, 2015 at 10:09 AM, Iman Mohammad-Rezazadeh <<a href="mailto:irezazadeh@ucdavis.edu" target="_blank">irezazadeh@ucdavis.edu</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Hi EEGLABERs,
<u></u><u></u></p>
<p class="MsoNormal">I have been looking into ‘newcrossf’ function and the way it calculates coherence for epoched data. Basically, it uses the ‘timefreq’ function to calculate the time/frequency decomposition
the data. ‘timefreq’ function treats the epoched data as a continuous one:<u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:"Courier New";color:black">X = reshape(X, g.frame, g.trials);</span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:"Courier New";color:black">[alltfX freqs timesout] = timefreq(X, g.srate, spectraloptions{:});</span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:"Courier New";color:black">Y = reshape(Y, g.frame, g.trials);</span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:"Courier New";color:black">[alltfY] = timefreq(Y, g.srate, spectraloptions{:});</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">and calculates the its spectrum using the whole data which is now concatenated version of all trials. So, for each of channel’s pair (X and Y , for example) the spectrum is calculated
as described above and then the joint time-freq decomposition is calculated for coherence value.<u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:"Courier New";color:black">coherres = sum(alltfX .* conj(alltfY), 3) ./ sqrt( sum(abs(alltfX).^2,3) .* sum(abs(alltfY).^2,3) );</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><b>However, similar to the ERSP concept, each trial/epoch might be different than others [because of perturbations in subjects’ mental status, mental fatigue, etc] and thus I think
it is more appropriate to calculate the coherence for each trial first and then make the average across trials.</b><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Any thoughts?<u></u><u></u></p>
<p class="MsoNormal"><span style="color:#888888">Iman <u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#888888"> <u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#888888"> <u></u><u></u></span></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">Makoto Miyakoshi<br>
Swartz Center for Computational Neuroscience<br>
Institute for Neural Computation, University of California San Diego<u></u><u></u></p>
</div>
</div>
</div>
</div></div></div>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div></div>
</div></div>