MRI_graph.m 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. function [degree, strength, modularity, CPL, CC, SW] = MRI_graph(mNet, AUC)
  2. mNetTresh = zeros(98,98,AUC(end));
  3. CPLx = nan(1,AUC(end));
  4. CCx = nan(1,AUC(end));
  5. NCC = nan(1,AUC(end));
  6. NCPL = nan(1,AUC(end));
  7. SWx = nan(1,AUC(end));
  8. modul = nan(1,AUC(end));
  9. mean_degree = nan(1,AUC(end));
  10. Stx = nan(1,AUC(end));
  11. f = waitbar(0,strcat('0/100'));
  12. for gi=AUC
  13. p=gi/100;
  14. waitbar(1i/100,f,num2str(gi),'/100');
  15. mNetD = threshold_proportional(mNet,p);
  16. mNetTresh(:,:,gi) = mNetD;
  17. % mNetD(mNetD==0) = nan;
  18. mNetDWght = weight_conversion(mNetD,'normalize');
  19. mNetDBin = weight_conversion(mNetD,'binarize');
  20. % Eglob (gi) = efficiency_wei(mNetD); % global efficieny
  21. Stx(gi) = squeeze(mean(strengths_und(mNetD)));
  22. D = distance_wei_floyd(mNetDWght,'inv');
  23. Dx = distance_wei_floyd(mNetDBin,'inv');
  24. [~,Q] = community_louvain(mNetD,1,[],'negative_sym');
  25. modul(gi) = Q;
  26. dgr = degrees_dir(mNetD);
  27. mean_degree(gi) = squeeze(mean(dgr));
  28. lambda = charpath(D,0,0);
  29. CPLx(gi) = lambda;
  30. cplb = charpath(Dx,0,0);
  31. clx = clustering_coef_wu(mNetDWght);
  32. CCx(gi) = squeeze(mean(clx));
  33. clb = clustering_coef_wu(mNetDBin);
  34. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  35. % small worldness density threshold
  36. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  37. % create random network to asses small worldness
  38. lambda_rdm = zeros(1,100);
  39. clcf_rdm = zeros(1,100);
  40. for k=1:100
  41. random = makerandCIJ_und(size(mNetD,1),nnz(mNetD)/2); % compute random network with same number of nodes and edges
  42. D_rdm = distance_bin(random);
  43. lambda_rdm(k) = charpath(D_rdm,0,0);
  44. clcf_rdm(k) = mean(clustering_coef_bu(random));
  45. end
  46. % small-worldness
  47. norm_clcf = abs(squeeze(mean(clb)))/abs(mean(clcf_rdm));
  48. NCC(gi) = norm_clcf;
  49. norm_lambda = (cplb/(mean(lambda_rdm)));
  50. NCPL(gi) = norm_lambda;
  51. SWx(gi) = norm_clcf/norm_lambda;
  52. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  53. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  54. end
  55. F = findall(0,'type','figure','tag','TMWWaitbar');
  56. delete(F)
  57. CC = squeeze(mean(CCx,'omitnan'));
  58. CPL = squeeze(mean(CPLx,'omitnan'));
  59. SW = squeeze(mean(SWx,'omitnan'));
  60. modularity = squeeze(mean(modul,'omitnan'));
  61. degree = squeeze(mean(mean_degree,'omitnan'));
  62. strength = squeeze(mean(Stx,'omitnan'));
  63. end