Doing drift correct before each trial with Eyelink

OS : Windows 10
PsychoPy version (e.g. 1.84.x): 2021.2.3
Standard Standalone? If not then what?: Y

Hi everyone :grinning:

I’m creating a reading experiment with Eyelink Duo System. Each participant needs to read 16 articles, which can be divided into 4 sections according to different manipulation conditions.

In order to make sure that participant’s calibration model remain valid, my teacher ask me to do calibration and validation before each section, but I think that drift correct function provided by the Eyelink system should be more helpful.

I use the eye-tracking components provided in 2021.2.3 version to create my experiment, but I don’t know how to use the custom component to add the codes for drift correct.

I read this article: Doing Drift Correction with ioHub, and then added eyetracker.sendCommand('doDriftCorrect', [600, 300, 1, 0]) in the “Begin Routine” tab. It successfully entered the drift correct screen on the Host PC, but I still found some issues.

  1. The entire screen is completely blank on the display PC during the drift correct phase. I want to show a cross mark which could let participant keeps their eyes fixing, so I added a text component in same routine, but the mark didn’t show up.

  2. I want to redo the calibration and validation when the drift correct shows that the calibration model has been invalid, but nothing changed when I pressed SPACEBAR or ENTER or C or V during the drift correct phase. I also tried to change the fourth parameter from ‘0’ to ‘1’, but it didn’t work, too. Should I add any other codes to get what I want? or there has another key should I use to enter the calibration phase?

Thank you for spending time answering my questions, any help would be greatly appreciated. :blush:

P.S. My monitor resolution is 1980*1080, so setting the fix position at (600, 300) should be fine and present on the screen.

Try using:

eyetracker.sendCommand('doDriftCorrect', [600, 300, 0, 0])

A 0 in the 3rd arg list should tell eyelink that you are drawing the drift correct graphics, which is what you need to do.

DC location needs to be specified in pixels with 0,0 being the top left of the screen.

Using a 1 in the 4th parameter will not work with the iohub eyelink implementation, so it is not possible to use it to go back into calibration mode. eyetracker.runSetupProcedure(), or using the Builder ET Calibrate Component, needs to be used to start the camera setup / calibration mode.

So I’m not sure it is possible to do what you want on a conditional basis. Could you always enter camera setup/calibration mode after you do a manual drift correct and then just press Escape to exit it if you do not want to recalibrate?

I guess it might be good to try and add more formal support for the eyelink drift correct functionality in a future version of PsychoPy. Adding it to the possible to do list.

Thank you

Hi @sol,

Thanks for your reply :blush:

I tried to set the 3rd arg from ‘1’ to ‘0’, but it still showed nothing on the display PC.

I also tried to set the 3rd and 4th args to ‘0’ or ‘1’ respectively, but neither of them work. The target point on the drift correct / check preview window was correctly displayed, I just couldn’t get anything show on my display PC.

I found this was because I controlled two computers at the same time, and Eyelink won’t accept any mouse click or keyboard input when the pupil missing. If I keep my eye fix on the display screen, I can successfully perform the drift correct by pressing the spacebar or clicking the ‘Accept Fixation’ button.

But if I press the spacebar or ‘ENTER’ key again, the host PC will go to the ‘Setup’ screen while the display PC run into the next routine and show the article, but the eyetracker seems not recording the eye movement before I click the ‘Record’ button on the ‘Setup’ screen.

When I used to learn how to operate the Eyelink system, I used a program written by another professor in Matlab. In that program, drift correct will appear before the start of each trial. If the drift value is acceptable, I can press the ‘G’ key to enter the trial and show my stimuli immediately, or just pressed ‘ENTER’ key to go back to the setup mode.

I think these operate steps was set by the teacher himself and control them by his program, not the original Eyelink default setting. Now I don’t know how to do the drift correct properly with Psychopy.

If the operation steps of the drift correct phase is same as the validation phase, I should go back to the setup screen after I pressed ‘ENTER’ key, and then press the ‘O’ key to start the trial. But now when I click the ‘ENTER’ key or spacebar, the trial will start immediately on the display PC while the host PC still in the setup mode.

I’m not sure what I did wrong and how to fix it. :worried:

I found that I just want to use the drift correct function to determine whether it is necessary to re-calibrate, so what I really want to do should be the ‘drift checking’ rather than the ‘drift correct’. Since I can’t use the drift correct function provided by Eyelink completely successfully, I want to try another way to check the drift value.

I use the method provided in the ‘branchedExperiment’ and ‘eyetracking’ to create a ‘checking phase’, the first routine in this phase will show a cross mark as a gaze target and a circle representing the current gaze position of the eye. The second routine is the calibration component, and the last routine only contains a 0.5 sec text component which will show ‘drift pass’ on the screen.

If the distance between cross and circle isn’t ideal, I can press the ‘y’ key to enter the calibration routine, or press the ‘n’ key to skip the calibration routine and proceed to the reading routine.

This idea is work successfully with the ‘MouseGaze’ mode now, but I’m worried it will fail with the Eyelink.

As mention in this discussion, The keyboard input and the etRecord components can’t work properly together, but the way I use to show the current gaze position circle is to add a etRecord component and set the position of the circle as $etRecord.getPos().

I delete the following code in the script to prevent the eyetracker recording status to be finished in the end of the drift routine:

        if etRecord.status != FINISHED:
            etRecord.status = FINISHED

But without the Eyelink, I’m not sure whether this script will work or not. Is there anything I should modify?

As a novice user of Psychopy, Thank you very much for your patience with me and a lots of assistance these days. :sob:


Hi @AliceHsiao,

I think your idea of implementing a ‘drift check’ instead of using the eyelink built-in drift correct is probably going to be the better option at this point if using the iohub common eye tracker interface that the Builder ET functionality uses.

It should work fine, but try not using the ETRecord component in your experiment:

  1. Instead of using $etRecord.getPos() you can use $eyetracker.getPos() to get the current eye position directly from the tracker.

  2. use a custom code component to start and another to stop the eye tracker recording. You could, for example, start recording right after calibration and stop recording at the end of your experiment. Quoting from the discusion you refence above:

To start recording add a new routine and then add the following to the begin routine tab of a custom code component in the routine:


To stop recording add a new routine and then add the following to the end routine tab of a custom code component:


The ETRecord issues in the current release have been / are being addressed so it should be much more usable in the next release.


If you need to use the eyelink DC for your experiment, you could write your experiment in Coder / as a python script using the pylink package directly with PsychoPy. We have heard that SR Research has released a new version of their EyeLink Developers Kit / API that “includes a lot of updates, including lots of new PsychoPy examples that come bundled with it.” If you go this route please contact SR Research for any pylink / eyelink related support questions.

Thanks again, please let us know how it goes

Hi @sol ,

Thanks for your suggestion, it works great! :blush:

And I think that I can’t use the etRecord component in the routine with deleting two lines of the code to prevent the eyetracker stop recording. I ran the experiment yesterday and the Eyelink crashed, this could be caused by I sent the start record command twice. One is in the custom code component, the other one is in the etRecord component. The previous one was disabled during the earlier “branchedExperiment” test since I didn’t want to test the eyetracking part at the same time, and I forgot to turn it back when I proceeded to do the “drift checking” test. When I test the whole experiment with Eyelink yesterday, I remembered to cancel the “disable” in custom code finally, and then it caused the crash in Eyelink.

So I think that’s why I can use the idea with MouseGaze successfully, but failed with Eyelink. I can’t edit the last post now, but that is a stupid idea.

I will check the package later, thanks for the information!

I’m truly grateful for your help and patience with me in these days. :smiling_face_with_three_hearts: