
clear;clc

cd /home/subhadip/Autism_AnatNet/austistic_study/Diffusion_Analysis/90_regions/adj_matrixes/Connectivity_Probability_weighted/symmetric

files=dir('Connection*.txt');

kden(1:10,1:length(files))=zeros;
clustering_coefficient(1:10,1:length(files))=zeros;
characteristic_path_length(1:10,1:length(files))=zeros;
Eglob(1:10,1:length(files))=zeros;
% Eloc(1:10,1:length(files))=zeros;
% BC(1:10,1:length(files))=zeros;
% r(1:10,1:length(files))=zeros;

for l=1:length(files)
    
    connection_matrix(1:90,1:90)=zeros;
    files(l).name
    temp1=load(files(l).name);
    connection_matrix(1:90,1:90)=temp1;
    W_fix=weight_conversion(connection_matrix,'autofix');
%   connection_matrix=weight_conversion(W_fix, 'normalize');
    connection_matrix=W_fix;
    clear temp1; clear W_fix;

   chk=1;
for threshold = 0.01:0.01:1 %0.0279:0.0029:0.054
    
    temp2=connection_matrix;
    temp2(temp2<threshold)=0;
    thresholded_connection_matrix=temp2;
    
    clear temp2;
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %density
    
     kden(chk,l) = density_und(thresholded_connection_matrix);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % clustering coefficient
   
   clustering_coefficient(chk,l)=mean(clustering_coef_wu(thresholded_connection_matrix));
%  clustering_coefficient_nodal(chk,l)=clustering_coef_wu(thresholded_connection_matrix);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % characteristic path length 

   L=1./thresholded_connection_matrix;
   L(L==Inf)=0;
   D=mean(distance_wei(L));
   characteristic_path_length(chk,l)=charpath(D);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % global efficiency and local efficiency
   
   Eglob(chk,l) = efficiency_wei(thresholded_connection_matrix);
%  Eloc(chk,l) = mean(efficiency_wei(thresholded_connection_matrix,1));
%  Eloc_nodal(chk,l) = efficiency_wei(thresholded_connection_matrix,1);
   chk=chk+1;

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%    % betweenness centrality
% BC(chk,l)=betweenness_wei(L);
% 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Assortativity
% r(chk,l)=assortativity_wei(thresholded_connection_matrix,0);

end 
clear chk; clear connection_matrix;
end

save('/home/subhadip/Autism_AnatNet/austistic_study/Diffusion_Analysis/90_regions/adj_matrixes/Connectivity_Probability_weighted/symmetric/kden_network.txt','kden','-ascii')
save('/home/subhadip/Autism_AnatNet/austistic_study/Diffusion_Analysis/90_regions/adj_matrixes/Connectivity_Probability_weighted/symmetric/ClusCoeff_network.txt','clustering_coefficient','-ascii')
save('/home/subhadip/Autism_AnatNet/austistic_study/Diffusion_Analysis/90_regions/adj_matrixes/Connectivity_Probability_weighted/symmetric/CharPathLength_network.txt','characteristic_path_length','-ascii')
save('/home/subhadip/Autism_AnatNet/austistic_study/Diffusion_Analysis/90_regions/adj_matrixes/Connectivity_Probability_weighted/symmetric/Eglob_network.txt','Eglob','-ascii')

