Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes plus compatibility with OpenSesame 4.0 #175

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

File renamed without changes
2 changes: 2 additions & 0 deletions opensesame_plugins/pygaze/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The name of the packages to check for updates on conda and pip
packages = ['pygaze']
40 changes: 40 additions & 0 deletions opensesame_plugins/pygaze/pygaze_drift_correct/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Performs eye-tracker drift correction"""

category = 'PyGaze'
priority = 10
help = 'manual/eyetracking/pygaze'
icon = 'os-pygaze_drift_correct'
controls = [
{'type': 'line_edit',
'var': 'xpos',
'label': 'X position',
'tooltip': 'X coordinate for drift correction'},
{'type': 'line_edit',
'var': 'ypos',
'label': 'Y position',
'tooltip': 'Y position for drift correction'},
{'type': 'line_edit',
'var': 'target_color',
'label': 'Target color',
'tooltip': 'Color for the drift-correction target',
'name': 'line_edit_target_color'},
{'type': 'combobox',
'var': 'target_style',
'label': 'Target style (OpenSesame >= 2.8.0)',
'options': ['default',
'large-filled',
'small-filled',
'large-open',
'small-open',
'large-cross',
'small-cross'],
'tooltip': 'Style for the drift-correction target',
'name': 'combobox_target_style'},
{'type': 'checkbox',
'var': 'draw_target',
'label': 'Show display with drift-correction target',
'tooltip': 'Indicates whether a drift-correction display should be shown'},
{'type': 'checkbox',
'var': 'fixation_triggered',
'label': 'Fixation triggered (no spacebar press required)',
'tooltip': 'Indicates whether drift correction should be performed as soon as a stable fixation is detected'}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"""This file is part of PyGaze.

PyGaze is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

PyGaze is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PyGaze. If not, see <http://www.gnu.org/licenses/>.
"""

import inspect
from openexp.canvas import Canvas
from libopensesame.item import Item
from libqtopensesame.items.qtautoplugin import QtAutoPlugin
from pygaze.display import Display


class PygazeDriftCorrect(Item):

def reset(self):
self.var.xpos = 0
self.var.ypos = 0
self.var.fixation_triggered = u'no'
self.var.target_color = u'[foreground]'
self.var.target_style = u'default'
self.var.draw_target = u'yes'

def prepare_drift_correction_canvas(self):
"""A hook to prepare the canvas with the drift-correction target."""
if self.var.draw_target == u'yes':
self.dc_canvas = Canvas(self.experiment)
self.dc_canvas.fixdot(
self.var.xpos, self.var.ypos, color=self.var.target_color,
style=self.var.target_style)
else:
self.dc_canvas = None

def draw_drift_correction_canvas(self, x, y):
"""A hook to show the canvas with the drift-correction target."""
if self.dc_canvas is not None:
self.dc_canvas.show()

def prepare(self):
super().prepare()
self.prepare_drift_correction_canvas()
self.experiment.pygaze_eyetracker. \
set_draw_drift_correction_target_func(
self.draw_drift_correction_canvas)

def run(self):
self.set_item_onset()
xpos = self.var.width / 2 + self.var.xpos
ypos = self.var.height / 2 + self.var.ypos
while True:
success = self.experiment.pygaze_eyetracker.drift_correction(
pos=(xpos, ypos),
fix_triggered=self.var.fixation_triggered == 'yes')
if success:
break


class QtPygazeDriftCorrect(PygazeDriftCorrect, QtAutoPlugin):

def __init__(self, name, experiment, script=None):
PygazeDriftCorrect.__init__(self, name, experiment, script)
QtAutoPlugin.__init__(self, __file__)

def init_edit_widget(self):
super().init_edit_widget()
self.custom_interactions()

def apply_edit_changes(self):
if not super().apply_edit_changes() or self.lock:
return False
self.custom_interactions()

def custom_interactions(self):
"""Disables the target-style combobox if no target display should be
drawn
"""
draw_target = self.var.draw_target == u'yes'
self.combobox_target_style.setEnabled(draw_target)
self.line_edit_target_color.setEnabled(draw_target)
107 changes: 107 additions & 0 deletions opensesame_plugins/pygaze/pygaze_init/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
"""Initializes and calibrates the eye tracker"""

category = 'PyGaze'
priority = 10
help = 'manual/eyetracking/pygaze'
icon = 'os-pygaze_init'
controls = [
{'type': 'combobox',
'var': 'tracker_type',
'label': 'Select tracker type',
'options': ['Simple dummy',
'Advanced dummy (mouse simulation)',
'EyeLink',
'EyeLogic',
'SMI',
'EyeTribe',
'OpenGaze',
'Alea',
'Tobii',
'Tobii-legacy',
'Tobii Pro Glasses 2'],
'tooltip': 'A list of supported eye trackers'},
{'type': 'checkbox',
'var': 'calibrate',
'label': 'Calibrate tracker',
'tooltip': 'Indicates whether calibration should be started'},
{'type': 'checkbox',
'var': 'calbeep',
'label': 'Calibration beep',
'tooltip': 'Play a beep when the calibration target jumps',
'name': 'checkbox_calbeep'},
{'type': 'line_edit',
'label': 'Log file',
'var': '_logfile',
'tooltip': 'The name for the log file'},
{'type': 'spinbox',
'var': 'sacc_vel_thr',
'label': 'Saccade velocity threshold',
'min_val': 0,
'max_val': 100000,
'suffix': ' °/s',
'tooltip': 'Velocity threshold for saccade detection algorithm',
'name': 'spinbox_sacc_vel_thr'},
{'type': 'spinbox',
'var': 'sacc_acc_thr',
'label': 'Saccade acceleration threshold',
'min_val': 0,
'max_val': 100000,
'suffix': ' °/s/s',
'tooltip': 'Acceleration threshold for saccade detection algorithm',
'name': 'spinbox_sacc_acc_thr'},
{'type': 'text',
'label': '<b>Warning:</b> PyLink is required for EyeLink functionality and is not installed. Visit http://osdoc.cogsci.nl/manual/eyetracking/eyelink/ for more information.',
'name': 'text_eyelink_pylink_check'},
{'type': 'text', 'label': 'DUMMY', 'name': 'text_pygaze_version'},
{'type': 'line_edit',
'label': 'Alea API key',
'var': 'alea_api_key',
'name': 'line_edit_alea_api_key',
'tooltip': 'The API key provided to you by Alea'},
{'type': 'checkbox',
'var': 'alea_animated_calibration',
'label': 'Animated calibration target',
'tooltip': 'Turn on child-friendly animated calibration targets',
'name': 'checkbox_alea_animated_calibration'},
{'type': 'checkbox',
'var': 'eyelink_force_drift_correct',
'label': 'Force drift correction (for EyeLink 1000)',
'tooltip': 'Turn on active drift correction',
'name': 'checkbox_eyelink_force_drift_correct'},
{'type': 'combobox',
'var': 'eyelink_pupil_size_mode',
'label': 'Pupil-size mode',
'tooltip': 'Determines whether pupil size is recorded as area or diameter',
'name': 'combobox_eyelink_pupil_size_mode',
'options': ['area', 'diameter']},
{'type': 'line_edit',
'label': 'SMI IP address',
'var': 'smi_ip',
'name': 'line_edit_smi_ip',
'tooltip': "The tracker's IP address"},
{'type': 'spinbox',
'var': 'smi_send_port',
'label': 'SMI send-port number',
'min_val': 0,
'max_val': 100000,
'name': 'spinbox_smi_send_port',
'tooltip': 'Port number for sending messages to the SMI tracker'},
{'type': 'spinbox',
'var': 'smi_recv_port',
'label': 'SMI receive-port number',
'min_val': 0,
'max_val': 100000,
'name': 'spinbox_smi_recv_port',
'tooltip': 'Port number for receiving messages from the SMI tracker'},
{'type': 'line_edit',
'label': 'Tobii Glasses IPV4/IPv6 address',
'var': 'tobiiglasses_address',
'name': 'line_edit_tobiiglasses_address',
'tooltip': 'The Tobii Pro Glasses IPv4/IPv6 address'},
{'type': 'spinbox',
'label': 'Tobii Glasses UDP port number',
'var': 'tobiiglasses_udpport',
'min_val': 0,
'max_val': 100000,
'name': 'spinbox_tobiiglasses_udpport',
'tooltip': 'Port number for the Tobii Pro Glasses 2 eye-tracker'}]
Loading