-
Notifications
You must be signed in to change notification settings - Fork 1
/
eyelinkFix.m
55 lines (50 loc) · 1.41 KB
/
eyelinkFix.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
%% if the eyetracker gets stuck, run this twice (will error the first time)
% may need to move cleanup function into own file
clc;
clear all;
close all;
useOfEyelink=1;
dummymode=0;
edfFile='test';
trigger=1;
% connection with eyetracker, opening file
if ~EyelinkInit(dummymode)
fprintf('Eyelink Init aborted.\n');
cleanup(useOfEyelink, edfFile, trigger);
return;
end
i = Eyelink('Openfile', edfFile);
if i~=0
fprintf('Cannot create EDF file ''%s'' ', edfFile);
cleanup(useOfEyelink, edfFile, trigger);
return;
end
if Eyelink('IsConnected')~=1 && ~dummymode
cleanup(useOfEyelink, edfFile, trigger);
return;
end
function cleanup(useOfEyelink, edfFile)
if useOfEyelink==1
Eyelink('Command' , 'set_idle_mode');
WaitSecs(0.5);
Eyelink('CloseFile');
%download data file
try
fprintf('Receiving data file ''%s''\n', edfFile );
status=Eyelink('ReceiveFile');
if status > 0
fprintf('ReceiveFile status %d\n', status);
fprintf('Data file ''%s'' can be found in ''%s''\n', edfFile, pwd );
end
if 2==exist(edfFile, 'file')
fprintf('Data file ''%s'' can be found in ''%s''\n', edfFile, pwd );
end
catch
fprintf('Problem receiving data file ''%s''\n', edfFile );
end
Eyelink('Shutdown');
end
Screen('CloseAll');
ListenChar(0);
ShowCursor;
end