We have functions to interface Matlab with the EyeLink scanner. These functions allow you to calibrate the scanner and get current eye position information, etc. These are all referenced below. We have included 64-bit binaries based on a beta-version of Eyelink's frameworks.
To run the eyelink commands, you will need to have the Eyelink Frameworks installed. If they are not installed, you may see an error like this:
>> mglEyelinkOpen Invalid MEX-file '/Users/justin/proj/mgl/mgllib/mglEyelink/mglPrivateEyelinkOpen.mexmaci64': dlopen(/Users/justin/proj/mgl/mgllib/mglEyelink/mglPrivateEyelinkOpen.mexmaci64, 1): Library not loaded: @executable_path/../Frameworks/edfapi.framework/Versions/A/edfapi Referenced from: /Users/justin/proj/mgl/mgllib/mglEyelink/mglPrivateEyelinkOpen.mexmaci64 Reason: image not found
The Eyelink libaries can be downloaded from the Eyelink CD - or, if you are using 64-bit, follow instructions here to get the beta. The ones you will need are called eyelink_core.framework (used for interfacing with the eye tracker) and edfapi.framework (used for reading the edf files that the tracker makes). These frameworks will appear as directories in Library/Frameworks (either in the root directory or your home directory). You also need the SDL frameworks (SDL.framework, SDL_ttf.framework, SDL_mixer.framework, SDL_image.framework, SDL_gfx.framework). There is also an eyelink_core_graphics.framework, but this framework should not be necessary. Once you have successfully installed the Frameworks, you should also be able to compile the Eyelink code (this is only necessary to do if you are using 32-bit Matlab or some other platform for which the code does not work):
Follow the Eyelink instructions for setting up your Eyelink computer and connecting to it. But, essentially, you need to do at least the following:
Configure IPv4: Manually IP Address: 220.127.116.11 Subnet Mask: 255.255.255.0 Router, DNS Server and Search Domains are irrelevant (I think)
If the system does not find a connected Eyelink computer, you will likely see an error like this:
>> mglEyelinkOpen displayApi: Socket BIND failed: -1 48 port 4000 displayAPI: /Users/sugy/dev/displayAPI/macdispapi/../common/w32_link.c 564 failed to create socket Cannot initialize link: Check network and TCP/IP setup(mglPrivateEyelinkOpen) Connection type is 0 Connection failed: could not establish a link.
If you use the mgl task code, you do not need to call any of the following functions explicitly.
purpose: Reads an Eyelink file into matlab
|filename||Name of EDF file you want to read|
|verbose||Set to 1 to display verbose information, defaults to 0|
purpose: Opens a TCP/IP link between matlab and the EyeLink eyetracker.
|ip||The IP address of the eyewink eye tracker, defaults to 18.104.22.168|
|conntype||0, open up a direct link, 1 initializes a dummy connection useful for debugging.|
% open the link % calls mglPrivateEyelinkOpen, default ip is '22.214.171.124', default conntype is 0 try mglEyelinkOpen('126.96.36.199', 0); catch err mglEyelinkOpen('188.8.131.52', 1); disp(sprintf('(mglEyelinkOpen) Establishing a dummy connection with the EyeLink')); end
purpose: Sends a command to the eyetracker
usage: mglEyelinkCMDPrintF('an EyeLink command');
|a string||anything recognized by EyeLink (see the manual)|
% set up some variables mglEyelinkCMDPrintF('screen_pixel_coords = 0 0 %d %d', mglGetParam('screenWidth'), mglGetParam('screenHeight')); mglEyelinkCMDPrintF('calibration_type = HV9'); mglEyelinkCMDPrintF('file_event_filter = RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON'); mglEyelinkCMDPrintF('file_sample_data = RIGHT,GAZE,AREA,GAZERES,STATUS'); mglEyelinkCMDPrintF('sample_rate = 500');
This function switches the Eyelink Software into the 'setup' state where you can adjust thresholds, change settings and run the calibration routine. You can use any of the keyboard commands that are available from the Eyelink software (on the Eyelink computer keyboard). This function returns when you exit the Eyelink setup state (via the ESC key), usually after you have successfully calibrated or validated. The keys you can use are listed below, for more information refer to the Eyelink Users Manual.
purpose: Open up a new datafile to store the eye data
purpose: Tell the eyetracker to start recording samples
|1 0 0 0||edf-sample (record eye samples in the current eyelink .edf file)|
|0 1 0 0||edf-event (record events in the current eyelink .edf file)|
|0 0 1 0||link-sample (send eye position samples back to matlab)|
|0 0 0 1||link-event (send events back to matlab)|
Pass in either a vector for recording state: e.g. [1 0 0 0] where the elements are [file-sample file-event link-sample link-event] or up to four string arguments that set the recording state
purpose: Insert a message into the recorded datastream
|meessage||text string that you want to insert|
purpose: Get the X and Y coordinate of the current eye position
usage: pos = mglEyelinkGetCurrentEyePos()
|pos||returns the eye position in the current device coordinates - e.g. visual angle if visual angle coordinates are set.|
purpose: Close the link between matlab and the eyetracker