Granger Causality analysis and Database on an esternal driver

Hello,

What type of analysis does brainstorm uses to obtain Granger causality? My supervisor said that there are different ways to obtain it.

Also, Since I expect the database for my EEG study to be very big, I am considering putting the database on an external drive. Would you advice this, or not?

Regards,

FABIO

The easier is to check directly the comments in the bst_granger function:
https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/connectivity/bst_granger.m

External drives are always slower, and it the difference can become important in processes that imply a lot of reading and writing on the hard drive. But if you cannot store it on an internal drive, then you don’t have the choice.
Search the forum for help with moving your database to a different drive.

I try to use bst_granger.m to analysis Granger causuality. But matlab shows the following error:

Undefined function or variable ‘bst_vgarch’

May I ask how to solve this problem? Thanks.

It looks like you are calling the function bst_granger with no second input (Y=[]). We currently do not support this usage of the function in Brainstorm, therefore the function bst_vgarch is not part of the Brainstorm distribution.

I attached here a version of this function that authors sent me a few years ago, but I have no idea whether this works correctly:
bst_vgarch.m (82.5 KB)

@hossein27en @leahy Do you have any suggestion about this usage of the bst_granger function?

1 Like

Thank you so much for your reply.

My code is as follows:

clc;clear;
X_All=readtable(‘data.csv’);
X=X_All{:,2:179}(1:20,:);
Y=X;
inputs.nTrials = 1; % use trial-averaged covariances in AR estimation
inputs.standardize = true; % zero mean and unit variance
inputs.flagFPE = true; % allow different orders for each pair of signals
inputs.lag = 3; % estimate causality in variance using lag-3 ARCH model
inputs.flagELM = true; % find the optimal lag rather than always given lag
inputs.rho = 50; % parameter to tune estimation of ARCH model
[inMean, inVariance] = bst_granger(X, Y, 5, inputs); % every pair in X

However, when I run the code, it shows the following error:

Transpose on ND array is not defined. Use PERMUTE instead.

Error in bst_correlation (line 122)
** connectivity(:, :, nSteps+1) = X*X’ / (size(X,2) - 1);**

Error in bst_vgarch (line 206)
** W = bst_correlation(epsilon, [], struct(‘normalize’, false, ‘nTrials’, 1, ‘maxDelay’, 0, ‘nDelay’, 1,**
** ‘flagStatistics’, false));**

Error in bst_granger (line 263)
** bst_vgarch(‘vec’, residual, inputs.nTrials, inputs.lag, 0, inputs.flagELM, 3, ‘on’, 999, [], inputs.rho,**
** false, [], [], [], []); %#ok**

Error in Yjl_test (line 11)
[inMean, inVariance] = bst_granger(X, Y, 5, inputs); % every pair in X

I’m sorry I cannot help you with this. The authors of these functions are not working with us anymore and we haven’t tested any other usage beyond the ones available through the Brainstorm interface.

@hossein27en @rmleahy @Sylvain Any other suggestion?

1 Like

Thanks for your answer.

Could you please tell me more details to analysis Grange Causality through brainstorm interface? Is there any user guide?

Hello,
I'm conducting Granger Causality analysis for each subject in both the time domain and frequency domain. I just wonder whether the time series of all the trials or the averaged ERF/ERP data should be the input. Do you have any suggestion?
Thanks!

Single trials/continuous recordings are preferred as the Granger method requires adjustment of parametric models of the time series, which can be a greedy process.