EyeTrackingCalibrationScanner - Meg Wiki
location: EyeTrackingCalibrationScanner

Eye tracking calibration using Matlab in the MRI scanner

The following script runs the calibration and validation using Matlab, instead of using winCAL. In this script, 9 calibration points are used by default (instead of the standard 13), and they are closer to the center of the screen compared to the standard calibration points. This may help in the calibration, since it is sometimes hard to calibrate in the scanner when using the outer points at the edge of the screen.

This script was developed by Yaara Erez and is heavily based on Johan Carlin’s code from here.

How to use the calibration-validation script

  • Check out this github repo. Your folder should now include the following 5 ‘.m’ files:

    • eyeTrackerCalibration
    • fullCalibrationRoutine
    • calibrateEyeTracker
    • validateCalibration
    • waitRespAlts

You can find these files also on stimuli computer 3 in the control room (rightmost one) under:

‘D:\Put your file here\eyeTrackerCalibration’ folder.

It is possible run the calibration from this folder too.

  • Open Matlab R2009a version and set the folder in which the calibration scripts are as your ‘current directory’ in the Matlab.
  • Make sure winCAL is disabled, and any other programs that used the serial port for eye tracking before are either closed or released the port from use.

  • Make sure that you are working with 'JOHAN iView' on the eye tracking computer and that the eye is properly identified (both pupil and corneal reflection). If needed, adjust the window and thresholds, as well as the image properties (such as contrast, use the scroll bar on the right of the image to access this button).
  • From the Matlab command line, type: ET_serial = eyeTrackerCalibration();

    • This function runs calibration and validation and returns a serial port object, with which you can later work with other Matlab functions if you want (for example, when running your experiment).

    • There is no need to run the calibration via the iView, and no need to record the data during calibration.
    • Remember to manually accept by space in the eye tracking computer the central point – it will appears twice: at the beginning of the calibration and at the beginning of the validation.

    • The last point of the validation is in the bottom-center of the screen. It will remain there for a few seconds before the validation is completed, be patient.
    • When the calibration-validation process is completed, you might want to look at the ‘user’ tab at the bottom-left corner of the iView on the eye tracking computer, to see the results of validation, to see whether they are good enough.
    • Note that some delays in the response of the function to keyboard presses are possible. This is because some messages are transferred between the stimuli and eye tracking machines, and these take time to be processed. Again, be patient, but if the delays are too long (e.g. >10s), it is possible that the function had crashed and is no longer responding. You have 2 options:

      • Kill the Psychtoolbox display screen via the task manager.
      • Use Alt+Shift to get to the Matlab command window and type Screen(‘closeall’); (and ‘Enter’). You might need to type it ‘blindly’ as the Psychtoolbox display screen takes over the screen so you cannot actually see the command window, although you are typing in it. But once you press the ‘Enter’, this display screen will be closed and you will be able to continue working with the Matlab. Remember that most chances are that the serial port is now open, so close it using fclose(‘all’) before you move on.

    • ET_serial can have any other name as you like.
    • If you do not need ET_serial for further use (for example, if you are going to run your experiment using a program other than Matlab), close it via the Matlab command window by typing: fclose(ET_serial);

  • If you fail to calibration because the Matlab says that the port is already open or in use, try the following:
    • Close any other programs that might have used the serial port.
    • In the Matlab, type: fclose(‘all’) to close all serial ports that might be open.

      • If the Matlab still claims that the port is already in use, try the command instrfind to see which ports are open, and then close them. e.g: ports = instrfind; and then fclose(ports(3)); to close the 3rd port.

  • Keyboard presses used in the function (from the stimuli computer):
    • ‘space’ – to accept the initial ‘Follow the target…’ display screen and move on, and to manually accept a point during calibration/validation (the latter is not always working for some reason).
    • ‘escape’ to exist. Expect a delay of a few seconds before the function exits.
    • 's’ – to skip calibration, can be used only when the initial ‘Follow the target’ display screen appears.
    • y’ and ‘n’ for ‘yes’ and ‘no’ – at the end of calibration-validation process, when asked on the screen whether calibration was OK and whether you want to try it again.

  • Be very ( ! ) careful when adjusting the eye image window in the iView – if you mouse-click on the image and it freezes and does not acquire eye movements (until you click it again), the calibration and validation will be interrupted and you will have to re-start it. If this happens, close the Psychtoolbox display screen using ‘Screen(‘closeall’)’ or by killing it from the task manager. These mouse-clicks on the image are also dangerous while recording, since they will be stopping your recording.
  • Changing calibration parameters: It is possible to change some of the calibration parameters, such as the size of the target, the number of calibration points and their location, etc. However, if you change parameters, make sure you do that on your own copy of the code, and not on the general one under ‘D:\Put your file here\eyeTrackerCalibration’ folder.

CbuMeg: EyeTrackingCalibrationScanner (last edited 2017-08-08 16:04:23 by JohanCarlin)