psychopy.org | Reference | Downloads | Github

Running seperate Windows for Pygame and Psychopy Rating Scale

Hi

I am trying to integrate the Pygaze package for eyetracking and Psychopy. As pygaze creates it’s own window I have used the following workaround, where I create a pygame window that I minimize.
(http://forum.cogsci.nl/index.php?p=/discussion/1640/open-using-pygaze-without-libscreen-in-a-java-application/p1)
I am then able to present stimuli to a psychopy Window ontop of the pygame window which handles eyetracking. Using this workaround meant that I was unable to use the default psychopy.event.getKeys / waitKeys ect, and I have therefore switched to the using the iohub for keyboard inputs
Unfortunately I am also unable to get mouse or keyboard input’s when using the Rating.Scale. probably due to the fact it uses the psychopy.event, instead of the iohub.

import pygame
from psychopy import visual, event

pygame.init()

win = visual.Window()
scale = visual.RatingScale(win, low=1, high=3,mouseOnly=False, singleClick=False,markerColor="blue")

while scale.noResponse:
      scale.draw()
      win.flip()

This code example is unable to take mouse input’s, however removing the pygame.init() makes it function again. This is the same behavior as when I use the pygaze eyetracker, so I use pygame.init() as it is a minimal working example

Is there a way to make psychopy’s rating scale work with Pygame?. perhaps through iohub?.
I have some workarounds in mind,
Right now, im considering 1. getting Iohub mouse input, as I have already done with the keyboard, and then making the rating scale work artificially. 2. modifying the visual.RatingScale.py to use iohub istead of event.Mouse.

I use Windows 7, running 32 bit anaconda python27 with psychopy 1.84.2, an a tobii pro x2-60 eyetracker and tobii SDK 3.2.

Thanks for reading

For RatingScale to work it needs the window that displays it to be active. So you could get participants to click on the psychopy window when it appears to make sure it’s active?

iohub can use keyboard/mouse inputs with any window active (but needs accessibility turned on if you use mac). As you say, then you’d need to spend some time under the hood of rating scale.

Alternatively use iohub instead of pygaze for the eyetracking?

Hi, thanks for the reply

It seems that clicking on the psychopy window does nothing to make it active in a way that thus makes it responsive to the ratingScale. Yes I’ve spent some time under the hood to rewrite the ratingScale, so it uses the iohub instead of event to get mouse\keyboard inputs. And everything works fine. I wouldn’t mind sharing the code, however their dependencies are not entirely my own, but let me know if anyone is in dire need of the same workaround.

As you mention I wouldn’t mind using the iohub for eyetracking (e.i using the iohub exclusively for device inputs). Here, I have once gotten the gcCursor to work and extracting gaze positions using tracker.getPosition(). However I haven’t been able to extract pupil measures from the eyetracker with iohub, whereas I can with pygaze.

With my limited understanding of psychopy & python, I am able to gather that the tracker.getPosition() calls this eyetracking code here, to extract positions. There is some other iohub eyetracking code called [eye_events] (http://pydoc.net/Python/PsychoPy/1.80.07/psychopy.iohub.devices.eyetracker.eye_events/) which does hint at the possibility to extract pupil measures, however I simply have no idea how I would obtain them.