Eyelink 1000 Eye-Tracking System

From REALab Wiki
Revision as of 19:03, 25 July 2012 by Barvision (talk | contribs) (Created page with "==Matlab Code== ===Beginning of script, eyelink initialization=== %Provide Eyelink with details about the graphics environment % and perform some initializations. The inform...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Matlab Code

Beginning of script, eyelink initialization

%Provide Eyelink with details about the graphics environment % and perform some initializations. The information is returned % in a structure that also contains useful defaults % and control codes (e.g. tracker state bit and Eyelink key values). el=EyelinkInitDefaults(expWindow);

% Initialization of the connection with the Eyelink Gazetracker. % exit program if this fails. if ~EyelinkInit(dummymode, 1)

   fprintf('Eyelink Init aborted.\n');
   cleanup;  % cleanup function
   return;

end

[v vs]=Eyelink('GetTrackerVersion'); fprintf('Running experiment on a %s tracker.\n', vs );

% make sure that we get gaze data from the Eyelink Eyelink('Command', 'link_sample_data = LEFT,RIGHT,GAZE,AREA');

fileName=sprintf('%s_RT.edf', subjectData.subjectNumber);%foo(1),foo(2),foo(3)); %RT= Rating Task Eyelink('Openfile',fileName);

% Calibrate the eye tracker EyelinkDoTrackerSetup(el);


End of experiment, closing eyelink

Eyelink('closefile');

% download data file try

   fprintf('Receiving data file %s\n', fileName);
   status=Eyelink('ReceiveFile',fileName);
   if status > 0
       fprintf('ReceiveFile status %d\n', status);
   end
   if 2==exist(fileName, 'file')
       fprintf('Data file %s can be found in %s\n', fileName, pwd );
   end

catch rdf

   fprintf('Problem receiving data file %s\n', fileName );
   rdf;

end


DataViewer trial marking

If you want to break up different trials in DataViewer, then put this code before and after the trail:

Eyelink('StartRecording');

%code for one trial goes here

EYELINK('stoprecording');


Areas of interest

You can create Areas of Interest for a picture in DataViewer, which should output *.ias file for that picture. Then when that picture is shown in matlab, you can use the following code which will allow Eyelink to tell whether the eyes focused on that AOI. Note from Sarah: if you want to use this, you have to present the picture/image for a long enough time for the image to load (likely more than 1sec, maybe closer to 2seconds), so this may not work well with very dynamic stimuli presentations.

Screen('Flip', expWindow); % Displays the window so you can see it template = ['InterestAreas/Photo' num2str(photoNumber) '-InterestAreas.ias']; %"template" is just a var name Eyelink('Message', '!V IAREA FILE %s', template); %note: you have to use the right .ias filename for given pic