-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfig2.m
168 lines (137 loc) · 5.11 KB
/
fig2.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
clear;
% opengl software
addpath('./functions/');
D = load('./data/preproc/context_dependent_face_categorization_task.mat').trial_data;
%% Fig 2A: Psychometric and chronometric functions along task axis
subj = cellfun(@(x) x.subj, D, 'uni', 0);
cond_switch = cellfun(@(x) x.cond_switch, D);
coh = cellfun(@(x) x.coh, D);
resp = cellfun(@(x) x.resp, D);
rt = cellfun(@(x) x.rt, D);
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
opt.color = {'k', 'r'};
opt.legend = {'Non-switch', 'Switch'};
opt.xlabel = {'Task axis', '(% Morph)'};
opt.ylim = [0.6, 1.6];
run_show_choiceRT(cond_switch, coh, resp, rt, subj, opt);
%% Fig 2B: Psychometric and chronometric functions along orthogonal axis
subj = cellfun(@(x) x.subj, D, 'uni', 0);
cond_switch = cellfun(@(x) x.cond_switch, D);
coh_orth = cellfun(@(x) x.coh_orth, D);
resp = cellfun(@(x) x.resp, D);
rt = cellfun(@(x) x.rt, D);
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
opt.color = {'k', 'r'};
opt.legend = {'Non-switch', 'Switch'};
opt.xlabel = {'Orthogonal axis', '(% Morph)'};
opt.ylim = [0.6, 1.6];
run_show_choiceRT(cond_switch, coh_orth, resp, rt, subj, opt);
%% Fig 2C
subj = cellfun(@(x) x.subj, D, 'uni', 0);
cond_switch = cellfun(@(x) x.cond_switch, D);
coh = cellfun(@(x) x.coh, D);
rt = cellfun(@(x) x.rt, D);
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
opt.xlabel = {'Task axis', '(Absolute % Morph)'};
opt.ylim = [0 0.4];
run_show_drtCoh_unsigned(cond_switch, coh, rt, subj, opt);
%% Fig 2D
subj = cellfun(@(x) x.subj, D, 'uni', 0);
cond_switch = cellfun(@(x) x.cond_switch, D);
coh_orth = cellfun(@(x) x.coh_orth, D);
rt = cellfun(@(x) x.rt, D);
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
opt.xlabel = {'Orthogonal axis', '(Absolute % Morph)'};
opt.ylim = [0 0.4];
run_show_drtCoh_unsigned(cond_switch, coh_orth, rt, subj, opt);
%% Fig 2E
subj = cellfun(@(x) x.subj, D, 'uni', 0);
n_after_switch = cellfun(@(x)x.n_after_switch, D);
cond_switch = cellfun(@(x) x.cond_switch, D);
rt = cellfun(@(x) x.rt, D);
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
opt.ylim = [-0.08 0.25];
opt.xlim = [-.5 5.5]+1;
run_show_drtAfterNSwitch(cond_switch, n_after_switch, rt, subj, opt);
%% Fig 2F
subj = cellfun(@(x) x.subj, D, 'uni', 0);
n_after_nonswitch = cellfun(@(x)x.n_after_nonswitch, D);
cond_switch = cellfun(@(x) x.cond_switch, D);
rt = cellfun(@(x) x.rt, D);
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
opt.ylim = [-0.08 0.4];
opt.xlim = [.5 4.5];
run_show_drtAfterNNonswitch(cond_switch, n_after_nonswitch, rt, subj, opt);
%% Fig 2G
csi = cellfun(@(x) x.csi, D);
fh = figure('color','w','Position',[100 100 350 150]);
subplot(1,2,1);
hold on;
histogram(csi, 15, 'Normalization', 'probability',...
'EdgeColor', 'k', 'EdgeAlpha', 1, 'FaceColor', 'none', 'FaceAlpha', 0);
xlabel('CSI (s)')
ylabel('Probability')
%% Fig 2H (left panel)
subj = cellfun(@(x) x.subj, D, 'uni', 0);
cond_switch = cellfun(@(x) x.cond_switch, D);
coh = cellfun(@(x) x.coh, D);
resp = cellfun(@(x) x.resp, D);
rt = cellfun(@(x) x.rt, D);
csi = cellfun(@(x) x.csi, D);
I = csi<=0.72;
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
opt.color = {'k', 'r'};
opt.legend = {'Non-switch', 'Switch'};
opt.xlabel = {'Task axis', '(% Morph)'};
opt.ylim = [0.6, 1.6];
run_show_choiceRT(cond_switch(I), coh(I), resp(I), rt(I), subj(I), opt);
%% Fig 2H (right panel)
subj = cellfun(@(x) x.subj, D, 'uni', 0);
cond_switch = cellfun(@(x) x.cond_switch, D);
coh = cellfun(@(x) x.coh, D);
resp = cellfun(@(x) x.resp, D);
rt = cellfun(@(x) x.rt, D);
csi = cellfun(@(x) x.csi, D);
I = csi>0.72;
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
opt.color = {'k', 'r'};
opt.legend = {'Non-switch', 'Switch'};
opt.xlabel = {'Task axis', '(% Morph)'};
opt.ylim = [0.6, 1.6];
run_show_choiceRT(cond_switch(I), coh(I), resp(I), rt(I), subj(I), opt);
%% Fig 2I
subj = cellfun(@(x) x.subj, D, 'uni', 0);
cond_switch = cellfun(@(x) x.cond_switch, D);
rt = cellfun(@(x) x.rt, D);
csi = cellfun(@(x) x.csi, D);
coh = cellfun(@(x) x.coh, D);
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
opt.ylim = [0 0.4];
opt.nbin = 7;
opt.plot_idv = 0;
run_show_drt_csi(cond_switch, coh, csi, rt, subj, opt);
%% Fig 2J (upper panels)
subj = cellfun(@(x) x.subj, D, 'uni', 0);
morph_flip = cellfun(@(x) x.morph_flip, D, 'uni', 0);
cond = cellfun(@(x) x.cond, D);
resp2_nonflip = cellfun(@(x) x.resp_nonflip==2, D);
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
run_show_heatmap(resp2_nonflip, morph_flip, cond, subj, opt);
%% Fig 2J (lower panels)
subj = cellfun(@(x) x.subj, D, 'uni', 0);
morph_flip = cellfun(@(x) x.morph_flip, D, 'uni', 0);
cond = cellfun(@(x) x.cond, D);
rt = cellfun(@(x) x.rt, D);
clear opt
opt.subj_list = {'002','005','007','008','012','013','010','014'};
run_show_heatmap(rt, morph_flip, cond, subj, opt);