WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-06-2014, 08:07 AM
chris2307 chris2307 is offline
Member
 
Join Date: Nov 2013
Posts: 36
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())
I'm hoping it is something obvious but if it's not, please let me know and I'll get more information put up on here.

Thanks
Reply With Quote
  #2  
Old 08-06-2014, 12:44 PM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
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 !
Reply With Quote
  #3  
Old 08-06-2014, 02:12 PM
chris2307 chris2307 is offline
Member
 
Join Date: Nov 2013
Posts: 36
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)
The third parameter specifies that the EyeTracker should draw to the screen for me and release the screen when finished.
Reply With Quote
  #4  
Old 08-07-2014, 06:04 AM
chris2307 chris2307 is offline
Member
 
Join Date: Nov 2013
Posts: 36
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()
However, I now get a black screen SDL application which is separate from the Vizard application. Nothing happens and all keyboard input is blocked so I tab out of it and return the experiment where I can hit escape.

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.
Reply With Quote
  #5  
Old 08-07-2014, 08:05 AM
chris2307 chris2307 is offline
Member
 
Join Date: Nov 2013
Posts: 36
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)
This is, as you can imagine, not the way I want to do things as it looks messy. I need the experiment to be full screen so starting in windowed mode isn't an option either.

Does anyone have any ideas?

Thanks
Reply With Quote
  #6  
Old 08-18-2014, 05:38 AM
chris2307 chris2307 is offline
Member
 
Join Date: Nov 2013
Posts: 36
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?
Reply With Quote
  #7  
Old 08-18-2014, 03:22 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You could try executing the function in a separate thread. If you've using a task for your program take a look at waitDirector.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:27 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC