Exemple #1
0
import psychopy.visual
import psychopy.event
import sys
import numpy as np

from psychopy_tobii_controller import tobii_controller

# PsychoPy window must be created before initializing tobii_controller.
# Monitor profile must be specified if you want to use cm, deg, degFlat, degFlatPos units.
# See PsychoPy document for monitor profile.
win = psychopy.visual.Window(units='norm', monitor='default')

# Initialize tobii_controller.
controller = tobii_controller(win)

# Open data file if you want to save gaze data.
controller.open_datafile('test.tsv', embed_events=False)

# Show Tobii status display.
# Press space to exit status display.
controller.show_status()

# Run calibration.
ret = controller.run_calibration([(-0.4, 0.4), (0.4, 0.4), (0.0, 0.0),
                                  (-0.4, -0.4), (0.4, -0.4)], )
# If calibration is aborted by pressing ESC key, return value of run_calibration()
# is 'abort'.
if ret == 'abort':
    win.close()
    sys.exit()
    name='before_text',
    text=u'\u6309\u7a7a\u683c\u5f00\u59cb\u773c\u52a8\u6821\u51c6',
    font='Arial',
    pos=(0, 0),
    height=74.45,
    wrapWidth=None,
    ori=0,
    color='white',
    colorSpace='rgb',
    opacity=1,
    depth=0.0)

# Initialize components for Routine "tobii_calibra"
tobii_calibraClock = core.Clock()
from psychopy_tobii_controller import tobii_controller
ptc_controller_tobii_controller = tobii_controller(win, id=0)
ptc_controller_tobii_controller.open_datafile(
    _thisDir + os.sep + 'eyedata' + os.sep + expInfo['participant'] + '_' +
    expInfo['block'] + 'eyedata.xls',
    embed_events=True)

# Initialize components for Routine "before_test"
before_testClock = core.Clock()
before_test_text = visual.TextStim(
    win=win,
    name='before_test_text',
    text=
    u'\u6821\u51c6\u7ed3\u675f\uff0c\u6309\u7a7a\u683c\u5f00\u59cb\u6b63\u5f0f\u5b9e\u9a8c\u3002',
    font='Arial',
    pos=(0, 0),
    height=74.45,