experiment freezes during drift correct
Hello,
I am using a Tobii120 and running an experiment on OpenSesame. I do not have any problems with the calibration or with the other pygaze plugins, but the experiment freezes when it comes to drift correct. I used pygaze_init at the beginning of the experiment, then comes the instructions. During the trial sequence, I have pygaze_drift_correct, pygaze_start_recording, fixation dot, sketchpad, sampler, media_player_mpy, keyboard_response, logger, pygaze_log, pygaze_stop_recording in this order.
During the first trial, I do not see a fixation dot with the pygaze_drift_correct, but the experiment continues. And after the video file, I need to press space to move to the next item, but the experiment freezes. When I abort using esc-Q, I get the message that it was aborted at the drift_correct. I do not know what the exact problem was because I do not get an error message. If I remove the drift_correct, but the other pygaze plugins in, the experiment runs smoothly. Does anyone have any ideas why this happens?
Thanks,
Figen
Comments
Hi Figen,
Unfortunately, I cannot help you (I don't have any eye tracker available), but to make sure that the problem is really related to the eye tracking part of your experiment, can you try to simplify it as much as possible? That is, remove items that are not necessary (i.e. sampler and media player). Does the experiment that still freezes on the drift correct?
Eduard
Hi Eduard,
Thanks for your reply. I simplified the experiment following your suggestions and it still freezes during drift-correct plugin. The other pygaze plugins run perfectly.
Figen
Hi Figen,
Thanks for trying. Unfortunately, without a (Tobii) eyetracker, I am at a loss here. Maybe @Edwin can help?
Eduard
Hi Figen,
Interesting problem; wouldn't really know how to solve it without more debugging access. Perhaps a simpler fix would be to simply put in your own drift check by using an inline_script. You would use this inline_script instead of a drift_correction, and the code in the Run Phase of the inline_script should look like this:
# Set the fixation position. (Example is screen centre.) fix_pos = (int(var.get("width")/2), int(var.get("height")/2)) # Set the maximum allowed distance (in pixels) between fixation target and fixation. max_dist = 60 # Create a canvas instance. screen = Canvas() # Draw the fixation dot. screen["fix_dot"] = Circle(x=fix_pos[0], y=fix_pos[1], r=10, fill=True) # Create a keyboard instance. kb = Keyboard(timeout=None) # Create a synth instance. beep = Synth(freq=440, osc="sine", length=200) # Loop until the fixation is OK. fixation_confirmed = False while not fixation_confirmed: # Check if a key was pressed. key, press_time = kb.get_key() # If Escape was pressed, calibrate the tracker. if key.lower() in ["Esc", "Escape"]: fixation_confirmed = True pygaze_eyetracker.calibrate() # Do a fixation check. elif key.lower() == "space": # Get a sample from the eye tracker. gaze_pos = pygaze_eyetracker.sample() # Measure how far it is from the fixation. d = math.sqrt((gaze_pos[0] - fix_pos[0])**2 + (gaze_pos[1]-fix_pos[1])**2) # Confirm if the fixation is close enough. if d < max_distance: fixation_confirmed = True else: beep.play()Dear Edwin,
Using an inline_script for my own drift check is a great solution to my problem. However, when I tried to run the code you very generously provided, I came across this error:
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 81, in prepare
self.var.get(u'_run', _eval=False))
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\base_python_workspace.py", line 110, in _compile
return compile(script, u'<string>', u'exec')
Inline script, line 5
^
SyntaxError: invalid syntax
Oh, never mind my previous comment. There were a couple invisible characters in the script, which caused the problem...
Thank you again Edwin, for the idea and also for providing the script. For posterity, I used the below script to solve my drift-correct problem.