mne-tools / mne-connectivity

Connectivity algorithms that leverage the MNE-Python API.
https://mne.tools/mne-connectivity/dev/index.html
BSD 3-Clause "New" or "Revised" License
68 stars 34 forks source link

Option to implement Granger causality analysis from the time domain? #243

Open an99xf opened 1 month ago

an99xf commented 1 month ago

It's great that Granger causality analysis has been incorporated in mne_connectivity.spectral_connectivity_epochs, which supports extensive frequency- and time-frequency-domain connectivity methods. However, Granger causality analysis actually can be done from time-series data (time domain), and this was developed already in Matlab (see Multivariate Granger Causality Toolbox).

Would it be possible to provide an option to implement Granger causality analysis from the time domain?

tsbinns commented 1 month ago

Hi, thanks for your post!

Definitely time domain Granger causality is useful to have. If you don't need it to be multivariate, you should be able to compute time domain GC using the vector_auto_regression() function. This tutorial has more info on how this can be used to compute the covariance of your residuals, which could then be used to compute a Granger score. Admittedly it's a bit more hands-on, but it is possible with the current tools.

I will say, I tried this recently and for the most part it worked, however I did run into some errors/undocumented behaviour which perhaps need to be addressed.

On the other hand, if you want it to be multivariate GC, then that requires new code. It might not be so difficult to implement since the multivariate method we currently use is just the frequency domain extension of the method by the same authors of that MATLAB toolbox you link to.

I will leave it to someone more senior than me to comment on whether they think adding this is appropriate, but if so, personally I likely cannot allocate time to implement this.