[FieldTrip] Time-frequency granger analysis

Tom Marshall tom.marshall at psy.ox.ac.uk
Sat Jul 6 17:47:37 CEST 2019

Hi Daniel,

I haven't been able to reproduce your problem exactly, but one point: Fieldtrip 'raw' data structures represent time in seconds. So if you are trying to create a data structure with 600 seconds of data, with a sampling frequency of 1000Hz, then your time axis should go from 0 to 600 (or from n to 600+n).

So instead of

data.time{1} = 1:600000;

you should specify

data.time{1} = 0.001:0.001:600;

Good luck!


From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of daniel.strahnen at uni-ulm.de <daniel.strahnen at uni-ulm.de>
Sent: 06 July 2019 15:23
To: 'FieldTrip discussion list'
Subject: [FieldTrip] Time-frequency granger analysis

Dear FieldTrip – Community,

My goal is to analyse changes of Granger Causality over a certain time period.

Here is the code I use to calculate the wavelet analysis:

data.label = {'CH1'; 'CH2'; 'CH3'; 'CH4'; 'CH5'; 'CH6'; 'CH7'};

data.fsample = 1000; % Sampling rate of 1kH

data.time{1} = 1:600000;

data.trial{1} = Output_data'; % Matrix organised as follows: 7 chan x 600000 samples

%% Wavelets for time-frequency power analysis

cfg              = [];

cfg.output       = 'powandcsd';

cfg.method       = 'wavelet';

cfg.foi          = 1:48;     % Frequency range from 1 to 48Hz

cfg.t_ftimwin    = ones(length(cfg.foi),1).*0.5;   % length of time window = 0.5 sec

cfg.toi          = 0:600; % 600 seconds (10min) time period

freq_data          = ft_freqanalysis(cfg, data);

Up to this point everything seems to be correct, but the granger analysis only gives my NaNs.

%% Granger causality analysis

cfg_conn = [];

cfg_conn.method = 'granger';

granger_str = ft_connectivityanalysis(cfg_conn, freq_data);

Does anyone has a suggestion what might be the mistake in my code?

Thank you very much and best regards


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190706/84bde6b9/attachment-0002.html>
-------------- next part --------------
fieldtrip mailing list

More information about the fieldtrip mailing list