1+ % EYETRACKER
2+ if use_eyelink
3+
4+ el= EyelinkInitDefaults(window );
5+
6+ % Initialization of the connection with the Eyelink Gazetracker.
7+ if (Eyelink(' initialize' ) ~= 0 )
8+ error(' could not init connection to Eyelink' );
9+ return ;
10+ end
11+
12+ % Open file to record data to
13+ status= Eyelink(' Openfile' ,edfFile );
14+ if status ~= 0
15+ status
16+ error(' openfile error' )
17+ end
18+
19+ % Pass the screen resolution to EyeLink
20+ [width , height ]=Screen(' WindowSize' , screenNumber );
21+ Eyelink(' command' ,' screen_pixel_coords = %ld %ld %ld %ld' , 0 , 0 , width - 1 , height - 1 );
22+ Eyelink(' message' , ' DISPLAY_COORDS %ld %ld %ld %ld' , 0 , 0 , width - 1 , height - 1 );
23+
24+ % Set calibration type.
25+ Eyelink(' command' , ' calibration_type = HV5' );
26+
27+ % Get EyeLink version
28+ [v , vs ]=Eyelink(' GetTrackerVersion' );
29+ fprintf(fidTime ,' Running experiment on a %s tracker.\n ' , vs ) ;
30+
31+ % Set event and sample filters (i.e. what will be recorded in the output file)
32+ Eyelink(' command' , ' file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON,INPUT' );
33+ Eyelink(' command' , ' file_sample_data = LEFT,RIGHT,GAZE,HREF,AREA,GAZERES,STATUS,INPUT' );
34+ % set link data (used for gaze cursor)
35+ Eyelink(' command' , ' link_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON,FIXUPDATE,INPUT' );
36+ Eyelink(' command' , ' link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS,INPUT' );
37+
38+ % Change camera setup options
39+ % set pupil Tracking model in camera setup screen
40+ % no = centroid. yes = ellipse
41+ Eyelink(' command' , ' use_ellipse_fitter = no' );
42+ % set sample rate in camera setup screen
43+ Eyelink(' command' , ' sample_rate = %d ' ,1000 );
44+
45+ % Calibrate the eye tracker
46+ EyelinkDoTrackerSetup(el );
47+ % start recording eye position
48+ Eyelink(' StartRecording' );
49+ % record a few samples before we actually start displaying
50+ WaitSecs(0.1 );
51+ % mark zero-plot time in data file
52+ Eyelink(' Message' , ' SYNCTIME' );
53+ TimeEyelink = GetSecs ;
54+ fprintf(fidTime , ' %f ;%s\n ' , TimeEyelink , ' Start_Eyelink' );
55+ end
56+
57+
58+ % To add message in your file
59+ if use_eyelink Eyelink(' Message' ,' PRE-TEST' ); end ;
60+
61+ % End with eyelink
62+ if use_eyelink
63+ Eyelink(' stoprecording' );
64+ status= Eyelink(' closefile' );
65+ if status ~= 0
66+ sprintf(' closefile error, status: %d ' ,status )
67+ end
68+ end
69+
70+
0 commit comments