Error extracting graph theory measures - brain connectivity toolbox

Dear experts,
I have a 90x90 connectivity matrix and am trying to extract graph theory measures using the brain connectivity toolbox, in particular the characteristic path length.I used the following code
load('01_DWI_FP_MD_C_trafo_Tracts_CSD_FA_PASS' )
>> charpath(CM)
But then I get the following error message "Error using charpath. The distance matrix must not contain NaN values"
I checked and indeed there are several NaN values in the matrix - can anyone provide suggestion on how to sort this error? Should the NaN be replaced by real values and if so how to do this? 0 or 1 values? I also attach the connectivity matrix
Sorry but I am very new to programming and any suggesting would be welcomed.
Thanks in advance,
Jose

10 Commenti

NaN cannot be a connection, so you would replace the NaN with 0.
Thank you for the reply.
Is there any script/code I could use to perfom this change from NaN to zero?
Jose
Jose il 21 Set 2022
Modificato: Jose il 21 Set 2022
Dear Walter,
Thank you very much again for your reply. The script you suggested did changed the NaNs to zero however when I call again the function charpath(CM) I got a new error message:
"Undefined function 'nanmax' for input arguments of type 'double'.
Error in charpath (line 72)
ecc = nanmax(D,[],2);"
I really don´t know why this error appears perhaps you could provide some suggestion?
Thank you
nanmax() is part of the Statistics toolbox; https://www.mathworks.com/help/stats/nanmax.html
You can instead use
ecc = max(D, [], 2);
Or for greater readability of intent,
ecc = max(D, [], 2, 'omitnan');
omitnan is the default.
Thank you for suggestion, I called the function upon but still there is the error "Unrecognized function or variable 'D'"
"ecc = max(D, [], 2, 'omitnan');
Unrecognized function or variable 'D'"
Can you help?
Is charpath() your function or one from the Brain Function Toolbox? If it is your function we would need to see the code; if it is from the toolbox we will need a link to the toolbox.
Hello Walter,
The toolbox I am using is the brain connectivity toolbox (https://sites.google.com/site/bctnet/)
The function I want to run from the toolbox is the characteristic path length – charpath (https://sites.google.com/site/bctnet/list-of-measures)
I also attach the matlab function of the measure perhaps this helps?
I am stuck not sure why I am getting these errors.
Thank you
It is not possible to reach that line of code without having executed
n = size(D,1);
which would have complained if D was not passed in to the function.
Please go back and re-run the charpath(CM) call ... after, that is, having changed the line
ecc = nanmax(D,[],2);
at line 72, to be
ecc = max(D,[],2,'omitnan');
and saving the charpath.m file.
Thank you Walter for your help this worked

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Data Import and Analysis in Centro assistenza e File Exchange

Richiesto:

il 19 Set 2022

Commentato:

il 4 Ott 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by