A simple EyeLink gaze-contingent demo showing how to retrieve online events from a buffer.
In each trial an image is presented with a red gaze-contingent dot overlaid on top.
The dot’s location is based on the average x y coordinates of fixations updated online every 50ms via a FIXUPDATE event.
See EyeLink Programmers Guide manual > Experiment Templates Overview > Control > Fixation Update Events
Each trial ends when the space bar is pressed.

FIXUPDATE events send updates about a current fixation at regular intervals. By default an interval of 50ms is used.
The first update is sent one update interval after the start of the fixation, and the last is sent at
the end of the fixation. This demo uses FIXUPDATE events to get the averaged gaze x y position across each fixation interval.


screenNumber is an optional parameter which can be used to pass a specific value to PsychImaging(‘OpenWindow’, …)
If screenNumber is not specified, or if isempty(screenNumber) then the default:
screenNumber = max(Screen(‘Screens’));
will be used.

This demo uses the ‘GetNextDataType’/’GetFloatData’ function pair that allows access to the following buffered samples and events
(See EyeLink Programmers Guide manual > Data Structures > FEVENT):

STARTBLINK 3 (the start of a blink)
ENDBLINK 4 (the end of a blink)
STARTSACC 5 (the start of a saccade)
ENDSACC 6 (the end of a saccade)
STARTFIX 7 (the start of a fixation)
ENDFIX 8 (the end of a fixation)
FIXUPDATE 9 (a fixation update during a fixation)
SAMPLE_TYPE 200 (a sample)
MISSING_DATA -32768 (missing data)

Use buffered data if you need to:
a) grab every single consecutive sample online
b) grab event data (e.g. fixation/saccade/blink events) online

Note that some buffered event data take some time to be available online due to the time involved
in calculating velocity/acceleration. If you need to retrieve online gaze
position as fast as possible and/or you don’t need to get all subsequent samples or other
events, then use the Eyelink(‘NewFloatSampleAvailable’) / Eyelink(‘NewestFloatSample’) function pair,
as illustrated in the GCfastSamples.m example.

Events structure and fields available via the ‘GetNextDataType’/’GetFloatData’ function pair:
type (number assigned to event - STARTBLINK=3, STARTSACC=5, STARTFIX=7)
eye (0=left eye, 1=right eye)
sttime (event start time)

  type (number assigned to event - ENDBLINK=4)  
  eye (0=left eye, 1=right eye)  
  sttime (event start time)  
  entime (event end time)  


  type (number assigned to event - ENDSACC=6)  
  eye (0=left eye, 1=right eye)  
  sttime (event start time)  
  entime (event end time)         
  gstx (Saccade start x gaze position)  
  gsty (Saccade start y gaze position)  
  genx (Saccade end x gaze position)  
  geny (Saccade end y gaze position)  
  supd\_x (Saccade start x 'pixel per degree' value)  
  supd\_y (Saccade start y 'pixel per degree' value)  
  eupd\_x (Saccade end x 'pixel per degree' value)  
  eupd\_y (Saccade end y 'pixel per degree' value)  

type (number assigned to event - FIXUPDATE=9, ENDFIX=8)
eye (0=left eye, 1=right eye)
sttime (event start time)
entime (event end time)
gavx (average gaze x position during fixation)
gavy (average gaze y position during fixation)
ava (average pupil size)
supd_x (Fixation start x ‘pixel per degree’ value)
supd_y (Fixation start y ‘pixel per degree’ value)
eupd_x (Fixation end x ‘pixel per degree’ value)
eupd_y (Fixation end y ‘pixel per degree’ value)

time (sample time)
type (SAMPLE=200)
pa ([lef eye pupil size, right eye pupil size])
gx ([left gaze x, right gaze x])
gy ([left gaze y, right gaze y])
rx (x ‘pixel per degree’ value)
ry (y ‘pixel per degree’ value)
buttons (button state and changes)
hdata (contains a list of 8 fields. Only the first 4 values are important:
[uncalibrated target sticker x, uncalibrated target sticker y, target sticker distance in mm, target flags)

Path   Retrieve current version from GitHub | View changelog