-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccuracyPlots.m
354 lines (218 loc) · 11.6 KB
/
AccuracyPlots.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
% this script plots accuracy bars
clear
clc
addpath('./')
configIrrelevant;
cd(processedDataComb)
addpath(genpath(processedDataComb));
% load binomial table for accuracy values & p values
load("binomialTables.mat");
binom = binomialTables;
%set chance level & p value
ChanceLevel = 0.5;
PValue = 0.05;
%Accuracy plot Values
%object surprise
objectAccuracy = [binom.criticalObjectOrientation(1),binom.criticalObjectDuration(1)]; % first value is the accuracy
objectPvalues = [binom.criticalObjectOrientation(4),binom.criticalObjectDuration(4)]; %forth value is the P value
%confidence intervals for error bars
%lowerBoundObjectOrientation = binom.criticalObjectOrientation(2);
%upperBoundObjectOrientation = binom.criticalObjectOrientation(3);
%lowerBoundObjectDuration = binom.criticalObjectDuration(2);
%upperBoundObjectDuration = binom.criticalObjectDuration(3);
%ObjectConfidenceIntervals = [lowerBoundObjectOrientation,upperBoundObjectOrientation;lowerBoundObjectDuration,upperBoundObjectDuration];
%face surprise
faceAccuracy = [binom.criticalFaceOrientation(1),binom.criticalFaceDuration(1)];
facePvalues = [binom.criticalFaceOrientation(4),binom.criticalFaceDuration(4)];
%lowerBoundFaceOrientation = binom.criticalFaceOrientation(2);
%upperBoundFaceOrientation = binom.criticalFaceOrientation(3);
%lowerBoundFaceDuration = binom.criticalFaceDuration(2);
%upperBoundFaceDuration = binom.criticalFaceDuration(3);
%FaceConfidenceIntervals = [lowerBoundFaceOrientation,upperBoundFaceOrientation;lowerBoundFaceDuration,upperBoundFaceDuration];
% surprise trial plot
BarAccuracy = [objectAccuracy; faceAccuracy]';
BarColors = [repmat(objectColor, 2, 1); repmat(faceColor, 2, 1)];
fig = figure; % figure for the subplots
AccuracyPlot = bar(BarAccuracy, 'grouped');
hold on;
AccuracyPlot(1).FaceColor = objectColor;
AccuracyPlot(2).FaceColor = faceColor;
% set the length for the error bars
%lowerBoundObject = objectAccuracy - ObjectConfidenceIntervals(:, 1)'; % error bar lengths
%upperBoundObject = ObjectConfidenceIntervals(:, 2)' - objectAccuracy;
%lowerBoundFace = faceAccuracy - FaceConfidenceIntervals(:, 1)';
%upperBoundFace = FaceConfidenceIntervals(:, 2)' - faceAccuracy;
%errorbar([1-0.15, 2-0.15], objectAccuracy, lowerBoundObject, upperBoundObject, 'k', 'LineStyle', 'none', 'LineWidth', 1); %error bars for object
%errorbar([1+0.15, 2+0.15], faceAccuracy, lowerBoundFace, upperBoundFace, 'k', 'LineStyle', 'none', 'LineWidth', 1); %error bars for face
yline(ChanceLevel, '--k'); % add the line to the chance level
yticks([0, 0.5, 1]);
ylim([0,1]);
ylabel('Accuracy','FontWeight','bold','FontSize', 14); % add labels and titles
xlabel('Probe','FontWeight','bold','FontSize', 14);
title('Surprise Trial Probe Accuracy','FontSize', 16);
ax = gca; % Get the current axes
ax.XTickLabel = {'Orientation', 'Duration'}; % Set the xticklabels
ax.FontSize = 12; % Adjust the font size as needed
ax.FontName = 'Arial';
% add asterisks for significant values
Astoffset = 0.2; % asterisks ofset to decide the placement of it
for i = 1:numel(objectAccuracy) % number of values are same for the object and face
% object P value
if objectPvalues(i) < PValue
text(i-0.35 - Astoffset, objectAccuracy(i) -0.05, '*', 'FontSize', 25, 'HorizontalAlignment', 'center');
end
% face p-value
if facePvalues(i) < PValue
text(i+0.35 - Astoffset, faceAccuracy(i)-0.05, '*', 'FontSize', 25, 'HorizontalAlignment', 'center');
end
end
legend('Object', 'Face', 'Location', 'northeast', 'Position', [0.81, 0.86, 0.05, 0.05]);
hold off;
%% Post-surprise bars
%object post (first control)
objectPostAccuracy = [binom.postObjectOrientation1(1),binom.postObjectDuration1(1)];
objectPostPvalues = [binom.postObjectOrientation1(4),binom.postObjectDuration1(4)];
%PostlowerBoundObjectOrientation = binom.postObjectOrientation1(2);
%PostupperBoundObjectOrientation = binom.postObjectOrientation1(3);
%PostlowerBoundObjectDuration = binom.postObjectDuration1(2);
%PostupperBoundObjectDuration = binom.postObjectDuration1(3);
%PostObjectConfidenceIntervals = [PostlowerBoundObjectOrientation,PostupperBoundObjectOrientation;PostlowerBoundObjectDuration,PostupperBoundObjectDuration];
%face post (first control)
facePostAccuracy = [binom.postFaceOrientation1(1),binom.postFaceDuration1(1)];
facePostPvalues = [binom.postFaceOrientation1(4),binom.postFaceDuration1(4)];
%PostlowerBoundFaceOrientation = binom.postFaceOrientation1(2);
%PostupperBoundFaceOrientation = binom.postFaceOrientation1(3);
%PostlowerBoundFaceDuration = binom.postFaceDuration1(2);
%PostupperBoundFaceDuration = binom.postFaceDuration1(3);
%PostFaceConfidenceIntervals = [PostlowerBoundFaceOrientation,PostupperBoundFaceOrientation;PostlowerBoundFaceDuration,PostupperBoundFaceDuration];
%plot the post-surprise bars
PostBarAccuracy = [objectPostAccuracy; facePostAccuracy]';
BarColors = [repmat(objectColor, 2, 1); repmat(faceColor, 2, 1)];
figure; % figure for the subplots
PostAccuracyPlot = bar(PostBarAccuracy, 'grouped');
hold on;
PostAccuracyPlot(1).FaceColor = objectColor;
PostAccuracyPlot(2).FaceColor = faceColor;
% set the length for the error bars
%PostlowerBoundObject = objectPostAccuracy - PostObjectConfidenceIntervals(:, 1)'; % error bar lengths
%PostupperBoundObject = PostObjectConfidenceIntervals(:, 2)' - objectPostAccuracy;
%PostlowerBoundFace = facePostAccuracy - PostFaceConfidenceIntervals(:, 1)';
%PostupperBoundFace = PostFaceConfidenceIntervals(:, 2)' - facePostAccuracy;
%errorbar([1-0.15, 2-0.15], objectPostAccuracy, PostlowerBoundObject, PostupperBoundObject, 'k', 'LineStyle', 'none', 'LineWidth', 1); %error bars for object
%errorbar([1+0.15, 2+0.15], facePostAccuracy, PostlowerBoundFace,PostupperBoundFace, 'k', 'LineStyle', 'none', 'LineWidth', 1); %error bars for face
yline(ChanceLevel, '--k'); % add the line to the chance level
ylim([0 1]);
yticks([0, 0.5, 1]);
ylabel('Accuracy','FontWeight','bold','FontSize', 14); % add labels and titles
xlabel('Probe','FontWeight','bold','FontSize', 14);
title('First Control Probe Accuracy','FontSize', 16);
ax = gca; % Get the current axes
ax.XTickLabel = {'Orientation', 'Duration'}; % Set the xticklabels
ax.FontSize = 12; % Adjust the font size as needed
ax.FontName = 'Arial'; % Set the font name
% add asterisks for significant values
Astoffset = 0.1; % asterisks ofset to decide the placement of it
for i = 1:numel(objectPostAccuracy)
if objectPostPvalues(i) < PValue
text(i-0.05 - Astoffset, objectPostAccuracy(i) - 0.05, '*', 'FontSize', 25, 'HorizontalAlignment', 'center');
end
% face p-value
if facePostPvalues(i) < PValue
text(i+0.25 - Astoffset, facePostAccuracy(i) - 0.05, '*', 'FontSize', 25, 'HorizontalAlignment', 'center');
end
end
legend('Object', 'Face', 'Location', 'northeast', 'Position', [0.81, 0.86, 0.05, 0.05]);
hold off;
%% combined accuracy
combinedSurprise = [binom.criticalOrientation(1),binom.criticalDuration(1)];
combinedControl = [binom.postOrientation1(1),binom.postDuration1(1)];
surprisePvalues = [binom.criticalOrientation(4),binom.criticalDuration(4)];
controlPvalues =[binom.postOrientation1(4),binom.postDuration1(4)];
% get the confidence intervals
% lowerBoundOrientation = binom.criticalOrientation(2);
% upperBoundOrientation = binom.criticalOrientation(3);
% lowerBoundDuration = binom.criticalDuration(2);
% upperBoundDuration = binom.criticalDuration(3);
%TotalConfidenceIntervals = [lowerBoundOrientation,upperBoundOrientation;lowerBoundDuration,upperBoundDuration];
% postLowerBoundOrientation = binom.postOrientation1(2);
% postUpperBoundOrientation = binom.postOrientation1(3);
% postLowerBoundDuration = binom.postDuration1(2);
% postUpperBoundDuration = binom.postDuration1(3);
%postTotalConfidenceIntervals = [postLowerBoundOrientation,postUpperBoundOrientation;postLowerBoundDuration,postUpperBoundDuration];
BarCombinedAccuracy = [combinedSurprise;combinedControl]';
BarColors = [repmat(surpriseColor, 2, 1); repmat(postColor, 2, 1)];
figure;
AccuracyCombinedPlot = bar(BarCombinedAccuracy,'grouped');
hold on;
%set the colors
AccuracyCombinedPlot(1).FaceColor = surpriseColor;
AccuracyCombinedPlot(2).FaceColor = postColor;
% set the length of the error bars
% lowerBoundSurpriseL = combinedSurprise - TotalConfidenceIntervals(:, 1)';
% upperBoundsupriseL = TotalConfidenceIntervals(:, 2)' - combinedSurprise;
% lowerBoundPostL = combinedControl - postTotalConfidenceIntervals(:, 1)';
% upperBoundPostL = postTotalConfidenceIntervals(:, 2)' - combinedControl;
%errorbar([1-0.15, 2-0.15], combinedSurprise,lowerBoundSurpriseL,upperBoundsupriseL, 'k', 'LineStyle', 'none', 'LineWidth', 1); % surprise
%errorbar([1+0.15, 2+0.15], combinedControl, lowerBoundPostL,upperBoundPostL, 'k', 'LineStyle', 'none', 'LineWidth', 1);
yline(ChanceLevel, '--k'); % add the line to the chance level
ylim([0 1])
yticks([0 0.5 1]);
ylabel('Accuracy','FontWeight','bold','FontSize', 14); % add labels and titles
xlabel('Probe','FontWeight','bold','FontSize', 14);
title('Surprise and First Control Probe Accuracy','FontSize', 16);
ax = gca; % Get the current axes
ax.XTickLabel = {'Orientation', 'Duration'}; % Set the xticklabels
ax.FontSize = 12; % Adjust the font size as needed
ax.FontName = 'Arial'; % Set the font name (change 'Arial' to your desired font)
% add asterisks for significant values
Astoffset = 0.1; % asterisks ofset to decide the placement of it
for i = 1:numel(combinedSurprise)
if surprisePvalues(i) < PValue
text(i-0.05 - Astoffset, combinedSurprise(i) - 0.05, '*', 'FontSize', 25, 'HorizontalAlignment', 'center');
end
% face p-value
if controlPvalues(i) < PValue
text(i+0.25 - Astoffset, combinedControl(i) - 0.05, '*', 'FontSize', 25, 'HorizontalAlignment', 'center');
end
end
% add legends
legend('Surprise', 'Post Surprise', 'Location', 'northeast');
hold off;
%% Order effect accuracy plots
% load order effect data
accuracyOrientation = [binom.orientationFirst(1),binom.orientationSecond(1)];
accuracyDuration = [binom.durationFirst(1),binom.durationSecond(1)];
orientationPvalues = [binom.orientationFirst(4),binom.orientationSecond(4)];
durationPvalues = [binom.durationFirst(4),binom.durationSecond(4)];
BarOrderAccuracy = [accuracyOrientation;accuracyDuration];
BarColors = [repmat(probedFirstColor, 2, 1); repmat(probedSecondColor, 2, 1)];
figure;
AccuracyOrderPlot = bar(BarOrderAccuracy,'grouped');
hold on;
%set the colors
AccuracyOrderPlot(1).FaceColor = probedFirstColor;
AccuracyOrderPlot(2).FaceColor = probedSecondColor;
%plot orientation order effect
yline(ChanceLevel, '--k'); % add the line to the chance level
ylim([0 1])
yticks([0 0.5 1]);
ylabel('Accuracy','FontWeight','bold','FontSize', 14); % add labels and titles
xlabel('Probe','FontWeight','bold','FontSize', 14);
title('Surprise Trial Probe Accuracy and Order Effect','FontSize', 16);
ax = gca; % Get the current axes
ax.XTickLabel = {'Orientation', 'Duration'}; % Set the xticklabels
ax.FontSize = 12; % Adjust the font size as needed
ax.FontName = 'Arial'; % Set the font name (change 'Arial' to your desired font)
Astoffset = 0.1; % asterisks ofset to decide the placement of it
for i = 1:numel(accuracyOrientation)
if orientationPvalues(i) < PValue
text(i-0.05 - Astoffset,accuracyOrientation(i) + 0.05, '*', 'FontSize', 25, 'HorizontalAlignment', 'center');
end
end
for i = 1:numel(accuracyDuration)
if durationPvalues(i) < PValue
text(i+0.25 - Astoffset,accuracyDuration(i) + 0.05, '*', 'FontSize', 25, 'HorizontalAlignment', 'center');
end
end
legend('Probed first', 'Probed second', 'Location', 'northeast');
hold off;