|
#1
|
|||
|
|||
Unable to draw EyeLink drift correction to screen
Hi all,
I am running an experiment in a loop. When a new trial begins, I would like to call the EyeLink 2 drift correction function. I've been able to call the menu for calibration before starting the experiment just fine. The problem is that my function does run and the drift correction routine is initialised (I can see this from the EyeTracker PC). However, I am unable to get the eye tracker to override the screen in order to display the drift correction dot. Instead, the experiment continues to be displayed on the screen, although is blocked whilst it waits for the drift correction routine to be exited. Code:
import viz import os import vizact import viztask import math #import pyxid import win32api import win32con sys.path.append(os.getcwd() + '/functions') import LoadLevel import screen import Lights import Physics import EyeTracker from text import Text from movement import Movement from toDataFile import toDataFile from StaticVisualSearchTask import StaticVisualSearchTaskExperiment userMovement = Movement(10) text = Text() EyeTracker.beginExperiment() EyeTracker.setupTracker() EyeTracker.testTrial() experiment = StaticVisualSearchTaskExperiment() toFile = toDataFile(experiment.getParticipantID()) def runExperiment(): yield experiment.prepareTrial(experiment.currentPhase()) toFile.newTrial(experiment.getTrialData(), experiment.getTrialNumber()) while True: if(experiment.hasTrialEnded() == False): if(experiment.isNewPhase() == True): yield experiment.prepareTrial(experiment.currentPhase()) toFile.asRaw("<phase_number>" + str(experiment.currentPhase()) + "</phase_number>") if(experiment.currentPhase() == 1): userMovement.disable() yield experiment.runPhase1(JOY_YES = userMovement.returnButtonYES(), JOY_NO = userMovement.returnButtonNO()) elif(experiment.currentPhase() == 2): userMovement.enable() yield experiment.runPhase2(JOY_YES = userMovement.returnButtonYES(), JOY_NO = userMovement.returnButtonNO()) elif(experiment.currentPhase() == 3): userMovement.enable() yield experiment.runPhase3(JOY_YES = userMovement.returnButtonYES(), JOY_NO = userMovement.returnButtonNO()) toFile.asTrialTick(EyeTracker.getCurrentGaze()) toFile.asTrialTick(viz.mouse.getPosition(viz.WINDOW_PIXELS)) else: toFile.endTrial(experiment.getTrialResult()) if(experiment.hasExperimentEnded() == False): yield EyeTracker.driftCorrection() # <------------------------------------------------- Here is where I attempt to carry out a drift correction yield experiment.nextTrial() yield experiment.prepareTrial(experiment.currentPhase()) toFile.newTrial(experiment.getTrialData(), experiment.getTrialNumber()) else: yield experiment.finish() break viz.quit() viztask.schedule(runExperiment()) Thanks |
#2
|
|||
|
|||
Hi Chris,
I think your experiment is doing exactly what it is being told (as computer usually do!). I don't know the nature of your EyeTracker.drifCorrection function, but it appears to me that Vizard is waiting for something that never happens. Yield should only be used for functions that return something to yield for. My guess is that your function does not return a yieldable object, so Vizard will be stuck there. Just deleting yield in front of you EyeTracker.driftCorrection function might do the trick. By the way, the viztask.schedule function only needs at least one yield statement. You have quite a few yield statements in your function, so beware that those functions are yieldable ! |
#3
|
|||
|
|||
Thanks for the reply
I've been trying it with and without the yield statement actually and I get the same results with both. Incidentally, the only reason the yield statement is in the example above is that it happened to be what I had just tested before posting! The experiment actually does do what I tell it to (technically), it just doesn't draw to the screen. For example, when I call my drift correction function the experiment does stop (which is good). The EyeTracker does go in to drift correction mode. The only issue is that the drift correction screen is not drawn to the screen. I can only assume that something is blocking the EyeTracker from drawing to the screen which it should be capable of doing. My EyeTracker.driftCorrection() function simply calls the line: Code:
pylink.getEYELINK().doDriftCorrect(960, 540, 1, 1) |
#4
|
|||
|
|||
Okay, so I figured out why nothing was happening on the screen. I had missed out some code which should have been in my driftCorrection() function:
Code:
def driftCorrection(): pylink.openGraphics((_display_width, _display_height)) pylink.setCalibrationColors((255, 255, 255), (0, 0, 0)) #Sets the calibration target and background color pylink.setTargetSize(int(_display_width / 70.0), int(_display_width / 300.0)); pylink.setCalibrationSounds("", "", ""); pylink.setDriftCorrectSounds("", "off", "off"); print "Called: Drift Correction" pylink.getEYELINK().doDriftCorrect(960, 540, 0, 0) pylink.closeGraphics() In the Vizard output box, I get the following error: pylink.openGraphics((_display_width, _display_height)) RuntimeError: Could not initalize graphics Unfortunately, this isn't helping me much because I run the exact same line of code when calling the calibration routine before the experiment. |
#5
|
|||
|
|||
Sorry for the triple post!
So I have a solution although it's by no means elegant and I am sure there is another way around this. I was getting the graphics error when trying to initialize the graphics when in fullscreen mode. I assume this is because Vizard has some kind of lock on the rendering loop and when trying to initialize a new window from within fullscreen mode, it fails. I've got around the problem by toggling full screen mode OFF before the drift correction function is called and back ON once it has completed: Code:
viz.window.setFullscreen(viz.OFF) EyeTracker.driftCorrection() viz.window.setFullscreen(viz.ON) Does anyone have any ideas? Thanks |
#6
|
|||
|
|||
Bumping the thread as I've had no reply in over a week.
Any ideas on how I can get round this issue without switching to windowed mode at the end of every trial? |
#7
|
|||
|
|||
You could try executing the function in a separate thread. If you've using a task for your program take a look at waitDirector.
|
|
|