-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwriteCaption.m
206 lines (194 loc) · 8.05 KB
/
writeCaption.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
function img = writeCaption(mapSet, img, type)
%WRITECAPTION Add a caption for the image
settings;
text = vision.TextInserter('%s', 'LocationSource', 'Input port', 'Color', ...
[255, 255, 255], 'FontSize', 18);
if strcmp(DISTINGUISH, '') && RENDER == OBJECT
locs = int32([ ...
10, 690; ...
10, 720; ...
10, 750; ...
10, 780; ...
10, 810 ...
]);
elseif ~strcmp(DISTINGUISH, '') && RENDER == OBJECT
locs = int32([ ...
10, 1150; ...
10, 1200; ...
10, 1250; ...
10, 1300; ...
10, 1350; ...
10, 1400; ...
10, 1450; ...
10, 1500; ...
1024, 1150; ...
1024, 1200; ...
1024, 1250; ...
1024, 1300; ...
1024, 1350; ...
1024, 1400; ...
1024, 1450; ...
1024, 1500 ...
]);
else
locs = int32([ ...
10, 1150; ...
10, 1200; ...
10, 1250; ...
10, 1300; ...
10, 1350; ...
10, 1400; ...
10, 1450; ...
10, 1500 ...
]);
end
if RENDER ~= OBJECT
if mapSet(1).isSame
type = 'Same';
else
type = 'Different';
end
if mapSet(1).key == 'z'
answer = 'Same';
elseif mapSet(1).key == 'm'
answer = 'Different';
end
end
if strcmp(DISTINGUISH, '') || RENDER == TRIAL
mapSetSize = size(mapSet, 2);
fixData = cat(1, [], mapSet(1:mapSetSize).fixData);
fixDur = fixData(:, 2);
percentCorrect = size(find([mapSet.isCorrect] == true), 2) / mapSetSize;
maxFix = round(max(fixDur));
minFix = round(min(fixDur));
totalDur = round(sum(fixDur));
totalFix = size(fixDur, 1);
elseif ~strcmp(DISTINGUISH, '')
if RENDER == OBJECT
option = [true, false];
for i = 1:size(option, 2)
if strcmp(DISTINGUISH, 'correct')
index = find([mapSet.isCorrect] == option(i));
elseif strcmp(DISTINGUISH, 'same')
index = find([mapSet.isSame] == option(i));
end
subset{i} = mapSet(index);
end
for i = 1:size(subset, 2)
subsetSize = size(subset{i}, 2);
fixData = cat(1, [], subset{i}(1:subsetSize).fixData);
if size(fixData, 1) ~= 0
fixDur = fixData(:, 2);
percentCorrect{i} = size(find([subset{i}.isCorrect] == true), 2) / subsetSize;
maxFix{i} = round(max(fixDur));
minFix{i} = round(min(fixDur));
totalDur{i} = round(sum(fixDur));
totalFix{i} = size(fixDur, 1);
else
fixDur = 0;
percentCorrect{i} = 0.0;
maxFix{i} = 0;
minFix{i} = 0;
totalDur{i} = 0;
totalFix{i} = 0;
end
end
elseif RENDER == PAIR
if strcmp(DISTINGUISH, 'correct')
index = find([mapSet.isCorrect] == true);
elseif strcmp(DISTINGUISH, 'incorrect')
index = find([mapSet.isCorrect] == false);
end
subset = mapSet(index);
subsetSize = size(subset, 2);
fixData = cat(1, [], subset(1:subsetSize).fixData);
if size(fixData, 1) == 0
percentCorrect = 0.0;
maxFix = 0;
minFix = 0;
totalDur = 0;
totalFix = 0;
else
fixDur = fixData(:, 2);
percentCorrect = size(find([subset.isCorrect] == true), 2) / subsetSize;
maxFix = round(max(fixDur));
minFix = round(min(fixDur));
totalDur = round(sum(fixDur));
totalFix = size(fixDur, 1);
end
end
end
clear mapSetSize fixData fixDur option index subset subsetSize;
switch RENDER
case TRIAL
strings = uint8([ ...
['Object Set: ', int2str(mapSet(1).objectSet), '_', int2str(mapSet(1).leftObject), ...
'_', int2str(mapSet(1).rightObject)], 0, ...
['Type: ', type], 0, ...
['Answer: ', answer], 0, ...
['Eye: ', mapSet(1).eye], 0, ...
['Total Time: ', int2str(mapSet(1).rt)], 0, ...
['Maximum Fixation: ', int2str(maxFix)], 0, ...
['Minimum Fixation: ', int2str(minFix)], 0, ...
['Total Fixations: ', int2str(mapSet(1).totalFix)] ...
]);
case PAIR
strings = uint8([ ...
['Object Set: ', int2str(mapSet(1).objectSet), '_' , int2str(mapSet(1).leftObject), ...
'_', int2str(mapSet(1).rightObject)], 0, ...
['Type: ', type], 0, ...
['Percent Correct: ', int2str(percentCorrect * 100), '%'], 0, ...
['Eye: ', mapSet(1).eye], 0, ...
['Total Time: ', int2str(totalDur)], 0, ...
['Maximum Fixation: ', int2str(maxFix)], 0, ...
['Minimum Fixation: ', int2str(minFix)], 0, ...
['Total Fixations: ', int2str(totalFix)] ...
]);
case OBJECT
if strcmp(DISTINGUISH, '')
strings = uint8([ ...
['Eye: ', mapSet(1).eye], 0, ...
['Total Time: ', int2str(totalDur)], 0, ...
['Maximum Fixation: ', int2str(maxFix)], 0, ...
['Minimum Fixation: ', int2str(minFix)], 0, ...
['Total Fixations: ', int2str(totalFix)] ...
]);
else
if strcmp(type, 'LEFT')
object = int2str(mapSet(1).leftObject);
elseif strcmp(type, 'RIGHT')
object = int2str(mapSet(1).rightObject);
elseif strcmp(type, 'EITHER')
object = int2str(mapSet(1).leftObject);
end
if strcmp(DISTINGUISH, 'correct')
dist1 = '_correct';
dist2 = '_incorrect';
elseif strcmp(DISTINGUISH, 'same')
dist1 = '_same';
dist2 = '_different';
end
strings = uint8([ ...
['Object Set: ', int2str(mapSet(1).objectSet), object, dist1], 0, ...
['Type: ', type], 0, ...
['Percent Correct: ', int2str(percentCorrect{1} * 100), '%'], 0, ...
['Eye: ', mapSet(1).eye], 0, ...
['Total Time: ', int2str(totalDur{1})], 0, ...
['Maximum Fixation: ', int2str(maxFix{1})], 0, ...
['Minimum Fixation: ', int2str(minFix{1})], 0, ...
['Total Fixations: ', int2str(totalFix{1})], 0, ...
['Object Set: ', int2str(mapSet(1).objectSet), object, dist2], 0, ...
['Type: ', type], 0, ...
['Percent Correct: ', int2str(percentCorrect{2} * 100), '%'], 0, ...
['Eye: ', mapSet(1).eye], 0, ...
['Total Time: ', int2str(totalDur{2})], 0, ...
['Maximum Fixation: ', int2str(maxFix{2})], 0, ...
['Minimum Fixation: ', int2str(minFix{2})], 0, ...
['Total Fixations: ', int2str(totalFix{2})], 0, ...
]);
end
clear object dist1 dist2;
end
img = step(text, img, strings, locs);
clear mapSet type text strings locs;
end