-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
68 lines (55 loc) · 2.07 KB
/
main.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
function main(varargin)
%% collect input
% use the inputParser class to deal with arguments
ip = inputParser;
%#ok<*NVREPL> dont warn about addParamValue
addParamValue(ip,'subject', 0, @isnumeric);
addParamValue(ip,'dominantEye', 'right', @(x) sum(strcmp(x, {'left','right'}))==1);
addParamValue(ip,'debugLevel', 0, @(x) isnumeric(x) && x >= 0);
addParamValue(ip,'responder', 'user', @(x) sum(strcmp(x, {'user','simpleKeypressRobot'}))==1)
addParamValue(ip,'experiments', [1,1,1], @(x) length(x)==3)
parse(ip,varargin{:});
input = ip.Results;
%% setup
[constants, input, exit_stat] = setupConstants(input, ip);
if exit_stat==1
windowCleanup(constants);
return
end
getDemographics(constants);
try
PsychDefaultSetup(2);
window = setupWindow(constants);
[mondrians, window] = makeMondrianTexes(window);
responseHandler = makeInputHandlerFcn(input.responder);
ListenChar(-1);
HideCursor;
if input.experiments(1)
%% assess occular dominance
[data, tInfo, expParams, input] = runOccularDominance(input, constants, window, responseHandler, mondrians);
domEye = checkOccularDominanceData(data);
% save data
% end of the experiment
expt = 'occularDominance';
structureCleanup(expt, input.subject, data, constants, tInfo, expParams);
else
domEye = input.dominantEye;
end
%% calibrate appropriate contrast for this participant
[data, tInfo, expParams, input, sa] =...
runStaircase( input, constants, window, responseHandler, mondrians, domEye);
% save data
expt = 'staircase';
structureCleanup(expt, input.subject, data, constants, tInfo, expParams, input, sa);
%% run main experiment
[data, tInfo, expParams, input, sa] =...
runCFSRecall(input, constants, window, responseHandler, mondrians, domEye, sa);
% save data
expt = 'CFSRecall';
structureCleanup(expt, input.subject, data, constants, tInfo, expParams, input, sa);
windowCleanup(constants);
catch
psychrethrow(psychlasterror);
windowCleanup(constants);
end
end