-
Notifications
You must be signed in to change notification settings - Fork 3
/
resilience_GMbased.m
306 lines (287 loc) · 10 KB
/
resilience_GMbased.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
%% Resilience Test Simulations
%Create list of nodes and their number
list=(1:358)';
load('HCP_atlasnames.mat');
nodenames=roinames;
%% Targeted Attack based on Betweenness Centrality HC
for h=1:size(HCPdata,2)
for i=1:size(smwrld_range,2)
SCN1_tb=ThreshNet_1(:,:,i,h);
BC1=[list, BC_one(:,i,h)];
BC1=sortrows(BC1, 2, 'descend');
for x=1:358
%set all rows and columns belonging to the node in xth position to zero
SCN1_tb(:,BC1(x,1))=0;
SCN1_tb(BC1(x,1),:)=0;
%Efficiency
Eglob1_BC(x,i,h) = efficiency_bin(SCN1_tb);
% find size of largest collection of nodes.
a = get_components(SCN1_tb); %get_components is a ECT function
c = arrayfun(@(x)length(find(a == x)), unique(a), 'Uniform', false); %gets the number of instances of each unique entry
cc = cell2mat(c); %have to convert to matrix
size_GCC1_BC(x,i,h) = max(cc); %max(cc) will be the number of nodes in largest component.
clear a c cc
end
clear BC1 SCN1_tb
end
end
%% Targeted Attack based on Betweenness Centrality FEAP
for h=1:size(HCPdata,2)
for i=1:size(smwrld_range,2)
SCN2_tb=ThreshNet_2(:,:,i,h);
BC2=[list, BC_two(:,i,h)];
BC2=sortrows(BC2, 2, 'descend');
for x=1:358
%set all rows and columns belonging to the node in xth position to zero
SCN2_tb(:,BC2(x,1))=0;
SCN2_tb(BC2(x,1),:)=0;
%Efficiency
Eglob2_BC(x,i,h) = efficiency_bin(SCN2_tb);
% find size of largest collection of nodes.
a = get_components(SCN2_tb); %get_components is a BCT function
c = arrayfun(@(x)length(find(a == x)), unique(a), 'Uniform', false); %gets the number of instances of each unique entry
cc = cell2mat(c); %have to convert to matrix
size_GCC2_BC(x,i,h) = max(cc); %max(cc) will be the number of nodes in largest component.
clear a c cc
end
clear BC2 SCN2_tb
end
end
%% Plot GCC and Eff -Surface Area
% Figure 5 in manuscript
percent=list/358;
percent=percent*100;
figure(1)
subplot(2,2,1)
scatter(percent, size_GCC1_BC(:,1,h), 'r')
hold on
scatter(percent, size_GCC1_BC(:,2,h), 'b')
hold on
scatter(percent, size_GCC1_BC(:,3,h), 'g')
hold on
scatter(percent, size_GCC1_BC(:,4,h), 'k')
hold on
scatter(percent, size_GCC1_BC(:,5,h), 'c')
hold on
scatter(percent, size_GCC1_BC(:,6,h), 'r')
hold on
scatter(percent, size_GCC1_BC(:,7,h), 'b')
hold on
scatter(percent, size_GCC1_BC(:,8,h), 'g')
hold on
scatter(percent, size_GCC1_BC(:,9,h), 'k')
hold on
title('HC Attack Based on BC- Cortical Thickness', 'FontSize', 18)
ylabel('Giant Connected Component', 'FontSize', 12)
xlabel('Percentage of Nodes Removed', 'FontSize', 14)
legend('0.075','0.1','0.125','0.15','0.175','0.2', '0.225', '0.25', '0.275', 'Location', 'northeast', 'FontSize', 12)
subplot(2,2,2)
scatter(percent, Eglob1_BC(:,1,h), 'r')
hold on
scatter(percent, Eglob1_BC(:,2,h), 'b')
hold on
scatter(percent, Eglob1_BC(:,3,h), 'g')
hold on
scatter(percent, Eglob1_BC(:,4,h), 'k')
hold on
scatter(percent, Eglob1_BC(:,5,h), 'c')
hold on
scatter(percent, Eglob1_BC(:,6,h), 'r')
hold on
scatter(percent, Eglob1_BC(:,7,h), 'b')
hold on
scatter(percent, Eglob1_BC(:,8,h), 'g')
hold on
scatter(percent, Eglob1_BC(:,9,h), 'k')
hold on
title('HC Attack Based on BC- Cortical Thickness', 'FontSize', 18)
ylabel('Global Efficiency', 'FontSize', 12)
xlabel('Percentage of Nodes Removed', 'FontSize', 14)
legend('0.075','0.1','0.125','0.15','0.175','0.2', '0.225', '0.25', '0.275', 'Location', 'northeast', 'FontSize', 12)
subplot(2,2,3)
scatter(percent, size_GCC2_BC(:,1,h), 'r')
hold on
scatter(percent, size_GCC2_BC(:,2,h), 'b')
hold on
scatter(percent, size_GCC2_BC(:,3,h), 'g')
hold on
scatter(percent, size_GCC2_BC(:,4,h), 'k')
hold on
scatter(percent, size_GCC2_BC(:,5,h), 'c')
hold on
scatter(percent, size_GCC2_BC(:,6,h), 'r')
hold on
scatter(percent, size_GCC2_BC(:,7,h), 'b')
hold on
scatter(percent, size_GCC2_BC(:,8,h), 'g')
hold on
scatter(percent, size_GCC2_BC(:,9,h), 'k')
hold on
title('FEAP Attack Based on BC- Cortical Thickness', 'FontSize', 18)
ylabel('Giant Connected Component', 'FontSize', 12)
xlabel('Percentage of Nodes Removed', 'FontSize', 14)
legend('0.075','0.1','0.125','0.15','0.175','0.2', '0.225', '0.25', '0.275', 'Location', 'northeast', 'FontSize', 12)
subplot(2,2,4)
scatter(percent, Eglob2_BC(:,1,h), 'r')
hold on
scatter(percent, Eglob2_BC(:,2,h), 'b')
hold on
scatter(percent, Eglob2_BC(:,3,h), 'g')
hold on
scatter(percent, Eglob2_BC(:,4,h), 'k')
hold on
scatter(percent, Eglob2_BC(:,5,h), 'c')
hold on
scatter(percent, Eglob2_BC(:,6,h), 'r')
hold on
scatter(percent, Eglob2_BC(:,7,h), 'b')
hold on
scatter(percent, Eglob2_BC(:,8,h), 'g')
hold on
scatter(percent, Eglob2_BC(:,9,h), 'k')
hold on
title('FEAP Attack Based on BC- Cortical Thickness', 'FontSize', 18)
ylabel('Global Efficiency', 'FontSize', 12)
xlabel('Percentage of Nodes Removed', 'FontSize', 14)
legend('0.075','0.1','0.125','0.15','0.175','0.2', '0.225', '0.25', '0.275', 'Location', 'northeast', 'FontSize', 12)
%% Targeted Attack based on Eigenvector Centrality HC
for h=1:size(HCPdata,2)
for i=1:size(smwrld_range,2)
SCN1_te=ThreshNet_1(:,:,i,h);
EC1=[list, EC_one(:,i,h)];
EC1=sortrows(EC1, 2, 'descend');
for x=1:358
%set all rows and columns belonging to the node in xth position to zero
SCN1_te(:,EC1(x,1))=0;
SCN1_te(EC1(x,1),:)=0;
%Efficiency
Eglob1_EC(x,i,h) = efficiency_bin(SCN1_te);
% find size of largest collection of nodes.
a = get_components(SCN1_te); %get_components is a ECT function
c = arrayfun(@(x)length(find(a == x)), unique(a), 'Uniform', false); %gets the number of instances of each unique entry
cc = cell2mat(c); %have to convert to matrix
size_GCC1_EC(x,i,h) = max(cc); %max(cc) will be the number of nodes in largest component.
clear a c cc
end
clear EC1 SCN1_te
end
end
%% Targeted Attack based on Eigenvector Centrality FEAP
for h=1:size(HCPdata,2)
for i=1:size(smwrld_range,2)
SCN2_te=ThreshNet_2(:,:,i,h);
EC2=[list, EC_two(:,i,h)];
EC2=sortrows(EC2, 2, 'descend');
for x=1:358
%set all rows and columns belonging to the node in xth position to zero
SCN2_te(:,EC2(x,1))=0;
SCN2_te(EC2(x,1),:)=0;
%Efficiency
Eglob2_EC(x,i,h) = efficiency_bin(SCN2_te);
% find size of largest collection of nodes.
a = get_components(SCN2_te); %get_components is a ECT function
c = arrayfun(@(x)length(find(a == x)), unique(a), 'Uniform', false); %gets the number of instances of each unique entry
cc = cell2mat(c); %have to convert to matrix
size_GCC2_EC(x,i,h) = max(cc); %max(cc) will be the number of nodes in largest component.
clear a c cc
end
clear EC2 SCN2_te
end
end
%% Plot GCC and Eff
% Supplemental Figures
percent=list/358;
percent=percent*100;
figure(1)
subplot(2,2,1)
scatter(percent, size_GCC1_EC(:,1,h), 'r')
hold on
scatter(percent, size_GCC1_EC(:,2,h), 'b')
hold on
scatter(percent, size_GCC1_EC(:,3,h), 'g')
hold on
scatter(percent, size_GCC1_EC(:,4,h), 'k')
hold on
scatter(percent, size_GCC1_EC(:,5,h), 'c')
hold on
scatter(percent, size_GCC1_EC(:,6,h), 'r')
hold on
scatter(percent, size_GCC1_EC(:,7,h), 'b')
hold on
scatter(percent, size_GCC1_EC(:,8,h), 'g')
hold on
scatter(percent, size_GCC1_EC(:,9,h), 'k')
hold on
title('HC Attack Based on EC- Cortical Thickness', 'FontSize', 18)
ylabel('Giant Connected Component', 'FontSize', 12)
xlabel('Percentage of Nodes Removed', 'FontSize', 14)
legend('0.075','0.1','0.125','0.15','0.175','0.2', '0.225', '0.25', '0.275', 'Location', 'northeast', 'FontSize', 12)
subplot(2,2,2)
scatter(percent, Eglob1_EC(:,1,h), 'r')
hold on
scatter(percent, Eglob1_EC(:,2,h), 'b')
hold on
scatter(percent, Eglob1_EC(:,3,h), 'g')
hold on
scatter(percent, Eglob1_EC(:,4,h), 'k')
hold on
scatter(percent, Eglob1_EC(:,5,h), 'c')
hold on
scatter(percent, Eglob1_EC(:,6,h), 'r')
hold on
scatter(percent, Eglob1_EC(:,7,h), 'b')
hold on
scatter(percent, Eglob1_EC(:,8,h), 'g')
hold on
scatter(percent, Eglob1_EC(:,9,h), 'k')
hold on
title('HC Attack Based on EC- Cortical Thickness', 'FontSize', 18)
ylabel('Global Efficiency', 'FontSize', 12)
xlabel('Percentage of Nodes Removed', 'FontSize', 14)
legend('0.075','0.1','0.125','0.15','0.175','0.2', '0.225', '0.25', '0.275', 'Location', 'northeast', 'FontSize', 12)
subplot(2,2,3)
scatter(percent, size_GCC2_EC(:,1,h), 'r')
hold on
scatter(percent, size_GCC2_EC(:,2,h), 'b')
hold on
scatter(percent, size_GCC2_EC(:,3,h), 'g')
hold on
scatter(percent, size_GCC2_EC(:,4,h), 'k')
hold on
scatter(percent, size_GCC2_EC(:,5,h), 'c')
hold on
scatter(percent, size_GCC2_EC(:,6,h), 'r')
hold on
scatter(percent, size_GCC2_EC(:,7,h), 'b')
hold on
scatter(percent, size_GCC2_EC(:,8,h), 'g')
hold on
scatter(percent, size_GCC2_EC(:,9,h), 'k')
hold on
title('FEAP Attack Based on EC- Cortical Thickness', 'FontSize', 18)
ylabel('Giant Connected Component', 'FontSize', 12)
xlabel('Percentage of Nodes Removed', 'FontSize', 14)
legend('0.075','0.1','0.125','0.15','0.175','0.2', '0.225', '0.25', '0.275', 'Location', 'northeast', 'FontSize', 12)
subplot(2,2,4)
scatter(percent, Eglob2_EC(:,1,h), 'r')
hold on
scatter(percent, Eglob2_EC(:,2,h), 'b')
hold on
scatter(percent, Eglob2_EC(:,3,h), 'g')
hold on
scatter(percent, Eglob2_EC(:,4,h), 'k')
hold on
scatter(percent, Eglob2_EC(:,5,h), 'c')
hold on
scatter(percent, Eglob2_EC(:,6,h), 'r')
hold on
scatter(percent, Eglob2_EC(:,7,h), 'b')
hold on
scatter(percent, Eglob2_EC(:,8,h), 'g')
hold on
scatter(percent, Eglob2_EC(:,9,h), 'k')
hold on
title('FEAP Attack Based on EC- Cortical Thickness', 'FontSize', 18)
ylabel('Global Efficiency', 'FontSize', 12)
xlabel('Percentage of Nodes Removed', 'FontSize', 14)
legend('0.075','0.1','0.125','0.15','0.175','0.2', '0.225', '0.25', '0.275', 'Location', 'northeast', 'FontSize', 12)