[FieldTrip] Time-frequency map of Granger causality from Fourier spectrum

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Wed Jun 23 11:53:09 CEST 2021

Hi Eva,

Allow me to point you to the discussion list’s archive. Specifically:




might be of relevance. In particular reason ‘2’, and Hints 1-3 in the 2019-July thread.

I suggest to start from there. Don’t hesitate to ask questions if you keep being stuck.

Best wishes,


On 23 Jun 2021, at 10:56, Eva Masson via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hi FieldTrip Community !

I need your wisdom !

I am trying to compute a time-frequency map of Granger causality for EEG data using a non parametric approach. To do so, I computed the Fourier Spectrum using the ‘mtmconvol’ method of ft_freqanalysis and I am now trying to feed it into ft_connectivityanalysis using the ‘granger’ method. I get an error that I don’t understand.

Here is the freq structure I’m trying to force into ft_connectivityanalysis :

freq =
            label: {2x1 cell}
           dimord: 'rpttap_chan_freq_time'
             freq: [1x64 double]
             time: [1x31 double]
    fourierspctrm: [4-D double]
        cumtapcnt: [1x64 double]
              cfg: [1x1 struct]

How I use ft_connectivityanalysis :

cfg = [];
cfg.method = 'granger';

granger = ft_connectivityanalysis(cfg, freq);

And the error message Matlab displays :

Error using zeros
Size inputs must be integers.

Error in sfactorization_wilson (line 63)
  S        = cat(3, zeros(size(S,1), size(S,1), npad), S);

Error in ft_connectivity_csd2transfer (line 181)
      [Htmp, Ztmp, Stmp] = sfactorization_wilson(tmp, freq.freq, ...

Error in ft_connectivityanalysis (line 430)
        data   = ft_connectivity_csd2transfer(data, optarg{:});

Can you enlighten me on this issue ?
Thanks a lot for your help !


fieldtrip mailing list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210623/a670f298/attachment.htm>

More information about the fieldtrip mailing list