-
Notifications
You must be signed in to change notification settings - Fork 0
/
intraNetworkConnectivityEstimate.m
66 lines (45 loc) · 2.52 KB
/
intraNetworkConnectivityEstimate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function [intraNetworkConnectivity,grandLayerWiseAverageIntraNetworkConnectivity]= intraNetworkConnectivityEstimate(layerNum, pwd)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Script intraNetworkConnectivityEstimate.m
%
% Estimates the within network connectivity for each of the subnetworks/communities
% for single network layer for each of the subjects.
%
% Dependencies:
% -No dependency
%
%
% Isil Bilgin 01/11/2018
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for subjectNum=1:size(subjectPool,2)
mainSubjectFolder = fullfile(pwd, sprinf('Subject%s',subjectPool{subjectNum}));
load(fullfile(mainSubjectFolder,'multilayeredMatrix.mat'));
for layer=1:layerNum
for subNetIndx=1:max(unique(nodeAssingment))
subNetwork = find(nodeAssingment==subNetIndx);
index =0; % index of each pair of connectivity between networks
intraNetworkConnectivity{subjectNum,layer}(subNetIndx) = 0;
for node1=1:size(subNetwork,2)-1
for node2 =node1+1:size(subNetwork,2)
if multiMatrix{1,layer}(subNetwork(node1),subNetwork(node2))~=0 % only add the existing connections to the sum hence the mean
index=index+1;
intraNetworkConnectivity{subjectNum,layer}(subNetIndx) = intraNetworkConnectivity{subjectNum,layer}(subNetIndx) + multiMatrix{1,layer}(subNetwork(node1),subNetwork(node2));
end
end
end
intraNetworkConnectivity{subjectNum,layer}(subNetIndx) = intraNetworkConnectivity{subjectNum,layer}(subNetIndx)/index;
end
end
end
%% Average Intra-network strenght estimate across the subjects
for layer=1:layerNum
averageIntraNetworkConnectivity{layer} = zeros(1,max(unique(nodeAssingment)));
for subjectNum=1:size(subjectPool,1)
averageIntraNetworkConnectivity{layer} = averageIntraNetworkConnectivity{layer} +intraNetworkConnectivity{subjectNum,layer};
end
averageIntraNetworkConnectivity{layer} = averageIntraNetworkConnectivity{layer}/size(subjectPool,2);
end
for layer=1:layerNum
grandLayerWiseAverageIntraNetworkConnectivity(layer) = mean(averageIntraNetworkConnectivity{layer});
end
save(fullfile(pwd, 'intraNetworkConnectivityEstimates.mat'),'intraNetworkConnectivity','averageIntraNetworkConnectivity','grandLayerWiseAverageIntraNetworkConnectivity')