-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdLGN_plot_analysis.m
353 lines (337 loc) · 9.82 KB
/
dLGN_plot_analysis.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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
function [ramps_peak ODI data]=dLGN_plot_analysis(directory,plotyn)
%SW181229
%Function for claculating and plotting extracted dLGN ephys data. This
%function uses the extracted ephys data gnerated with script Analysis_mini_ramp as an input
%Inputs:
%directory: directory of extracted mat file gnerated with script Analysis_mini_ramp
%NESTED FUNCTION:
%barwitherr
%uipickfiles
filename=uipickfiles('FilterSpec',directory)%pathname, you need uipickfiles function
load(char(filename));%load mat file
%% RAMP ANALYSIS
%%LOAD PEAK AMPLITUDES FOR AMPA and NMDA
for i=1:(size(data,1)-1)
%AMPA
blue_ramp_70(:,i)=data{i+1,4}.neg_peak2(1,:);
blue_laser_70(:,i)=data{i+1,4}.laser_amp(1,:);
red_ramp_70(:,i)=data{i+1,5}.neg_peak1(2,:);
red_laser_70(:,i)=data{i+1,5}.laser_amp(2,:);
blue_constant_70(:,i)=data{i+1,4}.neg_peak2(2,:);
blue_claser_70(:,i)=data{i+1,4}.laser_amp(2,:);
%NMDA
blue_ramp_40(:,i)=data{i+1,4}.pos_peak2(3,:);
blue_laser_40(:,i)=data{i+1,4}.laser_amp(3,:);
red_ramp_40(:,i)=data{i+1,5}.pos_peak1(4,:);
red_laser_40(:,i)=data{i+1,5}.laser_amp(4,:);
blue_constant_40(:,i)=data{i+1,4}.pos_peak2(4,:);
blue_claser_40(:,i)=data{i+1,4}.laser_amp(4,:);
end
i=[];
%%
%SET VALUES BELOW STD THRESHOLD CRITERION TO ZERO
for i=1:(length(data)-1)
%%%%%%%BLUE ONLY AMPA
idx=find(data{i+1,4}.neg_fail2(1,:)>0)';
d=data{i+1,4}.neg_peak2(1,:);
%%%%%%%
ze=zeros(11,1);
if length(idx)>=5;
ze(idx)=d(idx);
b_r_70(:,i)=ze ;
else
b_r_70(:,i)=ze;
end
%%%%%%%
idx=[];
d=[];
ze=[];
%%%%%%%RED AMPA
idx=find(data{i+1,5}.neg_fail1(2,:)>0)';
d=data{i+1,5}.neg_peak1(2,:);
%%%%%%%
ze=zeros(11,1);
if length(idx)>=5;
ze(idx)=d(idx);
r_r_70(:,i)=ze;
else
r_r_70(:,i)=ze;
end
%%%%%%%
idx=[];
d=[];
ze=[];
%%%%%%%BLUE CONSTANT AMPA
idx=find(data{i+1,4}.neg_fail2(2,:)>0)';
d=data{i+1,4}.neg_peak2(2,:);
%%%%%%%
ze=zeros(11,1);
if length(idx)>=5;
ze(idx)=d(idx);
b_c_70(:,i)=ze;
else
b_c_70(:,i)=ze;
end
%%%%%%%
idx=[];
d=[];
ze=[];
%%%%%%%BLUE ONLY NMDA
idx=find(data{i+1,4}.pos_fail2(3,:)>0)';
d=data{i+1,4}.pos_peak2(3,:);
%%%%%%%
ze=zeros(11,1);
if length(idx)>=5;
ze(idx)=d(idx);
b_r_40(:,i)=ze ;
else
b_r_40(:,i)=ze;
end
%%%%%%%
idx=[];
d=[];
ze=[];
%%%%%%%RED NMDA
idx=find(data{i+1,5}.pos_fail1(4,:)>0)';
d=data{i+1,5}.pos_peak1(4,:);
%%%%%%%
ze=zeros(11,1);
if length(idx)>=5;
ze(idx)=d(idx);
r_r_40(:,i)=ze;
else
r_r_40(:,i)=ze;
end
%%%%%%%
idx=[];
d=[];
ze=[];
%%%%%%%BLUE CONSTANT NMDA
idx=find(data{i+1,4}.pos_fail2(4,:)>0)';
d=data{i+1,4}.pos_peak2(4,:);
%%%%%%%
ze=zeros(11,1);
if length(idx)>=5;
ze(idx)=d(idx);
b_c_40(:,i)=ze;
else
b_c_40(:,i)=ze;
end
%%%%%%%
idx=[];
d=[];
ze=[];
end
%%
%ODI and AMPA/NMDA Ratio
for i=1:(length(data)-1)
%AMPA
ODI_raw_AMPA(:,i)=(abs(red_ramp_70(:,i))-abs(blue_constant_70(:,i)))./(abs(red_ramp_70(:,i))+abs(blue_constant_70(:,i)));
ODI_AMPA(:,i)=(abs(r_r_70(:,i))-abs(b_c_70(:,i)))./(abs(r_r_70(:,i))+abs(b_c_70(:,i)));
%NMDA
ODI_raw_NMDA(:,i)=(abs(red_ramp_40(:,i))-abs(blue_constant_40(:,i)))./(abs(red_ramp_40(:,i))+abs(blue_constant_40(:,i)));
ODI_NMDA(:,i)=(abs(r_r_40(:,i))-abs(b_c_40(:,i)))./(abs(r_r_40(:,i))+abs(b_c_40(:,i)));
%AMPA/NMDA Ratio
Ratio_an_r(:,i)=abs(r_r_70(:,i))./abs(r_r_40(:,i));
Ratio_an_b(:,i)=abs(b_r_70(:,i))./abs(b_r_40(:,i));
Ratio_an_bc(:,i)=abs(b_c_70(:,i))./abs(b_c_40(:,i));
end
%ODI average; used the last 6 entries from 11 ramps-> NEEDS TO BE DISCUSSED
ODI_A=nanmean(ODI_AMPA(5:end,:));
ODI_A_sem=nanstd(ODI_AMPA(5:end,:))/sqrt(length(data));
ODI_N=nanmean(ODI_NMDA(5:end,:));
ODI_N_sem=nanstd(ODI_NMDA(5:end,:))/sqrt(length(data));
%RATIO AMPA/NMDA average
R_r=nanmean(Ratio_an_r(5:end,:));
R_r_sem=nanstd(Ratio_an_r(5:end,:))/sqrt(length(data));
R_b=nanmean(Ratio_an_b(5:end,:));
R_b_sem=nanstd(Ratio_an_b(5:end,:))/sqrt(length(data));
R_bc=nanmean(Ratio_an_bc(5:end,:));
R_bc_sem=nanstd(Ratio_an_bc(5:end,:))/sqrt(length(data));
%Create combined vector for plotting in bar graph later
com_ODI=[ODI_A' ODI_N'];
com_ODI_sem=[ODI_A_sem' ODI_N_sem'];
com_R=[R_b' R_r' R_bc'];
com_R_sem=[R_b_sem' R_r_sem' R_bc_sem'];
%output important variables
ramps_peak.red70=r_r_70;
ramps_peak.red40=r_r_40;
ramps_peak.blue70=b_r_70;
ramps_peak.blue40=b_r_40;
ramps_peak.blue_constant70=b_c_70;
ramps_peak.blue_constant40=b_c_40;
ODI.AMPA=ODI_AMPA;
ODI.NMDA=ODI_NMDA;
ODI.aAMPA=ODI_A;
ODI.aNMDA=ODI_N;
data{1,7}='ODI AMPA';
data{1,8}='ODI NMDA';
for i=1:(length(data)-1)
data{i+1,7}=ODI_A(i);
data{i+1,8}=ODI_N(i);
end
%%
i=[];
if plotyn==1
%PLOT GRAPHS
cvec=unique(hsv(length(data)*30),'rows');
Legend=cell(length(data),1)% two positions
f1=figure('Name','AMPA');
set(gcf, 'Position', [200, 0, 600, 1500]);
f2=figure('Name','NMDA');
set(gcf, 'Position', [600, 0, 600, 1500]);
for i=1:(length(data)-1)
figure(f1);
subplot(3,1,1);
h{i}=plot(blue_laser_70(:,i),b_r_70(:,i),'--s','LineWidth',2,'MarkerSize',5,'Color',cvec(i*30,:));
axis square;
title('Blue laser only');
xlabel('Laser amplitude (a.u.)');
ylabel('Peak synaptic current (pA)');
Legend{i}=data{i,1};
hold on;
end
figure(f1);
legend(Legend,'Location','EastOutside');
legend boxoff;
hold on;
i=[];
%%%second repeat
for i=1:(length(data)-1)
subplot(3,1,2);
m{i}=plot(blue_laser_70(:,i),r_r_70(:,i),'--s','LineWidth',2,'MarkerSize',5,'Color',cvec(i*30,:));
title('Red laser');
xlabel('Laser amplitude (a.u.)');
ylabel('Peak synaptic current (pA)');
axis square;
hold on;
end
figure(f1);
legend(Legend,'Location','EastOutside');
legend boxoff;
hold on;
i=[];
%%%third repeat
for i=1:(length(data)-1)
subplot(3,1,3);
m{i}=plot(blue_claser_70(:,i),b_c_70(:,i),'--s','LineWidth',2,'MarkerSize',5,'Color',cvec(i*30,:));
title('Blue constant');
xlabel('Laser amplitude (a.u.)');
ylabel('Peak synaptic current (pA)');
axis square;
hold on;
end
figure(f1);
legend(Legend,'Location','EastOutside');
legend boxoff;
hold on;
i=[];
%40mV NMDA
%1st repeat
figure(f2);
for i=1:(length(data)-1)
subplot(3,1,1);
m{i}=plot(blue_laser_40(:,i),b_r_40(:,i),'--s','LineWidth',2,'MarkerSize',5,'Color',cvec(i*30,:));
title('Blue laser only');
xlabel('Laser amplitude (a.u.)');
ylabel('Peak synaptic current (pA)');
axis square;
Legend{i}=data{i,1};
hold on;
end
figure(f2);
legend(Legend,'Location','EastOutside');
legend boxoff;
hold on;
i=[];
%2nd repeat
for i=1:(length(data)-1)
subplot(3,1,2);
m{i}=plot(blue_laser_40(:,i),r_r_40(:,i),'--s','LineWidth',2,'MarkerSize',5,'Color',cvec(i*30,:));
title('Red laser');
xlabel('Laser amplitude (a.u.)');
ylabel('Peak synaptic current (pA)');
axis square;
Legend{i}=data{i,1};
hold on;
end
figure(f2);
legend(Legend,'Location','EastOutside');
legend boxoff;
hold on;
i=[];
%3rd repeat
for i=1:(length(data)-1)
subplot(3,1,3);
m{i}=plot(blue_claser_40(:,i),b_c_40(:,i),'--s','LineWidth',2,'MarkerSize',5,'Color',cvec(i*30,:));
title('Blue constant');
xlabel('Laser amplitude (a.u.)');
ylabel('Peak synaptic current (pA)');
axis square;
Legend{i}=data{i,1};
hold on;
end
figure(f2);
legend(Legend,'Location','EastOutside');
legend boxoff;
hold on;
i=[];
%ODI AND RATIO AMPA/NMDA
%ODI
try
figure;barwitherr(com_ODI_sem,com_ODI);
catch
figure;bar(com_ODI);hold on;errorbar(com_ODI,com_ODI_sem,'.');
end
ylim([-1.3 1.3])
axis square;
xlabel('Cell');
ylabel('ODI');
title('Ocular dominance');
legend('AMPA','NMDA');
%RATIO AMPA/NMDA
try
figure;barwitherr(com_R_sem,com_R);
catch
figure;bar(com_R);hold on;errorbar(com_R,com_R_sem,'.');
end
axis square;
xlabel('Cell');
ylabel('Peak AMPA / Peak NMDA');
title('AMPA / NMDA Ratio');
legend('Blue only','Red','Blue constant');
%% MINI ANALYSIS
% %AMPA
% i_o_suc=zeros(1,size(data,1));
% i_o_suc_sem=zeros(1,size(data,1));
% minionly=1;
% for i=1:size(data,1)
% if minionly==1;
% try
% mblue_70(:,i)=data{i,2}(1:50,1);
% mred_70(:,i)=data{i,2}(1:50,2);
% PD_blue_70(:,i)=data{i,4}(1:50,1);
% PD_red_70(:,i)=data{i,4}(1:50,2);
% IR1_red_70(:,i)=data{i,5}(1:50,2);
% IR1_blue_70(:,i)=data{i,6}(1:50,2);
% PD_rb_ratio(:,i)=mean(PD_red_70(:,i))/mean(IR1_blue_70(:,i));
% IR_rb_ratio(:,i)=mean(IR1_red_70(:,i))/mean(IR1_blue_70(:,i));
% catch
% end
% end
% end
%
%
% if length(find(mblue_70(:,i)<0))>5 & length(find(mred_70(:,i)<0))<7
% disp('IPSI ONLY');
% idx_success=find(mblue_70(1:50,i)<0);
% i_o_suc(:,i)=mean(mblue_70(idx_success));
% i_o_suc_sem(:,i)=std(mblue_70(idx_success,i))/length(sqrt(idx_success));
% else
% disp ('EITHER CONTRA ONLY OR BINOCULAR');
% end
%
% end
%
end
end