Sanjay's eyelink data analysis tools

Tools to help analyse data from the eyelink eye tracker

Download functions from the whole library 'zip' file at the top of the matlib page.

EDF file (eyelink data file) - contains raw traces and events, encoded in internal binary format
EDF2ASC - this is a DOS program that converts binary EDF files into ASCII (text) format (extension .asc) which is essentially a badly organised table of samples and events in time order. EDF2ASC appears only to work on older versions of Windows, or on the Eyelink PC itself.
readEDFASC - my Matlab script that reads the ASC file into a MATLAB struct-array. It will break down the data into trials if you have used 'start_recording' and 'end_recording' in your task code.
    s = readEDFASC('data.asc'); 
If you specify an EDF file, the script will try to run EDF2ASC.EXE which should be on the DOS path.
The resulting Struct-array has one element for each trial, and each trial i has fields:
  •  s(i).pos = [TIME X Y PUPIL] 
    i.e. an Nx4 array containing the actual trace, with N time-points,
  •  s(i).saccade = [ TIME1 TIME2 DUR X1 Y1 X2 Y2 AMPL PUPIL ] 
    i.e. a Nx9 array for N saccades
  •  s(i).fixation = [ TIME1 TIME2 DUR X Y PUPIL ] 
    i.e. Nx6 array for N fixations
  •  s(i).blink = [ TIME1 TIME2 DUR ] 
    i.e. Nx3 array for N blinks
  • also fields called message_name_t and message_name_m, which contain the timestamp and text content of messages sent to the eyelink from your task. For example if you called
    send_message('stimulus on')
    , then there are fields
     stimulus_t = time
    and
    stimulus_m = 'on'
viewSaccades - my Matlab script to display each trial's eye data, and allows you to mark / select them. If you provide event names, it will also display those events on the traces.
snipSaccades - This script is quite complicated, but allows you to epoch pupil and saccade data based on trial events. It can perform
  • rotation and translation based on trial-to-trial criteria
  • baseline subtraction (fixation correction)
  • Blink interpolation
  • Saccade curvature, peak velocity and amplitude calculations
  • Saccade filtering based on minimum size, index, or time relative to events
  • Averaging of trials by condition
  • Smoothing
Statistics! Aside from standard anova, I have written the following:
  • anovanTable N-way anova, using an N-dimensional array. For example, if you have a 2 x 2 x 2 design for 10 subjects, you can provide the data as a 2 x 2 x 2 x 10 array, and do
     [~,table] = anovanTable(X, 'varnames',{'F1','F2','F3','Sub'}, ...
                                'random', 4 , ...
                                'model', eye(4) ); 
  • conditionalPlot( X, Y ) plots the mean of 'Y' as a function of bins of X. It uses a novel sliding bin approach to produce a smooth function. For example, if X is the reaction time, and Y is accuracy on each trial (1 or 0 for correct or incorrect), then this will plot a conditional accuracy function. X and Y can be matrices (trial, subject) or (trial, subject, condition). Trials are binned, subjects are averaged, and conditions are plotted as separate lines.

    This function can perform permutation testing with correction for family-wise error across RT bins. It tells you at which RTs there are significant differences between conditions.

  • deltaPlot ( RT ) plots the differences in RT between conditions, as a function of RT. Although this sounds odd, it tells you a lot about changes in the shape of an RT distribution.

    In addition to a novel sliding bin approach, this function also performs permutation testing between conditions.

Pupil analysis pathway: example

Start with an EDF file for each subject. The EDF file should be run through "edf2asc", the converter provided by Eyelink, which results in an ASC file for each subject.
NC = 4; NS = 10;   % number of subjects / conditions
For i=1:NS                    % for each subject
  s=readEDFASC(‘file’)        % load eye data
  c=load( condition_file{i} ) % load conditions

  P=snipSaccades(s, ‘startevent’, ‘endevent’, ‘pupil’, true, ...)
  mP(i,:,:) = groupMeans(P, c.conditions)’
End

errorBarPlot(permute(mP,[1 3 2]))
[~,p]=permutationOLS(reshape(mP,NC*NS,[]),
              kron(ones(1,NS),1:NC)’, CONTRASTS,
              kron(1:NS,ones(1,NC))’ ) 
This code takes pupil data in an epoch between 'startevent' and 'endevent', then takes the mean for each of 4 conditions, for each subject. Then the across-subjects mean and sd are plotted, and the conditions are compared by permutation within subjects, giving a p-value.