[FieldTrip] Coherence calculation in phalow_amphigh advanced

Alexander Wutzke alex.wutzke at gmail.com
Sun Nov 9 21:54:32 CET 2014

Dear Ladies and Gentlemen,

i have some problem by using the example code "phalow_amphigh" in advanced
(link: http://fieldtrip.fcdonders.nl/example/crossfreq/phalow_amphigh ). I
do my best in the last days to understand my issue, which i will described

First, the code will generate a powerspectrum with the 'mtmconvol' method.
For Signal2 at every 2Hz until 60Hz. After that it will do a 'mtmfft'
calculation, so that we get on both axies the frequency range.
What will happened to the powerspectrum of signal2 at 2Hz etc. in this case?
Powerspectrum of powerspectrum? This is another confusing point.
Finally, when i calculate the coherence between the created channels
(singal1 between signal2 at 2Hz etc.) i get some strange output. I use the
example signals in the code at your homepage.
The plotting with imagesc generate a picture which seems to be wrong. But
maybe it can also be, that i cant understand the result and therefore my
interpretation is false. In general, the signal1 and signal2 are
independend at different frequencys and the result should be a blue (low or
no coherence) picture. But i get some blue jets and the rest of the picture
is amlost red (high coherence). This is very confusing to me! Please tell
me what i do wrong or is there a fieldtrip bug?
Thanks a lot and you will make me very happy with your answer!

I used the Fieldtrip version from 9.11.14.

Yours sincerely

The code part for this issue:

cfg = [];
cfg.method    = 'mtmconvol';
cfg.channel   = 's2 (high)';
cfg.output    = 'pow';
cfg.taper     = 'hanning';
cfg.foi       = [2:2:60];
cfg.toi       = data.time{1}(3001:7000); %power is calculated at every
cfg.t_ftimwin = 4./cfg.foi; %timewindow used to calculated power is 4
cycles long and therefore differs over frequencies
cfg.keeptrials = 'yes';

freq4 = ft_freqanalysis(cfg,data);

% Make data same length as freq1
data_cut = data;
for iTr = 1:length(data.trial)
  data_cut.trial{iTr} = data.trial{iTr}(:,3001:7000);
  data_cut.time{iTr}  = data.time{iTr}(3001:7000);

data_app = ft_appenddata([],data_cut, freq4); %contains original channel
and channels with power
                                           %FieldTrip automatically
converts the freq4 data to raw data.

% mtmfft output cross-spectral-density between s2 (high)(raw) and freq4
cfg = [];
cfg.method    = 'mtmfft';
cfg.output    = 'powandcsd';
cfg.tapsmofrq  = 1;
cfg.foilim    = [2 60];
cfg.keeptrials = 'no';
cfg.pad = 4;
cfg.channelcmb = {'s1 (AM)' 's2 (high)@2Hz'; 's1 (AM)' 's2 (high)@4Hz'; 's1
(AM)' 's2 (high)@6Hz'; 's1 (AM)' 's2 (high)@8Hz'; 's1 (AM)' 's2
(high)@10Hz'; 's1 (AM)' 's2 (high)@12Hz'; 's1 (AM)' 's2 (high)@14Hz'; 's1
(AM)' 's2 (high)@16Hz'; 's1 (AM)' 's2 (high)@18Hz'; 's1 (AM)' 's2
(high)@20Hz'; 's1 (AM)' 's2 (high)@22Hz'; 's1 (AM)' 's2 (high)@24Hz'; 's1
(AM)' 's2 (high)@26Hz'; 's1 (AM)' 's2 (high)@28Hz'; 's1 (AM)' 's2
(high)@30Hz'; 's1 (AM)' 's2 (high)@32Hz'; 's1 (AM)' 's2 (high)@34Hz'; 's1
(AM)' 's2 (high)@36Hz'; 's1 (AM)' 's2 (high)@38Hz'; 's1 (AM)' 's2
(high)@40Hz'; 's1 (AM)' 's2 (high)@42Hz'; 's1 (AM)' 's2 (high)@44Hz'; 's1
(AM)' 's2 (high)@46Hz'; 's1 (AM)' 's2 (high)@48Hz'; 's1 (AM)' 's2
(high)@50Hz'; 's1 (AM)' 's2 (high)@52Hz'; 's1 (AM)' 's2 (high)@54Hz'; 's1
(AM)' 's2 (high)@56Hz'; 's1 (AM)' 's2 (high)@58Hz'; 's1 (AM)' 's2

freq5 = ft_freqanalysis(cfg,data_app);

%calculate coherence

cfg = [];
cfg.method    = 'coh';
coh = ft_connectivityanalysis(cfg,freq5);

coh.freq5 = [2:2:60];

figure; imagesc(coh.freq, coh.freq5, coh.cohspctrm); colorbar
ylabel('Frequency(1/Hz)');title('Coherencespectra S1 - S2');
axis xy
print -dpng phalow_amphigh_fig11.png
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20141109/6120d6c2/attachment-0001.html>

More information about the fieldtrip mailing list