|
| 1 | +% Eyelink already initialized! |
| 2 | +% Running experiment on a 'EYELINK CL 4.56 ' tracker. |
| 3 | +% Error in function Open: Usage error |
| 4 | +% Could not find *any* audio hardware on your system - or at least not with the provided deviceid, if any! |
| 5 | +% Error in function FillRect: Invalid Window (or Texture) Index provided: It doesn't correspond to an open window or texture. |
| 6 | +% Did you close it accidentally via Screen('Close') or Screen('CloseAll') ? |
| 7 | +% EYELINK: WARNING! PsychEyelinkCallRuntime() Failed to call eyelink runtime callback function PsychEyelinkDispatchCallback [rc = 1]! |
| 8 | +% EYELINK: WARNING! Make sure that function is on your Matlab/Octave path and properly initialized. |
| 9 | +% EYELINK: WARNING! May also be an error during execution of that function. Type ple at command prompt for error messages. |
| 10 | +% EYELINK: WARNING! Auto-Disabling all callbacks to the runtime environment for safety reasons. |
| 11 | +% Eyelink: In PsychEyelink_get_input_key(): Error condition detected: Trying to send TERMINATE_KEY abort keycode! |
| 12 | + |
| 13 | +% Eyelink: In PsychEyelink_get_input_key(): Error condition detected: Trying to send TERMINATE_KEY abort keycode! |
| 14 | +% Error in function FillRect: Invalid Window (or Texture) Index provided: It doesn't correspond to an open window or texture. |
| 15 | +% Did you close it accidentally via Screen('Close') or Screen('CloseAll') ? |
| 16 | +% Error using Screen |
| 17 | +% Usage: |
| 18 | +% |
| 19 | +% Screen('FillRect', windowPtr [,color] [,rect] ) |
| 20 | +% |
| 21 | +% Error in eyeTracker (line 150) |
| 22 | +% Screen('FillRect', cfg.screen.win, [0 0 0]); |
| 23 | +% |
| 24 | +% Error in visualLocTanslational (line 52) |
| 25 | +% [el] = eyeTracker('Calibration', cfg); |
| 26 | + |
1 | 27 | function [el, edfFile] = eyeTracker(input, cfg, varargin) |
2 | 28 | % [el, edfFile] = eyeTracker(input, cfg, varargin) |
3 | 29 | % |
|
18 | 44 | % and perform some initializations. The information is returned |
19 | 45 | % in a structure that also contains useful defaults |
20 | 46 | % and control codes (e.g. tracker state bit and Eyelink key values). |
21 | | - el = EyelinkInitDefaults(cfg.win); |
| 47 | + el = EyelinkInitDefaults(cfg.screen.win); |
22 | 48 |
|
23 | 49 | % calibration has silver background with black targets, sound and smaller |
24 | 50 | % targets |
25 | | - el.backgroundcolour = [192 192 192, (cfg.win)]; |
26 | | - el.msgfontcolour = BlackIndex(cfg.win); |
27 | | - el.calibrationtargetcolour = BlackIndex(cfg.win); |
| 51 | + el.backgroundcolour = [192 192 192, (cfg.screen.win)]; |
| 52 | + el.msgfontcolour = BlackIndex(cfg.screen.win); |
| 53 | + el.calibrationtargetcolour = BlackIndex(cfg.screen.win); |
28 | 54 | el.calibrationtargetsize = 1; |
29 | 55 | el.calibrationtargetwidth = 0.5; |
30 | 56 | el.displayCalResults = 1; |
|
91 | 117 | % you must send this command with value NO for custom calibration |
92 | 118 | % you must also reset it to YES for subsequent experiments |
93 | 119 | Eyelink('command', 'generate_default_targets = YES'); |
94 | | - % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % |
95 | 120 |
|
96 | | - % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % |
97 | | - % % CUSTOM CALIBRATION |
98 | | - % % (SET MANUALLY THE DOTS COORDINATES, HERE FOR 6 DOTS) |
99 | | - % Eyelink('command', 'calibration_type = HV5'); |
100 | | - % % you must send this command with value NO for custom calibration |
101 | | - % % you must also reset it to YES for subsequent experiments |
102 | | - % Eyelink('command', 'generate_default_targets = NO'); |
103 | | - % |
104 | | - % % calibration and validation target locations |
105 | | - % [width, height]=Screen('WindowSize', screenNumber); |
106 | | - % Eyelink('command','calibration_samples = 6'); |
107 | | - % Eyelink('command','calibration_sequence = 0,1,2,3,4,5'); |
108 | | - % Eyelink('command','calibration_targets = ... |
109 | | - % %d,%d %d,%d %d,%d %d,%d %d,%d',... |
110 | | - % 640,512, ... %width/2,height/2 |
111 | | - % 640,102, ... %width/2,height*0.1 |
112 | | - % 640,614, ... %width/2,height*0.6 |
113 | | - % 128,341, ... %width*0.1,height*1/3 |
114 | | - % 1152,341 ); %width-width*0.1,height*1/3 |
115 | | - % |
116 | | - % Eyelink('command','validation_samples = 5'); |
117 | | - % Eyelink('command','validation_sequence = 0,1,2,3,4,5'); |
118 | | - % Eyelink('command','validation_targets = ... |
119 | | - % %d,%d %d,%d %d,%d %d,%d %d,%d',... |
120 | | - % 640,512, ... %width/2,height/2 |
121 | | - % 640,102, ... %width/2,height*0.1 |
122 | | - % 640,614, ... %width/2,height*0.6 |
123 | | - % 128,341, ... %width*0.1,height*1/3 |
124 | | - % 1152,341 ); %width-width*0.1,height*1/3 |
125 | | - % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % |
| 121 | + % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % |
| 122 | +% |
| 123 | +% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % |
| 124 | +% % CUSTOM CALIBRATION |
| 125 | +% % (SET MANUALLY THE DOTS COORDINATES, HERE FOR 6 DOTS) |
| 126 | +% Eyelink('command', 'calibration_type = HV5'); |
| 127 | +% % you must send this command with value NO for custom calibration |
| 128 | +% % you must also reset it to YES for subsequent experiments |
| 129 | +% Eyelink('command', 'generate_default_targets = NO'); |
| 130 | +% |
| 131 | +% % calibration and validation target locations |
| 132 | +% [width, height]=Screen('WindowSize', screenNumber); |
| 133 | +% Eyelink('command','calibration_samples = 6'); |
| 134 | +% Eyelink('command','calibration_sequence = 0,1,2,3,4,5'); |
| 135 | +% Eyelink('command','calibration_targets = %d,%d %d,%d %d,%d %d,%d %d,%d',... |
| 136 | +% 640,512, ... %width/2,height/2 |
| 137 | +% 640,102, ... %width/2,height*0.1 |
| 138 | +% 640,614, ... %width/2,height*0.6 |
| 139 | +% 128,341, ... %width*0.1,height*1/3 |
| 140 | +% 1152,341 ); %width-width*0.1,height*1/3 |
| 141 | +% |
| 142 | +% Eyelink('command','validation_samples = 5'); |
| 143 | +% Eyelink('command','validation_sequence = 0,1,2,3,4,5'); |
| 144 | +% Eyelink('command','validation_targets = %d,%d %d,%d %d,%d %d,%d %d,%d',... |
| 145 | +% 640,512, ... %width/2,height/2 |
| 146 | +% 640,102, ... %width/2,height*0.1 |
| 147 | +% 640,614, ... %width/2,height*0.6 |
| 148 | +% 128,341, ... %width*0.1,height*1/3 |
| 149 | +% 1152,341 ); %width-width*0.1,height*1/3 |
| 150 | +% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % |
126 | 151 |
|
127 | 152 | % % set parser (conservative saccade thresholds) |
128 | 153 | % Eyelink('command', 'saccade_velocity_threshold = 35'); |
|
134 | 159 | % enter Eyetracker camera setup mode, calibration and validation |
135 | 160 | EyelinkDoTrackerSetup(el); |
136 | 161 |
|
137 | | - % % % do a final check of calibration using driftcorrection |
138 | | - % % % You have to hit esc before return. |
139 | | - % % EyelinkDoDriftCorrection(el); |
140 | | - % |
141 | | - % % % do a final check of calibration using driftcorrection |
142 | | - % % success=EyelinkDoDriftCorrection(el); |
143 | | - % % if success~=1 |
144 | | - % % Eyelink('shutdown'); |
145 | | - % % Screen('CloseAll'); |
146 | | - % % return; |
147 | | - % % end |
| 162 | + % % do a final check of calibration using driftcorrection |
| 163 | + % % You have to hit esc before return. |
| 164 | + % EyelinkDoDriftCorrection(el); |
| 165 | + |
| 166 | + % % do a final check of calibration using driftcorrection |
| 167 | + % success=EyelinkDoDriftCorrection(el); |
| 168 | + % if success~=1 |
| 169 | + % Eyelink('shutdown'); |
| 170 | + % cleanUp() |
| 171 | + % return; |
| 172 | + % end |
148 | 173 |
|
149 | 174 | % Go back to black screen |
150 | | - Screen('FillRect', cfg.win, [0 0 0]); |
151 | | - Screen('Flip', cfg.win); |
| 175 | + Screen('FillRect', cfg.screen.win, [0 0 0]); |
| 176 | + Screen('Flip', cfg.screen.win); |
152 | 177 |
|
153 | 178 | case 'StartRecording' |
154 | 179 |
|
|
191 | 216 |
|
192 | 217 | case 'Shutdown' |
193 | 218 |
|
194 | | - edfFileName = cfg.fileName.eyetracker; |
| 219 | + edfFileName = fullfile( ... |
| 220 | + cfg.dir.outputSubject, ... |
| 221 | + 'eyetracker', ... |
| 222 | + cfg.fileName.eyetracker); |
| 223 | + |
195 | 224 | edfFile = 'demo.edf'; |
196 | 225 |
|
197 | 226 | % STEP 6 |
|
205 | 234 | % download data file |
206 | 235 | try |
207 | 236 | fprintf('Receiving data file ''%s''\n', edfFileName); |
208 | | - status = Eyelink('ReceiveFile', '', ... |
209 | | - [cfg.outputDir, filesep, 'eyetracker', filesep, edfFileName]); |
| 237 | + |
| 238 | + status = Eyelink('ReceiveFile', '', edfFileName); |
| 239 | + |
210 | 240 | if status > 0 |
211 | 241 | fprintf('ReceiveFile status %d\n', status); |
212 | 242 | end |
213 | | - if 2 == exist([cfg.outputDir, filesep, 'eyetracker', ... |
214 | | - filesep, edfFileName], 'file') |
215 | | - fprintf('Data file ''%s'' can be found in ''%s''\n', edfFileName, ... |
216 | | - [cfg.outputDir, filesep, 'eyetracker', filesep]); |
| 243 | + |
| 244 | + if 2 == exist(edfFileName, 'file') |
| 245 | + |
| 246 | + fprintf('Data file ''%s'' can be found in ''%s''\n', ... |
| 247 | + cfg.fileName.eyetracker, ... |
| 248 | + fullfile(cfg.dir.outputSubject, 'eyetracker')); |
| 249 | + |
217 | 250 | end |
| 251 | + |
218 | 252 | catch |
| 253 | + |
219 | 254 | fprintf('Problem receiving data file ''%s''\n', edfFileName); |
| 255 | + |
220 | 256 | end |
221 | 257 |
|
222 | 258 | Eyelink('shutdown'); |
|
229 | 265 |
|
230 | 266 | %% subfunctions for iView |
231 | 267 |
|
232 | | -function ivx = eyeTrackInit(cfg) |
233 | | - % initialize iView eye tracker |
234 | | - |
235 | | - ivx = []; |
236 | | - |
237 | | - if cfg.eyeTracker |
238 | | - |
239 | | - host = cfg.eyetracker.Host; |
240 | | - port = cfg.eyetracker.Port; |
241 | | - window = cfg.eyetracker.Window; |
242 | | - |
243 | | - % original: ivx=iviewxinitdefaults(window, 9 , host, port); |
244 | | - ivx = iviewxinitdefaults2(window, 9, [], host, port); |
245 | | - ivx.backgroundColour = 0; |
246 | | - [~, ivx] = iViewX('openconnection', ivx); |
247 | | - [success, ivx] = iViewX('checkconnection', ivx); |
248 | | - if success ~= 1 |
249 | | - error('connection to eye tracker failed'); |
250 | | - end |
251 | | - end |
252 | | -end |
253 | | - |
254 | | -function eyeTrackStart(ivx, cfg) |
255 | | - % start iView eye tracker |
256 | | - if cfg.eyeTracker |
257 | | - % to clear data buffer |
258 | | - iViewX('clearbuffer', ivx); |
259 | | - % start recording |
260 | | - iViewX('startrecording', ivx); |
261 | | - iViewX('message', ivx, ... |
262 | | - [ ... |
263 | | - 'Start_Ret_', ... |
264 | | - 'Subj_', cfg.Subj, '_', ... |
265 | | - 'Run', num2str(cfg.Session(end)), '_', ... |
266 | | - cfg.Apperture, '_', ... |
267 | | - cfg.Direction]); |
268 | | - iViewX('incrementsetnumber', ivx, 0); |
269 | | - end |
270 | | -end |
271 | | - |
272 | | -function eyeTrackStop(ivx, cfg) |
273 | | - % stop iView eye tracker |
274 | | - |
275 | | - if cfg.eyeTracker |
276 | | - |
277 | | - % stop tracker |
278 | | - iViewX('stoprecording', ivx); |
279 | | - |
280 | | - % save data file |
281 | | - thedatestr = datestr(now, 'yyyy-mm-dd_HH.MM'); |
282 | | - strFile = fullfile(OutputDir, ... |
283 | | - [cfg.Subj, ... |
284 | | - '_run', num2str(cfg.Session(end)), '_', ... |
285 | | - cfg.Apperture, '_', ... |
286 | | - cfg.Direction, '_', ... |
287 | | - thedatestr, '.idf"']); |
288 | | - iViewX('datafile', ivx, strFile); |
289 | | - |
290 | | - % close iView connection |
291 | | - iViewX('closeconnection', ivx); |
292 | | - end |
293 | | -end |
| 268 | +% function ivx = eyeTrackInit(cfg) |
| 269 | +% % initialize iView eye tracker |
| 270 | +% |
| 271 | +% ivx = []; |
| 272 | +% |
| 273 | +% if cfg.eyeTracker |
| 274 | +% |
| 275 | +% host = cfg.eyetracker.Host; |
| 276 | +% port = cfg.eyetracker.Port; |
| 277 | +% window = cfg.eyetracker.Window; |
| 278 | +% |
| 279 | +% % original: ivx=iviewxinitdefaults(window, 9 , host, port); |
| 280 | +% ivx = iviewxinitdefaults2(window, 9, [], host, port); |
| 281 | +% ivx.backgroundColour = 0; |
| 282 | +% [~, ivx] = iViewX('openconnection', ivx); |
| 283 | +% [success, ivx] = iViewX('checkconnection', ivx); |
| 284 | +% if success ~= 1 |
| 285 | +% error('connection to eye tracker failed'); |
| 286 | +% end |
| 287 | +% end |
| 288 | +% end |
| 289 | +% |
| 290 | +% function eyeTrackStart(ivx, cfg) |
| 291 | +% % start iView eye tracker |
| 292 | +% if cfg.eyeTracker |
| 293 | +% % to clear data buffer |
| 294 | +% iViewX('clearbuffer', ivx); |
| 295 | +% % start recording |
| 296 | +% iViewX('startrecording', ivx); |
| 297 | +% iViewX('message', ivx, ... |
| 298 | +% [ ... |
| 299 | +% 'Start_Ret_', ... |
| 300 | +% 'Subj_', cfg.Subj, '_', ... |
| 301 | +% 'Run', num2str(cfg.Session(end)), '_', ... |
| 302 | +% cfg.Apperture, '_', ... |
| 303 | +% cfg.Direction]); |
| 304 | +% iViewX('incrementsetnumber', ivx, 0); |
| 305 | +% end |
| 306 | +% end |
| 307 | +% |
| 308 | +% function eyeTrackStop(ivx, cfg) |
| 309 | +% % stop iView eye tracker |
| 310 | +% |
| 311 | +% if cfg.eyeTracker |
| 312 | +% |
| 313 | +% % stop tracker |
| 314 | +% iViewX('stoprecording', ivx); |
| 315 | +% |
| 316 | +% % save data file |
| 317 | +% thedatestr = datestr(now, 'yyyy-mm-dd_HH.MM'); |
| 318 | +% strFile = fullfile(OutputDir, ... |
| 319 | +% [cfg.Subj, ... |
| 320 | +% '_run', num2str(cfg.Session(end)), '_', ... |
| 321 | +% cfg.Apperture, '_', ... |
| 322 | +% cfg.Direction, '_', ... |
| 323 | +% thedatestr, '.idf"']); |
| 324 | +% iViewX('datafile', ivx, strFile); |
| 325 | +% |
| 326 | +% % close iView connection |
| 327 | +% iViewX('closeconnection', ivx); |
| 328 | +% end |
| 329 | +% end |
0 commit comments