/
Figure_1_f_data.m
120 lines (85 loc) · 4.66 KB
/
Figure_1_f_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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
%% Thomas_Yang_et al, 2023 @Nuo Li lab
%% Fig. 1f, lick behavior, unilateral SC photoactivation
clear all
close all
load Figure_1_f_data
%% licking temporal histogram, all mice
figure
n_plot = 0;
for i_aom = [0 0.1 0.3 0.4 0.5]
for i_SC_side = 1:2
n_plot = n_plot+1;
% select stim side
stim_side_selection = (StimSide_allSession==i_SC_side);
% set stim epoch
stim_epoch_selection = (Stim_Period_allSession==1 & StimOnTime_allSession<1 & StimDur_allSession ==0.5); % early sample
% lick early
if i_aom ==0
trial_selection = (AOM_data_allSession == i_aom & StimTrials_allSession >0);
else
trial_selection = (AOM_data_allSession == i_aom & stim_epoch_selection & StimTrials_allSession >0 & stim_side_selection);
end
if sum(trial_selection)>0
lick_times_tmp = cell2mat(Lick_Time_allSession(trial_selection));
lick_times_tmp = lick_times_tmp(lick_times_tmp(:,2)>0,:);
i_lick_right_tmp = (lick_times_tmp(:,1)==3); % blue
i_lick_left_tmp = (lick_times_tmp(:,1)==1); % red
n_trials_right_tmp = sum(trial_selection & R_hit_allSession==1);
n_trials_left_tmp = sum(trial_selection & L_hit_allSession==1);
subplot(5,2,n_plot); hold on
[y x] = hist(lick_times_tmp(i_lick_right_tmp,2), 0:.1:5);
plot(x,y/.1/n_trials_right_tmp,'b')
[y x] = hist(lick_times_tmp(i_lick_left_tmp,2), 0:.1:5);
plot(x,y/.1/n_trials_left_tmp,'r')
line([0.5723 0.5723],[0 30],'color','k')
line([1.8727 1.8727],[0 30],'color','k')
line([3.1732 3.1732],[0 30],'color','k')
xlim([0 4])
ylim([0 30])
end
end
end
subplot(5,2,1); title('All mice')
%% pooled across sample and delay
figure; hold on
for i_mice = 1:n_animals
X_type = [];
R_early_lick = [];
L_early_lick = [];
n_trials = [];
for i_aom = [0 .1 .2 .3 .4 .5]
% invert the trial type based on stimulated SC
i_select_leftSC = find(StimSide_allSession==1);
i_select_rightSC = find(StimSide_allSession==2);
Lick_ContraIpsi_allSession(i_select_leftSC,:) = Lick_Side_allSession(i_select_leftSC);
Lick_ContraIpsi_allSession(i_select_rightSC,:) = -(Lick_Side_allSession(i_select_rightSC)-2)+2;
% select stim side
stim_side_selection = (StimSide_allSession==i_SC_side);
% lick early
if i_aom ==0
trial_selection = (AOM_data_allSession == i_aom & StimTrials_allSession >0 & Session_Index_allSession(:,1)==i_mice);
X_type(end+1,1) = size(X_type,1)+1;
R_early_lick(end+1,1) = sum(trial_selection & AOM_data_allSession == 0 & StimTrials_allSession >0 & LickEarly_allSession == 1 & Lick_ContraIpsi_allSession==3)/sum(trial_selection & AOM_data_allSession == 0 & StimTrials_allSession == 1);
L_early_lick(end+1,1) = sum(trial_selection & AOM_data_allSession == 0 & StimTrials_allSession >0 & LickEarly_allSession == 1 & Lick_ContraIpsi_allSession==1)/sum(trial_selection & AOM_data_allSession == 0 & StimTrials_allSession == 1);
n_trials(end+1,1) = sum(trial_selection & AOM_data_allSession == 0 & StimTrials_allSession>0);
else
trial_selection = (AOM_data_allSession == i_aom & (Stim_Period_allSession==1 |Stim_Period_allSession==2) & StimTrials_allSession>0 & Session_Index_allSession(:,1)==i_mice);
if sum(trial_selection & stim_side_selection)>0
X_type(end+1,1) = size(X_type,1)+1;
R_early_lick(end+1,1) = sum(trial_selection & stim_side_selection & LickEarly_allSession == 1 & Lick_ContraIpsi_allSession==3)/sum(trial_selection & stim_side_selection);
L_early_lick(end+1,1) = sum(trial_selection & stim_side_selection & LickEarly_allSession == 1 & Lick_ContraIpsi_allSession==1)/sum(trial_selection & stim_side_selection);
n_trials(end+1,1) = sum(trial_selection & stim_side_selection);
end
end
end
if length(n_trials)>1
plot(X_type,R_early_lick,'-b');%,'markerfacecolor','w')
plot(X_type,L_early_lick,'-r');%,'markerfacecolor','w')
end
end
title('both SC hemi (sample or delay stim)')
xlabel('Power')
ylabel('Fraction of early licks')
ylim([0 1])
xlim([0 6])
legend('lick contra', 'lick ipsi')