-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRP_FA_plot2.m
More file actions
336 lines (278 loc) · 9.14 KB
/
RP_FA_plot2.m
File metadata and controls
336 lines (278 loc) · 9.14 KB
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
334
335
336
function RP_FA_plot2
%% Identify the directories and subject types in the study
% The full call can be
[~,subDir,~,CRD,~,Ctl,RP] = Tama_subj2;
%% Load TractProfile data
TPdata = fullfile('/biac4/wandell/biac2/wandell/data/DWI-Tamagawa-Japan2/results/Tama2_TP_SD.mat');
if exist(TPdata)
load(TPdata)
else
load '/Users/shumpei/Google Drive/RP/Tama2_TP_SD.mat'
end
%% Figure
% indivisual FA value along optic tract
% take values
fibID =3; %
sdID = 1;%:7
% make one sheet diffusivity
% merge both hemisphere
for subID = 1:length(TractProfile);
if isempty(TractProfile{subID,fibID}{sdID}.nfibers);
fa(subID,:) =nan(1,100);
else
fa(subID,:) = mean([TractProfile{subID,fibID}{sdID}.vals.fa;...
TractProfile{subID,fibID+1}{sdID}.vals.fa]);
end;
if isempty(TractProfile{subID,fibID}{sdID}.nfibers);
md(subID,:) =nan(1,100);
else
md(subID,:) = mean([ TractProfile{subID,fibID}{sdID}.vals.md;...
TractProfile{subID,fibID+1}{sdID}.vals.md]);
end;
if isempty(TractProfile{subID,fibID}{sdID}.nfibers);
rd(subID,:) =nan(1,100);
else
rd(subID,:) = mean([ TractProfile{subID,fibID}{sdID}.vals.rd;...
TractProfile{subID,fibID+1}{sdID}.vals.rd]);
end;
if isempty(TractProfile{subID,fibID}{sdID}.nfibers);
ad(subID,:) =nan(1,100);
else
ad(subID,:) = mean([ TractProfile{subID,fibID}{sdID}.vals.ad;...
TractProfile{subID,fibID+1}{sdID}.vals.ad]);
end;
end
%% switch based on property
Diffusion = {'fa'};
for ii =1:length(Diffusion)
property = Diffusion{ii};
switch property
case {'fa','FA'}
ValCtl = fa(Ctl,:);
ValRP = fa(RP,:);
XLIM = [10,90];
YLIM = [0 0.6];
XTICK = XLIM;
YTICK = YLIM;
XTICKLabel = {'OC','LGN'};
case {'md','MD'}
ValCtl = md(Ctl,:);
ValRP = md(RP,:);
XLIM = [10,90];
YLIM = [0.6 1.8];
XTICK = XLIM;
YTICK = YLIM;
XTICKLabel = {'OC','LGN'};
case {'ad','AD'}
ValCtl = ad(Ctl,:);
ValRP = ad(RP,:);
XLIM = [10,90];
YLIM = [1 2.4];
XTICK = XLIM;
YTICK = YLIM;
XTICKLabel = {'OC','LGN'};
case {'rd','RD'}
ValCtl = rd(Ctl,:);
ValRP = rd(RP,:);
XLIM = [10,90];
YLIM = [0.4 1.6];
XTICK = XLIM;
YTICK = YLIM;
XTICKLabel = {'OC','LGN'};
end
%% Wilcoxon
for ii = 1:length(ValRP);
[p(ii),h(ii)] = ranksum(ValCtl(:,ii),ValRP(:,ii),'alpha',0.05);
end
% %% ANOVA
%
% for jj= 1: 100
% pac = nan(14,3);
% pac(:,1)= ValCtl(:,jj);
% pac(1:length(RP),2)= ValRP(:,jj);
% pac(1:length(CRD),3)= CRD_fa(:,jj);
% [p(jj),~,stats(jj)] = anova1(pac,[],'off');
% co = multcompare(stats(jj),'display','off');
% C{jj}=co;
% end
% Portion = p<0.01; % where is most effected
%% Optic Tract
% FA
% figure; hold on;
mrvNewGraphWin;
subplot(1,2,1);hold on;
X = 1:100;
c = lines(100);
% bars where is significant difference between two groups
% p<0.05
bar(1:100,h*5,1,'EdgeColor','none','facecolor',[0.8 0.7 0.3])
% p,0.01
% bar(1:100,p,1,'EdgeColor','none','facecolor',[0.6 0.6 0.6])
% Control
st = nanstd(ValCtl,1);
m = nanmean(ValCtl);
% render control subjects range
A3 = area(m+2*st);
A1 = area(m+st);
A2 = area(m-st);
A4 = area(m-2*st);
% set color and style
set(A1,'FaceColor',[0.6 0.6 0.6],'linestyle','none')
set(A2,'FaceColor',[0.8 0.8 0.8],'linestyle','none')
set(A3,'FaceColor',[0.8 0.8 0.8],'linestyle','none')
set(A4,'FaceColor',[1 1 1],'linestyle','none')
plot(m,'color',[0 0 0], 'linewidth',3 )
% % add individual FA plot
% for k = CRD %1:length(subDir)
% plot(X,ValRP(k,:),'Color',c(3,:),'linewidth',1);
% end
% m = nanmean(fa(CRD,:));
% plot(X,m,'Color',c(3,:) ,'linewidth',3)
% add individual
for k =1:length(RP) %1:length(subDir)
plot(X,ValRP(k,:),'--','Color',c(5,:),'linewidth',1);
end
% plot mean value
m = nanmean(ValRP);
plot(X,m,'Color',c(5,:) ,'linewidth',3)
% add label
xlabel('Location','fontSize',14);
ylabel('Fractional diffusivity','fontSize',14);
% ylabel(upper(property),'fontSize',14);
title('Optic tract','fontSize',14)
% adjustment
set(gca,'xlim',XLIM,'ylim',YLIM, 'xtick',XTICK,'ytick',YTICK,...
'xtickLabel',XTICKLabel,...
'tickDir','out','tickLength', [0.01 0.02])
axis square
hold off;
% % save
% if save_fig,
% saveas(gcf,sprintf('OT_%s.png',upper(property)))
% saveas(gcf,sprintf('OT_%s.eps',upper(property)),'psc2')
% end
%% Figure
% indivisual FA value along optic tract
% take values
fibID =1; %
sdID = 1;%:7
% make one sheet diffusivity
% merge both hemisphere
for subID = 1:length(TractProfile);
if isempty(TractProfile{subID,fibID}{sdID}.nfibers);
fa(subID,:) =nan(1,100);
else
fa(subID,:) = mean([TractProfile{subID,fibID}{sdID}.vals.fa;...
TractProfile{subID,fibID+1}{sdID}.vals.fa]);
end;
if isempty(TractProfile{subID,fibID}{sdID}.nfibers);
md(subID,:) =nan(1,100);
else
md(subID,:) = mean([ TractProfile{subID,fibID}{sdID}.vals.md;...
TractProfile{subID,fibID+1}{sdID}.vals.md]);
end;
if isempty(TractProfile{subID,fibID}{sdID}.nfibers);
rd(subID,:) =nan(1,100);
else
rd(subID,:) = mean([ TractProfile{subID,fibID}{sdID}.vals.rd;...
TractProfile{subID,fibID+1}{sdID}.vals.rd]);
end;
if isempty(TractProfile{subID,fibID}{sdID}.nfibers);
ad(subID,:) =nan(1,100);
else
ad(subID,:) = mean([ TractProfile{subID,fibID}{sdID}.vals.ad;...
TractProfile{subID,fibID+1}{sdID}.vals.ad]);
end;
end
%% switch based on property
% Diffusion = {'fa','md','ad','rd'};
% for ii =1:length(Diffusion)
switch property
case {'fa','FA'}
ValCtl = fa(Ctl,:);
ValRP = fa(RP,:);
XLIM = [10,90];
YLIM = [0.2 0.8];
XTICK = XLIM;
YTICK = YLIM;
XTICKLabel = {'LGN','V1'};
case {'md','MD'}
ValCtl = md(Ctl,:);
ValRP = md(RP,:);
XLIM = [10,90];
YLIM = [0.6 1];
XTICK = XLIM;
YTICK = YLIM;
XTICKLabel = {'LGN','V1'};
case {'ad','AD'}
ValCtl = ad(Ctl,:);
ValRP = ad(RP,:);
XLIM = [10,90];
YLIM = [1 1.7];
XTICK = XLIM;
YTICK = YLIM;
XTICKLabel = {'LGN','V1'};
case {'rd','RD'}
ValCtl = rd(Ctl,:);
ValRP = rd(RP,:);
XLIM = [10,90];
YLIM = [0.3 0.8];
XTICK = XLIM;
YTICK = YLIM;
XTICKLabel = {'LGN','V1'};
end
%% Render plots
% Wilcoxon test
for ii = 1:length(ValRP);
[p(ii),h(ii)] = ranksum(ValCtl(:,ii),ValRP(:,ii),'alpha',0.05);
end
subplot(1,2,2); hold on;
X = 1:100;
c = lines(100);
% bars where is significant difference between two groups
% p<0.05
bar(1:100,h*5,1,'EdgeColor','none','facecolor',[0.8 0.7 0.3])
% p,0.01
% bar(1:100,p,1,'EdgeColor','none','facecolor',[0.6 0.6 0.6])
% Control
st = nanstd(ValCtl,1);
m = nanmean(ValCtl);
% render control subjects range
A3 = area(m+2*st);
A1 = area(m+st);
A2 = area(m-st);
A4 = area(m-2*st);
% set color and style
set(A1,'FaceColor',[0.6 0.6 0.6],'linestyle','none')
set(A2,'FaceColor',[0.8 0.8 0.8],'linestyle','none')
set(A3,'FaceColor',[0.8 0.8 0.8],'linestyle','none')
set(A4,'FaceColor',[1 1 1],'linestyle','none')
plot(m,'color',[0 0 0], 'linewidth',3 )
% % add individual FA plot
% for k = CRD %1:length(subDir)
% plot(X,ValRP(k,:),'Color',c(3,:),'linewidth',1);
% end
% m = nanmean(fa(CRD,:));
% plot(X,m,'Color',c(3,:) ,'linewidth',3)
% add individual
for k =1:length(RP) %1:length(subDir)
plot(X,ValRP(k,:),'--','Color',c(5,:),'linewidth',1);
end
% plot mean value
m = nanmean(ValRP);
plot(X,m,'Color',c(5,:) ,'linewidth',3)
% add label
xlabel('Location','fontSize',14);
ylabel('Fractional diffusivity','fontSize',14);
% ylabel(upper(property),'fontSize',14);
title('Optic radiation','fontSize',14)
% adjustment
set(gca,'xlim',XLIM,'ylim',YLIM, 'xtick',XTICK,'ytick',YTICK,...
'xtickLabel',XTICKLabel,...
'tickDir','out','tickLength', [0.01 0.02])
axis square
% lh = legend('RP','Control');
% set(lh,'box','off')
% L = get(lh);
hold off;
end