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

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 2022년 9월 21일
편집: Jose 2022년 9월 21일
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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

질문:

2022년 9월 19일

댓글:

2022년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by