[FieldTrip] Time-frequency granger analysis

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Mon Jul 8 10:05:39 CEST 2019


Hi Daniel,

As with any connectivity metric that needs a cross-spectrum estimate (and specifically for NPSF-based Granger causality estimates), this estimate needs to make sense. In your case, it doesn’t, for several reasons;

1) you only have a single ’trial’ of data, i.e. for every time point the csd is extremely unstable, and will never-ever give meaningful results numerically, even if the rest of the conditions are favorable.
2) in order for the NPSF algorithm to work, the spectral representation needs to be a) smooth, requiring multitapers (+sufficient number of observations) and b) the spectrum needs to be defined from DC to Nyquist.

I recommend you read a bit more in the documentation (and references mentioned) about the underlying algorithmic machinery, and look for some example code in the tutorials/FAQs to get in a more favorable starting position.

Hints:
1) forget about the ’time-frequency’ aspect, and focus on frequency only.
2) this means that you cut your data into smaller snippets, which are to be used as ovbservations, this can be done with ft_redefinetrial
3) then, use ‘mtmfft’ as method for ft_freqanalysis in combination with an appropriate amount of spectral smoothing (’tapsmofrq’) + ‘fourier’ as output.
4) then, think about what your data represents (in terms of referencing etc.) -> if you want a full multivariate NPSF while the data are rank deficient (e.g. with a common average, or another funky referencing scheme), the result will probably be NaN. In which case you’d need to specify cfg.granger.sfmethod = ‘bivariate’, or ditch one of the channels from your multivariate decomposition.

JM


On 6 Jul 2019, at 16:23, daniel.strahnen at uni-ulm.de<mailto:daniel.strahnen at uni-ulm.de> wrote:

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

Daniel

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190708/0c1400df/attachment-0002.html>
-------------- next part --------------
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


More information about the fieldtrip mailing list