Export the mat file from phase lock value connectivity

Hi, all. I' calculated the phase lock value connectivity using the source-level data matrix which is 9004*7501 (verticals* time points). I get the connectivity values and export the mat file, it is 40540510, I thought it should be 9004* 9004 matrix so that I could use the N*N matrix to calculate the network characteristics. why it display that? How could I do to reshape the N*N structure? Thank you.

Since PLV is a symmetric connectivity metric, only the lower triangle (which includes the diagonal) is saved. See:

To recover the NxN matrix, use:

R = bst_memory('GetConnectMatrix', TfMat);

See more details in this section of the connectivity tutorial page:
https://neuroimage.usc.edu/brainstorm/Tutorials/Connectivity#On_the_hard_drive

Thanks a lot, I 'll tri it now, and it sees works.

Hi, I have a related question.

I have a 22x22 PLV matrix (22 ROIs x 22 ROIs) and 253 connectivity values. Is there a way to export the data into excel with the corresponding ROI pair listed as the column names? Or would it be easier to manually list the ROIs I used and work out the pairs corresponding to the 'lower triangle + diagonal'? Thank you.

In the GUI, there is not way to directly export the data in your required format.

But, you can make use of script to prepare the data, and use a Matlab function such as writematrix() to save in format compatible with Excel, e.g., .csv

Export your connectivity file to Matlab as variable, e.g, with the name TfMat, then you can use this script to get all the pairs for the lower triangle (including the diagonal):

% Get all pair names and their connectivity value
allPairsNames = figure_timefreq('GetRowNames', TfMat.RefRowNames, TfMat.RowNames);        
allPairsValues = process_compress_sym('Expand', TfMat.TF, length(TfMat.RowNames));

% Indices for lower triangle and diagonal
ixs = find(tril(ones(length(TfMat.RowNames))));

% Extract selected names and connectivity values
selPairsNames  = allPairsNames(ixs);
selPairsValues = allPairsValues(ixs, :, :);