Explain Eyelink Code

Explanation: Provides Eyelink with details about the graphics environment and performs some initializations

  • windowPtr is the screen you opened, the screen where your experiment/stimulus will be displayed.

    • For example, the windowPtr here is w: [w, screenRect] = Screen('OpenWindow',screenNumber, gray);

Location: After Screen('OpenWindow'), before you initialize or connect to Eyelink.

Explanation: Connects (the Display PC) to Eyelink. Without this you will see a connection error. As it is written above there is no cleanup or shutdown functions, but you can look at demos and include them in your script if you want. If for some reason you cannot connect to Eyelink, you will see Eyelink Init aborted appear in the command window.
Location: Right after EyelinkInitDefaults. You cannot send or get information from the Eyelink without this, so this needs to be before sending any commands or messages to the Eyelink.

Explanation: This is not really necessary. It prints which tracker version you're using in your command window.
Location: Based on your preference. As long as the Display PC and Eyelink are connected it will work.

Explanation: Creates the file that Eyelink data will be in, establishes a name for the file and opens it. fileName will be used later on to close the file among other things.
Location: After EyelinkInit before you send commands or messages to Eyelink.

Explanation: 'command' is basically saying "Hey Eyelink, do this, please." And 'message' says "Hey Eyelink print the following string in my EDF file." These particular command and message lines get the pixel coordinates of the display screen and print them in your EDF file.
Location: Honestly, anywhere after establishing a connection with Eyelink. But probably best if you put it before you start recording just so it's easy to find.

Explanation: This tells Eyelink what information you want recorded into your EDF file.
Location: After you create your EDF file and before you start recording.

Explanation: EyelinkDoTrackerSetup(el) runs calibration and validation. A screen will appear that looks like this: [CAUTION: Pressing ESC on the Host PC keyboard on the calibration or validation screens does not accept the calibration and validation fixation points]

Instead, pressing ESC will erase them! EyelinkDoDriftCorrection(el); I do not think this is entirely necessary for Eyelink 1000, but why not do it if it could improve the tracking data. WaitSecs(0.1); Recommended to allow a bit (itty bitty amount) of time to pass so the participant isn't just immediately taken to the next screen. Read this to find out what to do during calibration, validation, and drift correction.

Location: After you told Eyelink what gaze information you wanted recorded and before you start recording.

Explanation: Besides during calibration and validation, it has not mattered where your patient participant has looked! UNTIL NOW. Once you run this command, you will start collecting eye position and pupil area. If for some reason you cannot record, the error will be displayed.

Location: Whenever you want to start recording. After calibration, validation, and drift and before you expect to get tracking information. 


Explanation: Again, 'message'  prints the string to your EDF file. This one is a universally accepted way to mark zero-plot time in your data file.

Location: After you're recording and you want to mark as the start of when you "care" about the tracking data

Explanation: This is just a way to "timestamp" your data. It acts as a marker and is completely up to you whether you need it or not. For example, I wanted to show a black screen, have the participant gaze at the screen for a while, and then present a bright white screen and compare the pupil diameter. I could scan through the thousands of lines of data to find the point where the pupil diameter drastically or I could just put a message when I flip the screen to white and easily find this in the EDF file.

Location: Any point in your experiment that you want to mark in your EDF file such as screen flips, the end of a trial, etc.

Explanation: Closes your EDF file
Location: When the recording is complete and before you move the file from Host PC to Display PC.

Explanation: Uploads the EDF file to Display PC from Host PC
Location: After you're done recording and have closed the EDF file. Before you shutdown Eyelink.

Explanation: Disconnects Display PC from Eyelink and Host PC. (Note: does not shut down Host PC)
Location: The end of a script, when you no longer need to use Eyelin