[FieldTrip] wavelet fourier output produces sign inverted imaginary part

Björn Herrmann bherrmann at cbs.mpg.de
Fri Nov 2 13:56:20 CET 2012

Dear fieldtrip users,

I have just received an anser to my email regarding the "sign inverted imaginary part".
It seems that I was introducing this error myself in my script by transposing the complex output. I did not know this before that this changes the sign of the imaginary part.

a = 3+1i;
b = a'
b = 
   3 - 1i

hmm. I am very sorry for the mistake and thankful to Matt bringing my attention to this. Thus, it seems fieldtrip does work alright regarding the output. I was working wrong.


Björn Herrmann

Auditory Cognition Group
Max Planck Institute for Human Cognitive and Brain Sciences
Stephanstrasse 1a, 04103 Leipzig, Germany

phone: ++49 (0)341 9940 2606
email: bherrmann at cbs.mpg.de

----- Ursprüngliche Mail -----
Von: fieldtrip-request at science.ru.nl
An: fieldtrip at science.ru.nl
Gesendet: Freitag, 2. November 2012 12:00:16
Betreff: fieldtrip Digest, Vol 24, Issue 2

Send fieldtrip mailing list submissions to
	fieldtrip at science.ru.nl

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to
	fieldtrip-request at science.ru.nl

You can reach the person managing the list at
	fieldtrip-owner at science.ru.nl

When replying, please edit your Subject line so it is more specific
than "Re: Contents of fieldtrip digest..."

Today's Topics:

   1. Minimal Stimulus Condition to evoke a detectable MEG	response
      (Mehmet-Akif Coskun)
   2. wavelet fourier output produces sign inverted imaginary	part
      (Bj?rn Herrmann)


Message: 1
Date: Thu, 01 Nov 2012 11:30:02 -0500
From: Mehmet-Akif Coskun <mcoskun at mail.uh.edu>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: [FieldTrip] Minimal Stimulus Condition to evoke a detectable
	MEG	response
Message-ID: <7280fbc125328.50925d3a at mail.uh.edu>
Content-Type: text/plain; charset="us-ascii"

Dear Fieldtrippers,

Is there any study that measured the minimal stimulus condition required to evoke a detectable MEG response. We acquire our data using 4D 248 sensor device and our stimulus is 1.8 kg/cm^2. We know this is above average but we also would like to know what is the threshold?

Also in many papers that i have seen, the threshold is measured as deflection of skin in mm. Is there a method that i can convert our units to find the deflection of skin?

I will greatly appreciate any helps,
Thanks in advance,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20121101/d13ae65d/attachment-0001.html>


Message: 2
Date: Fri, 2 Nov 2012 10:10:16 +0100 (CET)
From: Bj?rn Herrmann <bherrmann at cbs.mpg.de>
To: fieldtrip at science.ru.nl
Subject: [FieldTrip] wavelet fourier output produces sign inverted
	imaginary	part
Message-ID: <715262839.1275.1351847416532.JavaMail.root at zimbra>
Content-Type: text/plain; charset=utf-8

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);
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,



fieldtrip mailing list
fieldtrip at donders.ru.nl

End of fieldtrip Digest, Vol 24, Issue 2

More information about the fieldtrip mailing list