misc

parent 8bd8c15b
......@@ -25,3 +25,4 @@ dependencies:
- pip:
- PyPubSub
- psychopy==3.0.7
- tobii_research
"""Functions and settings for the tobii 4C eye tracker.
Tobii Research "Pro" license is required (to be purchased separately).
"""
import os
import platform
import glob
import subprocess
import tobii_research as tr
def call_eyetracker_manager_calibration(address):
"""Start the Tobii Eye Tracking Manager for calibration."""
try:
os_type = platform.system()
ETM_PATH = ''
DEVICE_ADDRESS = address
if os_type == 'Windows':
ETM_PATH = glob.glob(os.environ['LocalAppData'] +
'/TobiiProEyeTrackerManager/app-*/TobiiProEyeTrackerManager.exe')[0] # noqa: E501
elif os_type == 'Linux':
ETM_PATH = 'TobiiProEyeTrackerManager'
elif os_type == 'Darwin':
ETM_PATH = '/Applications/TobiiProEyeTrackerManager.app/Contents/MacOS/TobiiProEyeTrackerManager' # noqa:E501
else:
raise OSError('Unsupported platform: {}'.format(os_type))
eyetracker = tr.EyeTracker(DEVICE_ADDRESS)
mode = 'usercalibration'
etm_p = subprocess.Popen([ETM_PATH,
'--mode=' + mode,
'--device-address=' + eyetracker.address],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=False)
stdout, stderr = etm_p.communicate()
if etm_p.returncode == 0:
print('Eye Tracker Manager was called successfully!')
else:
print('Eye Tracker Manager call returned the error code: {}'.format(etm_p.returncode)) # noqa: E501
errlog = None
if os_type == 'Windows':
# On Windows ETM error messages are logged to stdout
errlog = stdout
else:
errlog = stderr
for line in errlog.splitlines():
if line.startswith('ETM Error:'):
print(line)
except Exception as e:
print(e)
......@@ -48,6 +48,14 @@ def run_descriptions(events_file, monitor='testMonitor', font='', lang='en'):
txt_stim.height = 1
txt_stim.font = font
# Prepare separation line
line_stim = visual.Line(win,
units='deg',
start=(0, -0.5),
end=(0, 0.5),
lineWidth=1,
lineColor=txt_color)
# Start a clock for measuring reaction times
# NOTE: Will be reset to 0 right before recording a button press
rt_clock = core.Clock()
......@@ -90,10 +98,11 @@ def run_descriptions(events_file, monitor='testMonitor', font='', lang='en'):
mag1_2 = setting[0, 5]
prob1_2 = setting[0, 7] * 10
txt_stim.text = ''
txt_stim.text += '{} - {}% | '.format(mag0_1, prob0_1)
txt_stim.text += '{} - {}%'.format(mag0_1, prob0_1)
txt_stim.text += '{} - {}%\n'.format(mag1_1, prob1_1)
txt_stim.text += '{} - {}% | '.format(mag0_2, prob0_2)
txt_stim.text += '{} - {}%'.format(mag0_2, prob0_2)
txt_stim.text += '{} - {}%'.format(mag1_2, prob1_2)
line_stim.draw()
txt_stim.draw()
rt_clock.reset()
onset = exp_timer.getTime()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment