-
Notifications
You must be signed in to change notification settings - Fork 0
/
EyelinkTestExperiment_experiment.m
122 lines (89 loc) · 3.91 KB
/
EyelinkTestExperiment_experiment.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
% EyelinkTestExperiment_experiment.m - A simple test experiment for learning how to work with the Eyelink
% equipment.
%
% Make sure the Eyelink host computer is turned on and running the eyelink
% program before running this script or it will error out.
%
% Author: Brian Armstrong
%
% import our lab's custom package so we can use its functions.
import cog_comm_tools.*;
% font settings
fontFace = 'Arial';
fontSize = 30;
fontStyle = 1;
% constants
waitTime = 2.00;
dt = 0.5;
screenPadding = 20;
% here we are specifying what screen resolution we want
screenResolution = [1152 864];
% a try block 'tries' a block of code and if an exception occurs it will jump to the following catch block
try
% SETUP EXPERIMENT
% assert that what we need is installed and working
initializeExperiment();
% initilize the window, set font style, unify keyboard for various OS
[window, resolution] = initializeWindow( fontFace, fontSize, fontStyle, screenResolution);
participantId = 'exampleParticipantId';
% this call initializes and makes a connection to the Eyelink Host
% Computer... returns the eyelink defaults we need for calibration
el = initializeEyelink(window, resolution);
% display some instructions...
displayInstructions(window, 'Please pick up the joystick.',dt,'joystick');
% Calibrate the eye tracker
displayInstructions(window, 'Now we will calibrate the EyeTracker.',dt,'joystick');
EyelinkDoTrackerSetup(el);
% do a final check of calibration using driftcorrection
displayInstructions(window, 'Now we perform a quick Drift Correction.', dt, 'joystick');
EyelinkDoDriftCorrection(el);
displayInstructions(window, 'You will see cross-hairs appear at different\n\npositions on the screen.\n\nJust look at the cross-hairs as they move around. ', dt, 'joystick');
clearWindow(window);
EyelinkOpenFile('elTest.edf');
% The TRIAL
%
% Just want to track the eyes while asking the participant to follow
% the crosshairs on the screen.
% the call that starts recording data...
EyelinkStartRecording();
% give the Eyelink Equipment a chance to start recording
WaitSecs(dt);
% draw the cross hairs on various positions on the screen, and log
% the times when presented. Wait between each draw.
% display the cross hair for the first time...
displayCrossHairsCentered(window);
% mark zero-plot time in data file
EyelinkSyncTime();
WaitSecs(waitTime);
% display the CrossHairs in various positions with delays in between...
displayCrossHairs(window, screenPadding, screenPadding);
WaitSecs(waitTime);
displayCrossHairs(window, resolution.width-screenPadding, resolution.height-screenPadding);
WaitSecs(waitTime);
displayCrossHairsCentered(window);
WaitSecs(waitTime);
displayCrossHairs(window, resolution.width-screenPadding, screenPadding);
WaitSecs(waitTime);
displayCrossHairs(window, screenPadding, resolution.height-screenPadding);
WaitSecs(waitTime);
displayCrossHairsCentered(window);
WaitSecs(waitTime);
% send eyelink host machine command to stop recording...
EyelinkStopRecording();
% blank out the screen...
clearWindow(window);
% transfer the file to the display machine...
EyelinkSaveFile('elTest.edf', participantId);
% end of the TRIAL
displayInstructions(window, 'Experiment Completed... ');
% SHUTDOWN THE EXPERIMENT
shutDownExperiment();
catch
% This "catch" section executes in case of an error in the "try" section above.
% If we encounter an exception, we clean up.
% Clean up.
shutDownExperiment();
% Since we are catching (handling) the error, we want to rethrow it so we can see
% what happened. We only catch it to call shutDownExperiment.
psychrethrow(psychlasterror);
end