wavelet analysis!
Jan Mathijs Schoffelen
Jan.Schoffelen at FCDONDERS.RU.NL
Thu Jun 14 14:41:06 CEST 2007
Dear Alex,
>When I compute coherence (using 'freqdescriptives') based on a frequency
>transform using 'freqanalysis_wltconvol', I get coherence values larger
>than 1. This has also been observed by Muthuraman before.
>
>The script below demonstrates this observation and also that
>freqanalysis_mtmconvol does everything correctly. I think the problem is
>pertinent to all current fieldtrip versions.
I'm very glad that you started trying out to solve the problem yourself.
Solving a problem indeed always starts with finding out where it goes wrong
;)
>While I can easily switch to mtmconvol I thought it could be useful to
>address this issue. Does anyone have an idea?
Yes, I have an idea. Regarding your suggested switch to mtmconvol I can only
very much support you to do so, but let's address the issue:
You construct 4 trials of surrogate data with an expected coherence of 1.
What you find is a coherence of 1 with mtmconvol, but a coherence of >1 with
wltconvol. Let's tackle the problem from its tail to find the cause, by
looking at the mathematics to compute coherence:
In pseudo-mathematics this yields:
Coherence = abs(mean(csd))./sqrt(mean(pow1)*mean(pow2)).
In your simulated case, you explicitly equated signal 1 and 2, which means
that the csd would be:
1 real-valued
2 equivalent to the power of one of the signals
(does everybody still agree?)
In pseudo-mathematics:
Pow1 = pow2 = csd: coherence = abs(mean(pow))./sqrt(mean(pow)*mean(pow))=
p/sqrt(p^2) = 1
Apparently, wltconvol either gives back too big a csd, or too small a pow1
(and pow2).
Let's have a look at the code then (of course you and Muthuraman already
did):
Mtmconvol line 450: powdum = 2.* abs(autspctrmacttap) .^ 2 ./ actfoinumsmp;
Mtmconvol line 489: csddum = 2.* (autspctrmacttap(cutdatindcmb(:,1),:) .*
conj(autspctrmacttap(cutdatindcmb(:,2),:))) ./ actfoinumsmp;
So these lines compute the power (450) and the csd (489). The 2 and the
actfoinumsmp are needed for a proper normalization. So far so good.
Wltconvol l. 279: powdum = (2.* abs(autspctrmacttap) ./ data.fsample) .^ 2;
Wltconvol l. 292: csddum = 2.* (autspctrmacttap(cutdatindcmb(:,1),:) .*
conj(autspctrmacttap(cutdatindcmb(:,2),:))) ./
data.fsample; %actfoinumsmp
Oooops! As you can see, the normalization of powdum is different from the
normalisation of csddum. In fact there is an additional 2./data.fsample
(still with me? The squaring is taken outside of the brackets), as compared
to the csddum. This would even allow me to predict the (wrong) coherence
outputted by your little simulation, but I leave that up to you guys.
This is indeed a bug and will be fixed.
Keep up the good work.
J-M
----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.
More information about the fieldtrip
mailing list