-
Notifications
You must be signed in to change notification settings - Fork 4
/
runReadingChildren.m
206 lines (199 loc) · 6.5 KB
/
runReadingChildren.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
% MATLAB script to run CriticalSpacing.m
% Copyright 2019, Denis G. Pelli, [email protected]
mainFolder=fileparts(mfilename('fullpath')); % Takes 0.1 s.
addpath(fullfile(mainFolder,'lib')); % Folder in same directory as this M file.
%% DEFINE CONDITIONS
clear o ooo
% o.useFractionOfScreenToDebug=0.3; %% ONLY FOR DEBUGGING
% o.skipScreenCalibration=true; %% ONLY FOR DEBUGGING
% o.printSizeAndSpacing=true;
o.experiment='Reading';
o.experimenter='';
o.observer='';
o.viewingDistanceCm=100;
o.useSpeech=false;
o.speakViewingDistance=false;
o.setNearPointEccentricityTo='fixation';
o.nearPointXYInUnitSquare=[0.5 0.5]; % location on screen. [0 0] lower left, [1 1] upper right.
o.durationSec=0.15; % duration of display of target and flankers
o.getAlphabetFromDisk=true;
o.trialsDesired=40;
o.readSpacingDeg=nan;
o.spacingDeg=nan;
o.fixationThicknessDeg=0.03;
o.fixationMarkDeg=3;
o.isFixationBlankedNearTarget=false;
o.brightnessSetting=0.87; % Half luminance. Some observers find 1.0 painfully bright.
o.readLines=12;
o.readCharPerLine=50;
o.screen=0;
ooo={};
if true
o.conditionName='reading';
o.readFilename='FirstGradeTexts.txt';
o.task='read';
o.thresholdParameter='spacing';
o.targetFont='Monaco';
o.targetDeg=nan;
o.getAlphabetFromDisk=false;
o.trialsDesired=2;
o.minimumTargetPix=8;
o.eccentricityXYDeg=[0 0];
% The reading test fills a 15" MacBook Pro screen with 1 deg letters at
% 50 cm. Larger letters require proportionally smaller viewing
% distance.
o.viewingDistanceCm=18;
o.alphabet='abc';
o.borderLetter='x';
o.flankingDirection='horizontal';
o.useFixation=false;
o.readSpacingDeg=2;
ooo{end+1}=o;
o.readSpacingDeg=1;
ooo{end+1}=o;
o.viewingDistanceCm=100;
o.readSpacingDeg=0.5;
ooo{end+1}=o;
o.readSpacingDeg=0.25;
ooo{end+1}=o;
end
if 1
for ecc=[ 2.5 ]
o.conditionName='crowding';
o.task='identify';
o.trialsDesired=30;
o.targetDeg=2;
o.spacingDeg=2;
o.thresholdParameter='spacing';
o.eccentricityXYDeg=[ecc 0]; % Distance of target from fixation. Positive up and to right.
o.targetFont='Sloan';
o.getAlphabetFromDisk=true;
o.alphabet='DHKNORSVZ'; % Sloan alphabet, excluding C
o.borderLetter='X';
o.minimumTargetPix=8;
o.fixationThicknessDeg=0.03;
o.fixationMarkDeg=1; % 0, 3, and inf are typical values.
o.isFixationBlankedNearTarget=false;
o.flankingDirection='radial';
o.viewingDistanceCm=100;
o2=o; % Copy the condition
o2.eccentricityXYDeg=-o.eccentricityXYDeg;
ooo{end+1}=[o o2];
end
end
if 0
for ecc=[0 5]
o.conditionName='acuity';
o.targetDeg=4;
o.thresholdParameter='size';
o.eccentricityXYDeg=[ecc 0]; % Distance of target from fixation. Positive up and to right.
o.targetFont='Sloan';
o.getAlphabetFromDisk=true;
o.alphabet='DHKNORSVZ'; % Sloan alphabet, excluding C
o.borderLetter='X';
if ecc>0
o.fixationThicknessDeg=0.03;
o.fixationMarkDeg=1; % 0, 3, and inf are typical values.
o.isFixationBlankedNearTarget=false;
o.flankingDirection='radial';
o.viewingDistanceCm=100;
else
o.fixationThicknessDeg=0.02;
o.fixationMarkDeg=inf; % 0, 3, and inf are typical values.
o.isFixationBlankedNearTarget=true;
o.flankingDirection='horizontal';
o.viewingDistanceCm=100;
end
o2=o; % Copy the condition
o2.eccentricityXYDeg=-o.eccentricityXYDeg;
ooo{end+1}=[o o2];
end
end
if 1
for ecc=0
o.conditionName='crowding';
o.targetDeg=2;
o.spacingDeg=2;
o.thresholdParameter='spacing';
o.eccentricityXYDeg=[ecc 0]; % Distance of target from fixation. Positive up and to right.
o.targetFont='Pelli';
o.getAlphabetFromDisk=true;
o.alphabet='123456789';
o.borderLetter='$';
o.minimumTargetPix=4;
o.fixationThicknessDeg=0.02;
o.fixationMarkDeg=40; % 0, 3, and inf are typical values.
o.isFixationBlankedNearTarget=true;
o.flankingDirection='horizontal';
o.viewingDistanceCm=250;
o2=o; % Copy the condition
o2.eccentricityXYDeg=-o.eccentricityXYDeg;
ooo{end+1}=[o o2];
end
end
if rand>0.5
% ooo=fliplr(ooo);
end
% Adjust viewing distance so text fits on screen.
for block=1:length(ooo)
for oi=1:length(ooo{block})
o=ooo{block}(oi);
switch o.task
case 'read'
o.readLines=12;
o.readCharPerLine=50;
o.screen=0;
maxViewingDistanceCm=MaxViewingDistanceCmForReading(o);
if o.viewingDistanceCm>maxViewingDistanceCm
fprintf('Block %f. Reducing viewing distance from %.0f to %.0f cm.\n',...
block,o.viewingDistanceCm,maxViewingDistanceCm);
o.viewingDistanceCm=maxViewingDistanceCm;
end
ooo{block}(oi)=o;
end
end
end
%% Number the blocks.
for block=1:length(ooo)
for oi=1:length(ooo{block})
ooo{block}(oi).block=block;
ooo{block}(oi).blocksDesired=length(ooo);
end
end
% ooo=Shuffle(ooo);
%% Print as a table. One row per threshold.
for block=1:length(ooo)
if block==1
oo=ooo{1};
else
try
oo=[oo ooo{block}];
catch e
fprintf('Success with %d conditions in %d blocks, but failed on next block.\n',...
length(oo),max([oo.block]));
throw(e)
end
end
end
t=struct2table(oo,'AsArray',true);
% Print the conditions in the Command Window.
disp(t(:,{'block' 'experiment' 'conditionName' 'trialsDesired' 'targetFont' ...
'readSpacingDeg' 'eccentricityXYDeg' 'viewingDistanceCm'}));
trials=sum([oo.trialsDesired]);
fprintf('Total of %d trials, which may take about %.0f minutes. But reading trials take longer.\n',trials,trials/10);
% return
%% Run.
for block=1:length(ooo)
if isempty(ooo{block}(1).experimenter) && block>1
[ooo{block}.experimenter]=deal(ooo{block-1}(1).experimenter);
end
if isempty(ooo{block}(1).observer) && block>1
[ooo{block}.observer]=deal(ooo{block-1}(1).observer);
end
[ooo{block}.isFirstBlock]=deal(block==1);
[ooo{block}.isLastBlock]=deal(block==length(ooo));
ooo{block}=CriticalSpacing(ooo{block});
if any([ooo{block}.quitExperiment])
break
end
end