[FieldTrip] wavelet fourier output produces sign inverted imaginary part
Roemer van der Meij
r.vandermeij at donders.ru.nl
Fri Nov 2 13:21:06 CET 2012
Dear Björn,
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.
Please verify whether this is causing the phase-flip you mention in your
first paragraph.
All the best,
Roemer
On Fri, Nov 2, 2012 at 10:10 AM, Björn Herrmann <bherrmann at cbs.mpg.de>wrote:
> Dear fieldtrip users,
>
> I observed something strange using ft_freqanalysis with the "wavelet"
> method that might be important for many/some of you.
> 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:
>
>
> Cf = 5;
> Sf = 500;
> dur = 20;
>
> freqs = 1:10;
>
> cfg = [];
> cfg.method = 'wavelet';
> cfg.output = 'fourier';
> cfg.width = 3;
> cfg.toi = 0:0.01:dur;
>
> t = 0:1/Sf:(dur-1/Sf);
> data = [];
> data.avg = sin(2*pi*Cf*t+1.1);
> data.fsample = Sf;
> data.time = t;
> data.label = {'channel'};
> data.dimord = 'chan_time';
>
> floop = [];
> for ii = 1 : length(freqs)
> cfg.foi = freqs(ii);
> F = ft_freqanalysis(cfg, data);
> floop(:,ii) = squeeze(F.fourierspctrm);
> end
> cfg.foi = freqs;
> F = ft_freqanalysis(cfg, data);
> fonego = squeeze(F.fourierspctrm)';
>
> [real(floop(1000,1)), real(fonego(1000,1)); ...
> imag(floop(1000,1)), imag(fonego(1000,1)); ...
> angle(floop(1000,1)), angle(fonego(1000,1))]
>
> ans =
> -0.0128 -0.0128
> 0.0067 -0.0067
> 2.6605 -2.6605
>
>
> 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
> Based on some tests i did, I believe the fonego is the wrong one (i.e.
> using cfg.foi = [4 5]).
>
> All the best,
>
> Björn
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
--
Roemer van der Meij M.Sc.
PhD Candidate
Donders Institute for Brain, Cognition and Behaviour
Centre for Cognition
P.O. Box 9104
6500 HE Nijmegen
The Netherlands
Tel: +31(0)24 3655932
E-mail: r.vandermeij at donders.ru.nl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20121102/05d3690e/attachment-0002.html>
More information about the fieldtrip
mailing list