Skip to content

Commit 63774ca

Browse files
committed
bug fix with EyeLink
1 parent a870214 commit 63774ca

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

src/cleanUp.m

100644100755
File mode changed.

src/eyeTracker.m

100644100755
Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,55 +63,54 @@
6363

6464
% Get EyeLink setup information.
6565
[el.v, el.vs] = Eyelink('GetTrackerVersion');
66-
66+
fprintf('Running experiment on a ''%s'' tracker.\n', el.vs);
67+
6768
% Save EL setup version in cfg
6869
cfg.eyeTracker.eyeLinkVersionString = el.vs;
6970

70-
fprintf('Running experiment on a ''%s'' tracker.\n', el.vs);
71-
7271
% Make sure that we get gaze data from the Eyelink.
7372
Eyelink('Command', 'link_sample_data = LEFT,RIGHT,GAZE,AREA');
74-
Eyelink('command', 'link_event_data = GAZE,GAZERES,HREF,AREA,VELOCITY');
75-
Eyelink('command', 'link_event_filter = LEFT,RIGHT,FIXATION,BLINK,SACCADE,BUTTON');
73+
Eyelink('Command', 'link_event_data = GAZE,GAZERES,HREF,AREA,VELOCITY');
74+
Eyelink('Command', 'link_event_filter = LEFT,RIGHT,FIXATION,BLINK,SACCADE,BUTTON');
7675

7776
%% Calibration
7877

7978
% This command is crucial to map the gaze positions from the tracker to
8079
% screen pixel positions to determine fixation.
81-
Eyelink('command', 'screen_pixel_coords = %ld %ld %ld %ld', 0, 0, 0, 0);
82-
Eyelink('message', 'DISPLAY_COORDS %ld %ld %ld %ld', 0, 0, 0, 0);
80+
Eyelink('Command', 'screen_pixel_coords = %ld %ld %ld %ld', 0, 0, 0, 0);
81+
Eyelink('Message', 'DISPLAY_COORDS %ld %ld %ld %ld', 0, 0, 0, 0);
8382

8483
% Set calibration type.
85-
Eyelink('command', 'calibration_type = HV5');
86-
84+
Eyelink('Command', 'calibration_type = HV5');
85+
8786
if cfg.eyeTracker.defaultCalibration
8887

8988
% Set default calibration parameters.
90-
Eyelink('command', 'generate_default_targets = YES');
89+
Eyelink('Command', 'generate_default_targets = YES');
9190

9291
else
9392

9493
% Set custom calibration parameters.
95-
Eyelink('command', 'generate_default_targets = NO');
94+
Eyelink('Command', 'generate_default_targets = NO');
9695

9796
% Calibration target locations, set manually the dots
9897
% coordinates, here for 6 dots.
9998

10099
% [width, height]=Screen('WindowSize', screenNumber);
101100

102-
Eyelink('command', 'calibration_samples = 6');
103-
Eyelink('command', 'calibration_sequence = 0,1,2,3,4,5');
104-
Eyelink('command', 'calibration_targets = %d,%d %d,%d %d,%d %d,%d %d,%d', ...
101+
Eyelink('Command', 'calibration_samples = 6');
102+
Eyelink('Command', 'calibration_sequence = 0,1,2,3,4,5');
103+
Eyelink('Command', 'calibration_targets = %d,%d %d,%d %d,%d %d,%d %d,%d', ...
105104
640, 512, ... % width/2,height/2
106105
640, 102, ... % width/2,height*0.1
107106
640, 614, ... % width/2,height*0.6
108107
128, 341, ... % width*0.1,height*1/3
109108
1152, 341); % width-width*0.1,height*1/3
110109

111110
% Validation target locations
112-
Eyelink('command', 'validation_samples = 5');
113-
Eyelink('command', 'validation_sequence = 0,1,2,3,4,5');
114-
Eyelink('command', 'validation_targets = %d,%d %d,%d %d,%d %d,%d %d,%d', ...
111+
Eyelink('Command', 'validation_samples = 5');
112+
Eyelink('Command', 'validation_sequence = 0,1,2,3,4,5');
113+
Eyelink('Command', 'validation_targets = %d,%d %d,%d %d,%d %d,%d %d,%d', ...
115114
640, 512, ... % width/2,height/2
116115
640, 102, ... % width/2,height*0.1
117116
640, 614, ... % width/2,height*0.6
@@ -123,6 +122,8 @@
123122
% Set EDF file contents (not clear what this lines are used for).
124123
el.vsn = regexp(el.vs, '\d', 'match'); % won't work on EL
125124

125+
fprintf('Waiting for calibration \n')
126+
126127
% Enter Eyetracker camera setup mode, calibration and validation.
127128
EyelinkDoTrackerSetup(el);
128129

@@ -226,15 +227,22 @@
226227
% Initialize EL and make sure it worked: returns 0 if OK, -1 if error.
227228
% Exit program if this fails.
228229
elInit = Eyelink('Initialize');
229-
if ELinit ~= 0
230-
error('Eyelink is not initialized, aborted.\n');
230+
if elInit ~= 0
231+
error([newline 'Eyelink is not initialized, aborted.']);
231232
end
232233

233234
% Make sure EL is still connected: returns 1 if connected, -1 if dummy-connected,
234235
% 2 if broadcast-connected and 0 if not connected. Exit program if this fails.
235236
elConnection = Eyelink('IsConnected');
236-
if ELconnection ~= 1
237-
error('Eyelink is not connected, aborted.\n');
237+
if elConnection ~= 1
238+
error([newline 'Eyelink is not connected, aborted.']);
239+
end
240+
241+
% Initialize Eyelink system and connection: returns 1 when succesful, 0
242+
% otherwise
243+
if ~EyelinkInit(0, 1)
244+
fprintf('Eyelink Init aborted.\n');
245+
return
238246
end
239247

240248
end

0 commit comments

Comments
 (0)