Granger Causality Matrix Error


Hello Brainstorm team,

I think I’ve run into a bug in the Bivariate Granger Causality (NxN) routine and I hope you can help me with it. I’m pulling scout time series from a 2-second data segment, but I notice that sometimes one or more scouts return a series of all zeros. As soon as the GC code reaches that channel(s), it stops and fills the entire causality matrix with zeros. I have other examples in my analysis where this happens; the figure attached is just one case.

In my view, the calculation should skip or handle the zero series and keep going. Only the rows and columns for frontalpole R, for example, should be zero.

Can this be adjusted so the algorithm continues past a zero time series? I’m attaching both the scout time series and the resulting GC matrix for reference (https://drive.google.com/file/d/1WWW2I53F-zyuNwqghTcfa8-LChsL9xXM/view?usp=drive_link).

Thanks for looking into this.

Hello Brainstorm team,

Just following up on this issue I raised regarding the Bivariate Granger Causality (NxN) routine and how it handles zero time series. I understand you may be busy, but I’d appreciate any thoughts or updates when you have a chance.

Let me know if I can provide anything else to help.

Thanks again,
Margherita

Hello Margherita,

Thanks for the shared data, it was useful to identify the bug that you reported.

This was not really related to the GC itself, but to the fact that signals are standardized (mean 0, std 1) before computing GC, so, flat channels were giving troubles.

Another issue that raised in the data, is that sometimes the ratio restricted_variance / unrestricted_variance was smaller than 1, which suggest that the model that considered x and y performed worse than the model that considers only x. In theory this should not be the case, it seems it is related to numerical issues, as in the cases this happens the ratio (restricted_variance / unrestricted_variance) - 1 is in the order of 10^-15.

The fixes for this are located in these links, these lines of coded are not in the main Brainstorm code, as we need to do some more testing.

Apologies for the delay in the reply

Best,
Raymundo

1 Like

Hello Margherita,

We have updated the Granger causality code in Brainstorm.

  1. The issue with flat signals is now addressed. Commits 3993cb9
  2. Moreover, now you can choose to use the MVGC Toolbox for the computation of GC. In fact, this is now the recommended method. Commit b207388

Please update your Brainstorm version to see this as an option in the process to compute Granger causality.

2 Likes

Dear Raymuldo,

Thank you so much for the huge effort and commitment in solving this issue. I’ll start working on this fix right away. Really appreciate the great work!

Best,
Margherita