[Eeglablist] A tentative issue in coherence calculation in EEGLAB for epoched data

Iman Mohammad-Rezazadeh irezazadeh at ucdavis.edu
Thu Jul 23 16:03:12 PDT 2015

The way the code scripted is to calculate the spectrum from the whole data at once

[alltfX freqs timesout] = timefreq(X, g.srate, spectraloptions{:})

Not each epoch separately and then make an average from them.  and yes in matters !

From: Makoto Miyakoshi [mailto:mmiyakoshi at ucsd.edu]
Sent: Thursday, July 23, 2015 3:44 PM
To: Iman Mohammad-Rezazadeh <irezazadeh at UCDAVIS.EDU>
Cc: EEGLAB List <eeglablist at sccn.ucsd.edu>; Loo, Sandra <SLoo at mednet.ucla.edu>; Scott Makeig <smakeig at ucsd.edu>; Chantelle C Kinzel <ckinzel at mednet.ucla.edu>; Michelini, Giorgia <giorgia.michelini at kcl.ac.uk>
Subject: Re: A tentative issue in coherence calculation in EEGLAB for epoched data

Dear Iman,

I ask you this without testing it, but does the order of the averaging process makes difference in results?


On Mon, Jul 20, 2015 at 10:09 AM, Iman Mohammad-Rezazadeh <irezazadeh at ucdavis.edu<mailto:irezazadeh at ucdavis.edu>> wrote:

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:

X = reshape(X, g.frame, g.trials);
[alltfX freqs timesout] = timefreq(X, g.srate, spectraloptions{:});

Y = reshape(Y, g.frame, g.trials);
[alltfY] = timefreq(Y, g.srate, spectraloptions{:});

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.

coherres = sum(alltfX .* conj(alltfY), 3) ./ sqrt( sum(abs(alltfX).^2,3) .* sum(abs(alltfY).^2,3) );

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.

Any thoughts?

Makoto Miyakoshi
Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20150723/8d29a35f/attachment.html>

More information about the eeglablist mailing list