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 个评论
Walter Roberson
2022-9-19
NaN cannot be a connection, so you would replace the NaN with 0.
Jose Teles
2022-9-19
Walter Roberson
2022-9-19
CM(isnan(CM)) = 0;
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
Walter Roberson
2022-9-21
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.
Jose
2022-9-21
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?
Walter Roberson
2022-9-21
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.
Jose
2022-9-22
Hello Walter,
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
Walter Roberson
2022-9-23
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.
Jose
2022-10-4
Thank you Walter for your help this worked
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!