Implement Granger causality connectivity measures like DTF, (g)PDC in the
See original ticket here:
For (g)PDC, in order to get close to the reference implementation, it would be necessary to implement multi-variate autoregressive modeling (MVAR) methods into mne, as one of the
mode options in the
There are three existing python packages (AFAIK) that implement these causal connectivity measures:
- Source Connectivity Toolbox (SCoT): https://github.com/scot-dev/scot
- Connectivipy: https://github.com/dokato/connectivipy
- spectral_connectivity: https://github.com/Eden-Kramer-Lab/spectral_connectivity
SCoT is probably the best contender for integration, given that it’s both close to the original implementation (MVAR-based) and is consistent with
mne-python's data shape. However, both connectivipy and spectral_connectivity have desirable features that should be considered as well, if the authors of these packages are open to the idea. Per their project page, spectral_connectivity relies on the multitaper Fourier transform, separating the time-frequency transformation from the actual connectivity measures. This is different than the reference PDC implementation, but it could be very useful in certain situations to use a non-parametric connectivity measure.
Another consideration would be projecting fitted MVAR model coefficients into source space, prior to computing the causality measure. There are some advantages to doing this, largely related to computational load. I’m no expert in this field, but expect that there would be some debate as to whether this step is necessary. Given
mne-python's existing features, it seems like a good fit, however.
Lastly, there’s the question of what to do with the causality measures - e.g. visualization, statistical analysis - once computed, and whether such applications should also be integrated into mne. From my limited use,
mne.viz connectivity plots are currently tailored for non-causal measures, i.e. where the direction of the connectivity is not a factor. The python packages listed above all have their own visualization submodules, but do not implement any 3D visualization techniques. All-to-all connectivity measures, even in just 1 direction (i.e. the lower triangle of the connectivity matrix), are rather unwieldy. Below is a possible scenario where a causal connectivity measure is computed, and the results visualized:
Example use case
- M/EEG recordings are made (task or resting state) and a ROI picked.
- An MVAR model is fitted to the sensor data or its PCA projection, and then projected into source space.
- All-to-all PDC is computed for each estimated source.
- To visualize, the user specifies a source dipole, direction (inflow/outflow), number of traces, and the type of surface to display (pial, white, etc.)
- The resulting 3D visualization (volume) visualizes the desired connectivity measure between the ROI/source dipole and other dipoles in source space as color-coded tubes (similar to this example, but in source space).
mne-python is the de-facto M/EEG analysis package in python, it makes more sense to me to try and implement this functionality according to your standards than to just get a working implementation and be done with it. Again, not an expert (from a ML background), but intend to learn, and would appreciate any help/advice that y’all can offer.