/
Figure_1_g_data.m
99 lines (66 loc) · 2.8 KB
/
Figure_1_g_data.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
%% Thomas_Yang_et al, 2023 @Nuo Li lab
%% Fig. 1g, ignore rate
clear all
close all
load Figure_1_g_data
%% individual mouse
perf_Raw_all = [];
n_mice = 0;
for i_mice = unique(Session_type_allSession(:,1))'
n_mice = n_mice+1;
%% ------------ plot the performance --------------
% control
X_type = [];
Y_perf = [];
n_trials = [];
X_type(end+1,1) = size(X_type,1)+1;
i_select = find(AOM_data_allSession == 0 & StimTrials_allSession >0 & Session_type_allSession(:,1)==i_mice);
% Ignore rate, alls Trials
Y_perf(end+1,1) = sum(R_ignore_allSession(i_select)|L_ignore_allSession(i_select))/length(i_select);
for i=1:1000
tmp = R_ignore_allSession(i_select);
perf_tmp(i) = mean(tmp(randsample(length(tmp),length(tmp),1)));
end
Y_perf(end,2) = std(perf_tmp);
n_trials(end+1,1) = length(i_select);
% stim trials
for i_condition = 1:3
X_type(end+1,1) = size(X_type,1)+1;
if i_condition==1
i_select = find(Sample_Delay_allSession==1 & AOM_data_allSession>1.5 & LickEarly_allSession==0 & StimTrials_allSession >0 & Session_type_allSession(:,1)==i_mice & StimDur_allSession>0.6);
elseif i_condition==2
i_select = find(Sample_Delay_allSession==2 & AOM_data_allSession>1.5 & LickEarly_allSession==0 & StimTrials_allSession >0 & Session_type_allSession(:,1)==i_mice & StimDur_allSession>0.6);
elseif i_condition==3
i_select = find(Sample_Delay_allSession==3 & AOM_data_allSession>1.5 & LickEarly_allSession==0 & StimTrials_allSession >0 & Session_type_allSession(:,1)==i_mice & StimDur_allSession>0.6);
end
% Ignore rate, alls Trials
Y_perf(end+1,1) = sum(R_ignore_allSession(i_select)|L_ignore_allSession(i_select))/length(i_select);
for i=1:1000
tmp = R_ignore_allSession(i_select);
perf_tmp(i) = mean(tmp(randsample(length(tmp),length(tmp),1)));
end
Y_perf(end,2) = std(perf_tmp);
n_trials(end+1,1) = length(i_select);
end
figure(1);
subplot(2,3,i_mice); hold on
errorbar(1:4,Y_perf(:,1),Y_perf(:,2),'color','k')
for i_tmp = 1:4
text(i_tmp,Y_perf(i_tmp,1)+.1,num2str(n_trials(i_tmp,1)));
end
ylabel('Fraction ignored')
ylim([0 1])
title(['Mouse ',num2str(i_mice)]);
% save data
perf_Raw_all(:,1,n_mice) = Y_perf(:,1);
end
% plot performance for all mice
perf_all = squeeze(perf_Raw_all(:,1,:));
figure; hold on
plot(1:2,perf_all([1 4],:),'color',[.3 .3 .3]);
ylim([0 1])
xlim([0 3])
ylabel('Fraction ignored')
xticks([1 2])
xticklabels({'0' '4.5'})
xlabel('Power (mW)')