Dear <span style="font-size:13px;font-family:arial,sans-serif">Björn</span>, <div><br></div><div>Please note that in your example, you take the complex conjugate transpose of 'fonego'. This changes the sign of the imaginary part of your Fourier coefficients. </div>
<div><br></div><div>Please verify whether this is causing the phase-flip you mention in your first paragraph.</div><div><br></div><div>All the best,</div><div>Roemer</div><div class="gmail_extra"><br><br><br><div class="gmail_quote">
On Fri, Nov 2, 2012 at 10:10 AM, Björn Herrmann <span dir="ltr"><<a href="mailto:bherrmann@cbs.mpg.de" target="_blank">bherrmann@cbs.mpg.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear fieldtrip users,<br>
<br>
I observed something strange using ft_freqanalysis with the "wavelet" method that might be important for many/some of you.<br>
It seems that the imaginary part of the fourier output (from "wavelet") is sign inverted for the TFR calculated for more than one frequency at once (i.e. cfg.foi = [4 5]) as compared to the TFR calculated independently for the frequencies (i.e., first cfg.foi = 4, and then cfg.foi = 5). This impacts the phase angle which is backwards in case of calculating the TFR for more frequencies in one go. amplitude/power is unaffected and it seems also ITPC calculations. momentary phase and therefore some phase-amplitude coupling measures are, however, affected by this. I attached a bit of code showing the difference:<br>
<br>
<br>
Cf = 5;<br>
Sf = 500;<br>
dur = 20;<br>
<br>
freqs = 1:10;<br>
<br>
cfg = [];<br>
cfg.method = 'wavelet';<br>
cfg.output = 'fourier';<br>
cfg.width = 3;<br>
cfg.toi = 0:0.01:dur;<br>
<br>
t = 0:1/Sf:(dur-1/Sf);<br>
data = [];<br>
data.avg = sin(2*pi*Cf*t+1.1);<br>
data.fsample = Sf;<br>
data.time = t;<br>
data.label = {'channel'};<br>
data.dimord = 'chan_time';<br>
<br>
floop = [];<br>
for ii = 1 : length(freqs)<br>
cfg.foi = freqs(ii);<br>
F = ft_freqanalysis(cfg, data);<br>
floop(:,ii) = squeeze(F.fourierspctrm);<br>
end<br>
cfg.foi = freqs;<br>
F = ft_freqanalysis(cfg, data);<br>
fonego = squeeze(F.fourierspctrm)';<br>
<br>
[real(floop(1000,1)), real(fonego(1000,1)); ...<br>
imag(floop(1000,1)), imag(fonego(1000,1)); ...<br>
angle(floop(1000,1)), angle(fonego(1000,1))]<br>
<br>
ans =<br>
-0.0128 -0.0128<br>
0.0067 -0.0067<br>
2.6605 -2.6605<br>
<br>
<br>
I thought this might be important for some of you, independently of a bug report i'll try to send later (i have to figure out how this works first). My colleagues and I were unable to fix the problem in the fieldtrip script directly, but a simple solution is to do the following: real(fourier)+(imag(fourier)*-1)*1i<br>
Based on some tests i did, I believe the fonego is the wrong one (i.e. using cfg.foi = [4 5]).<br>
<br>
All the best,<br>
<br>
Björn<br>
<br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></blockquote></div><br></div>
<br clear="all"><div><br></div>-- <br><font size="3"><font color="darkblue"><font face="calibri">Roemer
van der Meij M.Sc.<br>
PhD Candidate<br>
Donders Institute for Brain, Cognition and Behaviour<br>
Centre for Cognition<br>
P.O. Box 9104<br>
6500 HE Nijmegen<br>
The Netherlands<br>
Tel: +31(0)24 3655932<br>
E-mail: <a href="mailto:r.vandermeij@donders.ru.nl" target="_blank">r.vandermeij@donders.ru.nl</a></font></font></font><div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%">
</div><br>