-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fig_3.m
executable file
·333 lines (251 loc) · 11.5 KB
/
Fig_3.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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
function Fig_3
% This script creates boxplots of the correlations within words, numbers,
% between words and numbers, and between words and other domains, and
% numbers and other domains. This is done for left and right lateral
% VTC, as well as left and right medial VTC.
partitions = {'lateral', 'medial'};
ResultsDir = './figures';
% We create plots for both lateral and medial VTC.
for p = 1:length(partitions)
partition = partitions{p};
if strcmp(partition, 'lateral')
DataDir='./data/lateral_VTC';
elseif strcmp(partition, 'medial')
DataDir='./data/medial_VTC';
end
%% get young childrens data first
filename_lh = sprintf('csym_all_lh_vtc_%s_youngc_inplane_3_Runs_z.mat', partition);
filename_lh_path = fullfile(DataDir, filename_lh);
filename_rh = sprintf('csym_all_rh_vtc_%s_youngc_inplane_3_Runs_z.mat', partition);
filename_rh_path = fullfile(DataDir, filename_rh);
load(filename_lh_path)
youngc_lh = lh_combinedcsymmatrix;
load(filename_rh_path)
youngc_rh = rh_combinedcsymmatrix;
clear rh_combinedcsymmatrix lh_combinedcsymmatrix
%% get older childrens data
filename_lh_oc = sprintf('csym_all_lh_vtc_%s_olderc_inplane_3_Runs_z.mat', partition);
filename_lh_oc_path = fullfile(DataDir, filename_lh_oc);
filename_rh_oc = sprintf('csym_all_rh_vtc_%s_olderc_inplane_3_Runs_z.mat', partition);
filename_rh_oc_path = fullfile(DataDir, filename_rh_oc);
load(filename_lh_oc_path)
olderc_lh = lh_combinedcsymmatrix;
load(filename_rh_oc_path)
olderc_rh = rh_combinedcsymmatrix;
clear rh_combinedcsymmatrix lh_combinedcsymmatrix
%% get adult data as well
filename_lh_ad = sprintf('csym_all_lh_vtc_%s_adults_inplane_3_Runs_z.mat', partition);
filename_lh_ad_path = fullfile(DataDir, filename_lh_ad);
filename_rh_ad = sprintf('csym_all_rh_vtc_%s_adults_inplane_3_Runs_z.mat', partition);
filename_rh_ad_path = fullfile(DataDir, filename_rh_ad);
load(filename_lh_ad_path)
adults_lh = lh_combinedcsymmatrix;
load(filename_rh_ad_path)
adults_rh = rh_combinedcsymmatrix;
clear rh_combinedcsymmatrix lh_combinedcsymmatrix
%% prepare for plotting
% The loaded combinedcsymmatrix has
% 10 rows x 10 columns (representing the categories) and session as a third
% dimension.Categories are in the following order (W = words, N = Numbers):
% 1 2 3 4 5 6 7 8 9 10
% A K B L C G P H W N
group = cat(1, repmat([1], length(youngc_lh),1), repmat([2], length(olderc_lh),1), repmat([3], length(adults_lh),1));
% words
ww_yc_lh = reshape(youngc_lh(9,9,:),[length(youngc_lh(9,9,:)),1]);
ww_oc_lh = reshape(olderc_lh(9,9,:),[length(olderc_lh(9,9,:)),1]);
ww_ad_lh = reshape(adults_lh(9,9,:),[length(adults_lh(9,9,:)),1]);
% combine data for all groups
w_w = [ww_yc_lh; ww_oc_lh; ww_ad_lh];
% numbers
nn_yc_lh = reshape(youngc_lh(10,10,:),[length(youngc_lh(10,10,:)),1]);
nn_oc_lh = reshape(olderc_lh(10,10,:),[length(olderc_lh(10,10,:)),1]);
nn_ad_lh = reshape(adults_lh(10,10,:),[length(adults_lh(10,10,:)),1]);
% combine data for groups
n_n = [nn_yc_lh; nn_oc_lh; nn_ad_lh];
% wordsnumbers
wn_yc_lh = reshape(youngc_lh(9,10,:),[length(youngc_lh(9,10,:)),1]);
wn_oc_lh = reshape(olderc_lh(9,10,:),[length(olderc_lh(9,10,:)),1]);
wn_ad_lh = reshape(adults_lh(9,10,:),[length(adults_lh(9,10,:)),1]);
w_n = [wn_yc_lh; wn_oc_lh; wn_ad_lh];
% words all nonwords
wnw_yc_lh = reshape(mean(youngc_lh(9,1:8,:),2), [length(mean(youngc_lh(9,1:8,:),2)),1]);
wnw_oc_lh = reshape(mean(olderc_lh(9,1:8,:),2), [length(mean(olderc_lh(9,1:8,:),2)),1]);
wnw_ad_lh = reshape(mean(adults_lh(9,1:8,:),2), [length(mean(adults_lh(9,1:8,:),2)),1]);
w_nw = [wnw_yc_lh; wnw_oc_lh; wnw_ad_lh];
% numbers all nonnumbers
nnn_yc_lh = reshape(mean(youngc_lh(10,1:8,:),2), [length(mean(youngc_lh(10,1:8,:),2)),1]);
nnn_oc_lh = reshape(mean(olderc_lh(10,1:8,:),2), [length(mean(olderc_lh(10,1:8,:),2)),1]);
nnn_ad_lh = reshape(mean(adults_lh(10,1:8,:),2), [length(mean(adults_lh(10,1:8,:),2)),1]);
n_nn = [nnn_yc_lh; nnn_oc_lh; nnn_ad_lh];
%% right hemisphere
% words
ww_yc_rh = reshape(youngc_rh(9,9,:),[length(youngc_rh(9,9,:)),1]);
ww_oc_rh = reshape(olderc_rh(9,9,:),[length(olderc_rh(9,9,:)),1]);
ww_ad_rh = reshape(adults_rh(9,9,:),[length(adults_rh(9,9,:)),1]);
w_w_rh = [ww_yc_rh; ww_oc_rh; ww_ad_rh];
% numbers
nn_yc_rh = reshape(youngc_rh(10,10,:),[length(youngc_rh(10,10,:)),1]);
nn_oc_rh = reshape(olderc_rh(10,10,:),[length(olderc_rh(10,10,:)),1]);
nn_ad_rh = reshape(adults_rh(10,10,:),[length(adults_rh(10,10,:)),1]);
n_n_rh = [nn_yc_rh; nn_oc_rh; nn_ad_rh];
% wordsnumbers
wn_yc_rh = reshape(youngc_rh(9,10,:),[length(youngc_rh(9,10,:)),1]);
wn_oc_rh = reshape(olderc_rh(9,10,:),[length(olderc_rh(9,10,:)),1]);
wn_ad_rh = reshape(adults_rh(9,10,:),[length(adults_rh(9,10,:)),1]);
w_n_rh = [wn_yc_rh; wn_oc_rh; wn_ad_rh];
% words all nonwords
wnw_yc_rh = reshape(mean(youngc_rh(9,1:8,:),2), [length(mean(youngc_rh(9,1:8,:),2)),1]);
wnw_oc_rh = reshape(mean(olderc_rh(9,1:8,:),2), [length(mean(olderc_rh(9,1:8,:),2)),1]);
wnw_ad_rh = reshape(mean(adults_rh(9,1:8,:),2), [length(mean(adults_rh(9,1:8,:),2)),1]);
w_nw_rh = [wnw_yc_rh; wnw_oc_rh; wnw_ad_rh];
% numbers all nonnumbers
nnn_yc_rh = reshape(mean(youngc_rh(10,1:8,:),2), [length(mean(youngc_rh(10,1:8,:),2)),1]);
nnn_oc_rh = reshape(mean(olderc_rh(10,1:8,:),2), [length(mean(olderc_rh(10,1:8,:),2)),1]);
nnn_ad_rh = reshape(mean(adults_rh(10,1:8,:),2), [length(mean(adults_rh(10,1:8,:),2)),1]);
n_nn_rh = [nnn_yc_rh; nnn_oc_rh; nnn_ad_rh];
%% other preparations for plotting.
figure('Position', [0, 0, 800, 500]);
set(gcf,'color','white')
hold on
% Number of rows
nrows = 1;
% w and h of each axis in normalized units
axisw = 0.10;
axish = (1 / nrows) * 0.85;
% lets add some white space to give the figure more structure
space = zeros(51,1);
pairs_titles = {'w-w', 'n-n', ' ', 'w-n', ' ', 'w-nw', 'n-nn'};
pairs_lh = { w_w, n_n, space, w_n, space, w_nw, n_nn};
pairs_rh = { w_w_rh, n_n_rh, space, w_n_rh, space, w_nw_rh, n_nn_rh};
axis_pos = [0 0.22 0.375 0.5 0.6250 0.75 0.875];
%% make plots - seperate for the left and right hemisphere
% Let's create the LEFT hemisphere plot first
for p= 1:length(pairs_lh)
axisl = axis_pos(p);
if p ==1
subplot('position', [axisl, 0.1, axisw+0.09, axish])
else
subplot('position', [axisl, 0.1, axisw, axish])
end
% boxplots
boxplot(pairs_lh{p},group, 'Labels',{' 5-9', '10-12', ' 22-26'}, 'Widths', 0.9,'Symbol', 'k.');
hold on
t_lh = title(sprintf(pairs_titles{p}));
% adjust title position
set(t_lh, 'Position', [2 -0.28 0]);
box off
% Color the boxes in the colors from our color scheme.
mycolors = [0.98 0.5 0.447; 0.11 0.56 1; 143/255 197/255 223/255];
b = findobj(gca,'Tag','Box');
for j=1:length(b)
patch(get(b(j),'XData'),get(b(j),'YData'),mycolors(j, :),'FaceAlpha',.7);
end
if p ~= 1
set(gca, 'YColor', [1 1 1])
set(gca, 'YTicklabel','')
end
if p == 1
ylabel('Correlation');
end
% make the median lines nicer
lines = findobj(gcf, 'type', 'line', 'Tag', 'Median');
set(lines, 'Color', 'k');
set(findobj(gcf, 'LineStyle', '--'), 'LineStyle', '-');
if p ~= 3 && p ~= 5
% add zero line but only for plots with data (not for spacings)
r =refline(0,0);
set(r,'Color',[0.5,0.5,0.5]);
set(r,'LineStyle','-');
else
r =refline(0,0);
set(r,'Color',[1,1,1]);
set(r,'LineStyle','-');
end
% make axis fixed and look better
ylim([-0.2 0.8]);
xlim([0 4]);
set(gca, 'TickLength', [0 0]);
set (gca, 'box' , 'off')
set(gca,'XTicklabel', []);
set(gca, 'XColor', [1 1 1])
hold on
end
%overall title
axes( 'Position', [0, 0, 1, 0.95] ) ;
set( gca, 'Color', 'None', 'XColor', 'White', 'YColor', 'White' ) ;
text( 0.55, 0.965, sprintf('Left %s VTC', partition), 'FontSize', 11', 'FontWeight', 'Bold', ...
'HorizontalAlignment', 'center', 'VerticalAlignment', 'Bottom') ;
set(gcf, 'PaperPositionMode', 'auto')
set(findall(gcf, '-property', 'FontName'), 'FontName', 'Arial')
set(findall(gcf, '-property', 'FontName'), 'FontSize', 14)
hold off
figurename = sprintf('Fig_3_Boxplot_%s_correlations_wordsnumbers_others_lh', partition);
print(fullfile(ResultsDir, figurename), '-dpng', '-r600')
%% other preparations for plotting. matlab gives subplots different sizes,
%when there are many of them. we dont want that
figure('Position', [0, 0, 800, 500]);
%% Now create the RIGHT hemisphere plot
for r= 1:length(pairs_rh)
axisl = axis_pos(r);
if r ==1
subplot('position', [axisl, 0.1, axisw+0.09, axish])
else
subplot('position', [axisl, 0.1, axisw, axish])
end
ylim([-0.2 0.75]);
hold on
set(gcf,'color','white') % background color white
% boxplots
boxplot(pairs_rh{r},group, 'Labels',{' 5-9', '10-12', ' 22-26'}, 'Widths', 0.9,'Symbol', 'k.');
t_rh = title(sprintf(pairs_titles{r}));
% adjust title position
set(t_rh, 'Position', [2 -0.28 0]);
box off
% Color the boxes in the colors from our color scheme.
mycolors = [0.98 0.5 0.447; 0.11 0.56 1; 143/255 197/255 223/255];
b = findobj(gca,'Tag','Box');
for j=1:length(b)
patch(get(b(j),'XData'),get(b(j),'YData'),mycolors(j, :),'FaceAlpha',.7);
end
if r ~= 1
set(gca, 'YColor', [1 1 1])
set(gca, 'YTicklabel','')
end
if r == 1
ylabel('Correlation');
end
% make median lines look better
lines = findobj(gcf, 'type', 'line', 'Tag', 'Median');
set(lines, 'Color', 'k');
set(findobj(gcf, 'LineStyle', '--'), 'LineStyle', '-');
if r ~= 3 && r ~= 5
%add zero line but only for plots with data (not spacings)
r =refline(0,0);
set(r,'Color',[0.5,0.5,0.5]);
set(r,'LineStyle','-');
else
r =refline(0,0);
set(r,'Color',[1,1,1]);
set(r,'LineStyle','-');
end
% make axis fixed and look better
ylim([-0.2 0.8]);
xlim([0 4]);
set(gca, 'TickLength', [0 0]);
set (gca, 'box' , 'off')
set(gca,'XTicklabel', []);
set(gca, 'XColor', [1 1 1])
hold on
end
%overall title
axes( 'Position', [0, 0, 1, 0.95] ) ;
set( gca, 'Color', 'None', 'XColor', 'White', 'YColor', 'White' )
text( 0.55, 0.965, sprintf('Right %s VTC', partition), 'FontSize', 11', 'FontWeight', 'Bold', ...
'HorizontalAlignment', 'center', 'VerticalAlignment', 'Bottom') ;
set(gcf, 'PaperPositionMode', 'auto')
set(findall(gcf, '-property', 'FontName'), 'FontName', 'Arial')
set(findall(gcf, '-property', 'FontName'), 'FontSize', 14)
figurename = sprintf('Fig_3_Boxplot_%s_correlations_wordsnumbers_others_rh', partition);
print(fullfile(ResultsDir,figurename), '-dpng', '-r600')
end
end