# [Eeglablist] Normalizing Coherences in newcrossf.m

Samuel Norman-Haignere samuel.norman-haignere at yale.edu
Thu Jul 17 16:07:46 PDT 2008

```Hello,

I have just subscribed to the eeglablist, so it might still be necessary to
respond directly to my e-mail in order for me to get a response.

I have a question regarding the newcrossf function that is used to calculate
coherences.  I am trying to calculate the coherence between two time series
without any epoch.  The time series in this case are actually two voxel time
courses from an fMRI image, with a sampling rate of .67 Hz and a total
length of 288 time points.  When I run the newcrossf using these timecourses
I get a very reasonable looking coherence map, however the values are not
normalized.  I have now spent a fair amount of time searching around the
internet for resources on calculating coherence values and it seems that the
proper formula is coh(x) = |Sxy| ^2 / Sxx(f)Syy(f) (or the square root of
that) where Sxy is the cross spectrum between x and y and Sxx and Syy the
autospectra.  From the discussion at
http://www.dsprelated.com/showmessage/49505/1.php, it seems to make sense to
me that Sxy can be computed as Sxy(f) = X(f)Y'(f) where X and Y are the
fourier transforms of the two time series and Y' the complex conjugate of Y.
This seems to me to be born out by the code used to calculate the
unnormalized coherence values: coherres = alltfX .* conj(alltfY) where
alltfX and alltfY are the time/frequency decompositions of the two time
series as computed by the timefreq function in EEGLAB.  Sxx(f) should
therefore be computed as Sxx(f) = X(f)X'(f), and the equation for coherence
should become (in Matlab notation) coherres = (alltfX .*  alltfY) ./ sqrt(
(abs(alltfX) .^2) .*  (abs(alltfY) .^2)    ).  Running this however results
in all of the coherences becoming 1.  It is also interesting to meet that
virtually this exact formula (it also contains summing over a third
dimension which I do not believe exists in my runs) is found in the 'coher'
conditions.  It seems to meet from looking at the code that this 'coher'
condition is never or rarely satisfied, and when I forced EEGLAB to run
under the 'coher' condition it produced the exact same result of coherences
of value 1.

So my question is basically how it is possible to normalize the coherences
in the newcrossf function and what is wrong with my formula.

My call to newcrossf is as follows:  newcrossf(t1, t2, 288, [0 (288*1500)],
.67, 0)

Any responses would be very helpful!

Thanks,

Sam Norman-Haignere

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20080717/3d0bfd47/attachment.html
```