You can use the Eyelink eye tracker with mgl and the task code. First, make sure that the mgl eyelink is compiled by following instructions here.

  1. Using mglEditScreenParams select use of the Eyelink by setting eyeTrackerType to Eyelink.
  2. Set parameters such as the number of calibration points you want to use, how far those calibration points are from the center of the screen, sample rate and what data you want to save, by using mglEyelinkParams.
  3. In your experiment make sure to call eyeCalibDisp (see the task program taskTemplateSaccade for an example)
      myscreen = eyeCalibDisp(myscreen);
  4. This will run the calibration routine, see under mglEyelinkSetup for a full reference on text commands that can be used to calibrate the scanner. As a quick guide, the basic procedure goes something like this.
    1. Hit ENTER to bring up an image of the eye
    2. Make sure that the eye is centered appropriately.
    3. Hit ESC to close this image of the eye.
    4. HIT C to run the calibration routine. You will need to hit enter after fixating the first fixation point, after that you should just be able to fixate each fixation point in turn and it will go through the calibration.
    5. Hit Enter to accept the calibration.
    6. Hit ESC to end the calibration routine and start your stimulus program.
  5. Upon ending your stimulus program, mgl will save a file with an edf extension that stores the eye position information.
  6. You can now read the saved data using getTaskEyeTraces.

To test this whole procedure, you may wish to use the stimulus program taskTemplateSaccade. This program has the subject saccade to a number of eccentric positions and back to the fixation. After you are done, you should have saved eye traces that look like ones below.

Optionally, you may also want to test eye position for significant effects across conditions, which can be tested using the function (see help in function):



A simple GUI that allows you to set parameters for the EyeLink eye tracker. You can set the whether you want 5 or 9 calibration points (set calibrationType to HV5 or HV9, respectively). You can set the sample rate and which data you want to save. You can also set the calibration area - the area of the screen that you want to use for calibration. Sometimes it is useful to move the calibration in from the edges of the screen when you are having trouble getting pupil lock at far eccentricities.


getTaskEyeTraces can be used to load the eye tracker data. It works like getTaskParameters, but also returns the eye traces sorted by trial. You can load up the data for an experiment. For example, from a run of taskTemplateSaccade

>> getTaskEyeTraces('100811_stim01')
(getTaskEyeTraces) Opening edf file /Users/justin/data/eyetracker/10081101.edf took 3 secs 374 ms
(getTaskEyeTraces) Extracting trial by trial data for 63 trials took 0 secs 842 ms
(getStimvolFromVarname) taskNum=[1], phaseNum=[1], segmentNum=[1]
(getstimvol) Same trial in multiple conditions.
(getStimvolFromVarname) targetAngle=0.0000000 targetRadius=8.0000000: 3 trials
(getStimvolFromVarname) targetAngle=45.0000000 targetRadius=8.0000000: 4 trials
(getStimvolFromVarname) targetAngle=90.0000000 targetRadius=8.0000000: 4 trials
(getStimvolFromVarname) targetAngle=135.0000000 targetRadius=8.0000000: 4 trials
(getStimvolFromVarname) targetAngle=180.0000000 targetRadius=8.0000000: 4 trials
(getStimvolFromVarname) targetAngle=225.0000000 targetRadius=8.0000000: 4 trials
(getStimvolFromVarname) targetAngle=270.0000000 targetRadius=8.0000000: 4 trials
(getStimvolFromVarname) targetAngle=315.0000000 targetRadius=8.0000000: 4 trials
(getStimvolFromVarname) targetAngle=0.0000000 targetRadius=12.0000000: 4 trials
(getStimvolFromVarname) targetAngle=45.0000000 targetRadius=12.0000000: 4 trials
(getStimvolFromVarname) targetAngle=90.0000000 targetRadius=12.0000000: 4 trials
(getStimvolFromVarname) targetAngle=135.0000000 targetRadius=12.0000000: 4 trials
(getStimvolFromVarname) targetAngle=180.0000000 targetRadius=12.0000000: 4 trials
(getStimvolFromVarname) targetAngle=225.0000000 targetRadius=12.0000000: 4 trials
(getStimvolFromVarname) targetAngle=270.0000000 targetRadius=12.0000000: 4 trials
(getStimvolFromVarname) targetAngle=315.0000000 targetRadius=12.0000000: 4 trials

This will return a structure similar to the one returned by getTaskParameters except there will be an “eye” field:

ans = 

                  nTrials: 63
              trialVolume: [1x63 double]
                trialTime: [1x63 double]
             trialTicknum: [1x63 double]
                   trials: [1x63 struct]
                 blockNum: [1x63 double]
            blockTrialNum: [1x63 double]
                 response: [1x63 double]
             reactionTime: [1x63 double]
    originalTaskParameter: [1x1 struct]
           responseVolume: [1x63 double]
                parameter: [1x1 struct]
                 stimfile: [1x1 struct]
                      eye: [1x1 struct]

This will have the eye position data sorted by trial:

ans = 

     hPos: [63x2002 double]
     vPos: [63x2002 double]
    pupil: [63x2002 double]
     time: [1x2002 double]

Note that hPos and vPos fields contains eye position data with respect to the center of the screen in degrees.

It will also display a figure (this can be turned off by setting the input parameter dispFig=0) of the eye position data sorted by trial type