psychopy.org | Reference | Downloads | Github

IOHub basic Stroop Demo not working

#1

Mac OSX 14.14
Stand alone PsychoPy2 (v1.90.3)
Stand alone PsychoPy3

I stated trying to make a Tobii eye tracker work with PsychoPy3, but that was way beyond me.

I downloaded PsychoPy2, and just tried the demo Stroop (ioHUB keyboard). It only involves a keyboard so it should work. But it didn’t. I will attach the file and the .yaml file, although its within PsychoPy. I changed the .yaml to .py so you will have to change it back. It crashes at:
io = client.ioHubConnection(io_config) It does write an empty .hdf5 file.

I know it opens the yaml file. I have tried all kinds of variations. I tried all kinds of variations with the tobii and the code in Chapter 19 of the PsychoPy book (excellent, BTW). I get the same error. I changed the screen dimensions in the yaml file to fit my screen, and other things. The yaml file is in the same folder as the program.

Jon once suggested that I use the shell to find out what is being loaded. With the Tobii eyetracker example this is the slimmest thing I could do. First, I am sure I am in the correct folder.

import psychopy
from psychopy.iohub import util, client
config_file = ‘tobii_std.yaml’
io_config = util.readConfig(config_file)
io = client.ioHubConnection(io_config)

Traceback (most recent call last):
File “”, line 1, in
File “/Users/williamprinzmet/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/iohub/client/init.py”, line 290, in init
RuntimeError: Error starting ioHub server

I thought something might be wrong with my computer so I reinstalled the OS 3 times and ran every diagnostic I could think of. I get the exact same error with PsychoPy2 and PsychoPy3. Need some new ideas to try. Could I have something running that interferes with the ioHUB. Turned off virus protection, etc. In system settings>privacy>accessibility allow PsychPy to do whatever.

iohub_config.py (582 Bytes)
stroop.psyexp (13.8 KB)

#2

It is probably better to try and work with the latest PsychoPy3 Python 3.6 standalone and start from basics and build up from there.

Re iohub keyboard / mouse demo’s:

Did you add the PsychoPy3 app to authorized application list, or whatever macOS calls it now? You need to do this or iohub can not get keyboard or mouse events.

Any of the demos/coder/iohub examples should now work (in the case of eyetracking, if eye tracker device is supported on macOS). Your post reminds me that I need to check if the Builder iohub demos also work; I’ve only been thinking in Coder space.

Re eye tracker support:

We have done a lot of work getting iohub working again in PsychoPy3 / Python 3, including support for keyboard and mouse, as well as these eye trackers: gazepoint, tobii, and sr research.

Using the latest PsychoPy3 source and Windows 10 I am able to run all the coder eye tracker demos with all a GazePoint GP3, SR Research EyeLink 1000, and Tobii T120 with the following notes:

  1. Last I checked, the latest Tobii Python SDK supports up to Python 3.5. PsychoPy standalone supports Python 3.6. So to use the Tobii you will need to setup a Python 3.5 environment with all the needed dependencies. I am not the best one to explain how to do this on macOS. When Tobii releases a version for Python 3.6, then I believe Jon will start to include it in the macOS and Windows builds for Python 3.6.

  2. I have not tested the Tobii on macOS yet. I would like to wait until they support Python 3.6 to do so as I do not really want to spend the time getting 3.5 setup. ;(

Thanks again.

#3

Sol,

Thank you for all the work you have done with PsychoPy and your suggestions.  Later this week I am working with an undergraduate who understands Python better than I do.  We will have 3 Macs, so we can see if it's my Mac or something else.  Let me tell you what I have tried and what worked and did not work.  (Explicit questions in green.)

1. I went back to a simple keyboard IOHub program, Stroop example, which I found buried in PsychoPy. **It did not work on my Macintosh, so then I tried it on an old PC I own and it worked with PsychoPy3!!  **There were a lot of warnings and I do not know what version of Python it used. In PsychoPy3 there is a window for selecting version of PsychoPy, what should I chose, “latest” or something else.
2. Next I tried the Stroop with eye movements on the PC. It didn’t work but I didn’t get the message that it did not connect to iohub. It just didn’t start up the Tobii. I think I have to do that with the Tobii software controller, which I did have on my mac, but erased it (thinking that was the problem).  I think I have to maybe use Tobii’s software to get it started, what do you think?

3. On the Mac System Preference > Security and Privacy > Accessibility I have allowed PsychoPy2 and PsychoPy3 to control my computer.

4, Actually I now have 3 example builder programs and accompanying yaml files: (1) Chapter 19 and link on pg 258. Note that link is 404, but I could find the file; (2) [https://github.com/aleksandernitka/EyeTracking_Tobii_PsychoPy_IOHUB/find/master](https://github.com/aleksandernitka/EyeTracking_Tobii_PsychoPy_IOHUB/find/master) which needs a few corrections for Python3; (3) The stroop IOhub eyemovement (and keyboard). Since I can get the keyboard version to work, I will start there this afternoon on the PC, then move back to the mac.

5. Question about yaml files. For monitor_devices, is the “device_number” then same as the PsychoPy screen number?

I have a path forward. Get the stroop eye movement to work on PC. Try it on different macs, then …

The questions are:

	(1) Should I use Tobii’s software to start things?

	(2) What version of PsychoPy should I chose?  Latest?

	(3) Does device_number = screen number

I will make it work!!!

#4

For what it’s worth, I’ve noticed some similar issues with iohub from Builder, on the latest version of Pyschopy on 10.14.4

I can run PYTHONHOME=/Applications/PsychoPy3.app/Contents/Resources /Applications/PsychoPy3.app/Contents/MacOS/python stroop.py without issues, but if I try to launch the same experiment from within Builder, iohub fails to start up. It also hangs for a while - I’m assuming it’s trying and failing to create a connection to the iohub process.

No clue why, unfortunately.

#5

Thanks for the tip; this may help explain some things. No clue why either, but knowing an issue exists is the first step in fixing it I guess.

#6

Hi Bill,

Thanks for your perseverance. We will figure this out. :wink:

I have a path forward. Get the stroop eye movement to work on PC…

This is a good plan. I would maybe add a first step of getting one of the eye tracker coder demos running that I know should work. Lets focus on the using the most current code / examples, so if / when issues are found we can fix them and submit the fixes.

If the goal is to use a Tobii, then also keep in mind you will need to use Python 3.5 and install the necessary psychopy / iohub / tobii dependencies. The iohub Tobii implementation now uses their latest Python SDK, the tobii_research module. It can be installed using pip if you are setting up your own Python 3.5 env:

pip install tobii_research

If you have access to a Windows 7/10 computer I can private msg you a link to a WinPython 3.5 distro that I’ve setup with psychopy and dependencies that I have been using for the tobii testing. This maybe the fastest way to get something up and running.

(1) Should I use Tobii’s software to start things?

No you should not have to. I have been using the TobiiProEyeTrackerManager app to check that I can see the T120, but that should not be needed to run an experiment.

What version of PsychoPy should I chose? Latest?

Since you are going to be setting up your own python env, may as well use the latestpsychopy master branch source and ‘python setup.py install’ it.

(3) Does device_number = screen number

If you mean the eye tracker device_number, then it can be used to indicate the index of the tobii tracker you want to connect to. By default it should be 0. It is only useful if you have > 1 Tobii connected to your experiment computer / network and do not want to use the model name or serial number to indicate which Tobii device iohub should be used.

I’m going to test the iohub Builder examples on Windows 10 with Python 3.5 and 3.6 today so we should know where that is at soon.

Thanks again.

#7

Ari and Sol,
Yesterday was 3 steps backward.

First, the behavior I Ari described, the builder stalls on connecting to the ioHUB is exactly what happens.  But I can find the stroop.py that Ari describes.  Could you send it to me?  Its not in the standalone PsychoPy 3.10.  Then I can compare, line by line the demo Stroop.py and the Stroop.py that builder makes from Stroop.psyexp

Secondly, stupidly I installed Tobii’s software on my PC and now PsychoPy will not run at all. I will not get to try and fix that until tomorrow.  I should have waited for Sol's email.  I work too hard going no where.

I have installed the standalone version of PsychoPy.  The latest version is 3.10.  It includes Python 3.6, but I may have too many version of Python.   I could try the manual install, but I would like to have the coder demo stroop.py. I have been afraid to do the manual install because I don’t understand Unix.  But I did manage to install pip and pip install tobii_research.  I am working with a student today who did a manual install on his computer.  He thinks maybe I have too many Pythons installed.  I will see what we can do and get back to you all.

Your responses definitely helped!  I will work on the mac today.  I will perhaps get back to the PC tomorrow.  My problem might only be my mac, and something that was installed and then didn’t get properly uninstalled. I will find out today.

Thank you very much.
#8

Tested demos/builder/iohub/stroop_keyboard and demos/builder/iohub/stroop_eyetracking on Windows 10 with Python 3.5 and PsychoPy3 3.1.1 and both run OK as long as you do not use the SMI config file. For Tobii, enter tobii_std.yaml when prompted.

I did a pull request to remove the no longer supported eye trackers from the demo and add a default file for the gazepoint GP3. The demo code is unchanged other than the default eye tracker file name.

#9

I also just realized that Tobii has added Python 3.6 support for tobii_research. I installed it on my Windows 10 Python 3.6 env and the iohub demos work well.

@jon, could you please add tobii_research to the next standalone installers for Windows and macOS Python 3.6? I’ll update the doc page to indicate 3.6 is now supported.

Thanks.

#10

Yep, that’s done for all of Mac (3.6) Win32 (2.7 and 3.6) and Win64 (3.6). They’ll be available in PsychoPy 3.1.2 (hopefully out tomorrow)

1 Like
#11

Sol, (and other who will help)

        For about 6 months I

have been trying to get a Tobii eye tracker to work with ioHUB with builder
standalone PsychoPy. But besides complaining I had no positive information to
add to help solve to problems. Now I hope I can help; I understand what needs
to be fixed.

        I made 4 changes to my

approach. (1) I used several different Macintoshes running Mojave (OSX
10.14.5), and an older version High
Sierra (10.13.6). (2) I chose 2 programs that I could not mess up, coder
examples of ioHUB: keyboard.py, mouse.py (/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/demos/coder/iohub/).
These programs do not even involve a yaml file so there is no way I can mess
then with my incompetence. (3) Finally, for fun, I installed
Anaconda/Spyder/PsychoPy (Anaconda). This might be a stand in for a manual
install of PsychoPy. I know it works because when I created .py files with my
most complex .psyexp experiments, they ran flawlessly. (4) Maybe most importantly
I tried to run the experiments with Apple Security & Privacy > Privacy

Accessibility turned on or off for PsychoPy3 (hence Accessibility). I also
ran PsychoPy2. This is a 5-factor fully crossed design.

      The results are easier to report. There are two problems,

one large and one smaller.

First,
Mojave: Standalone PsychoPy3 (& 2) is a disaster with Accessibility
turned on. Furthermore, ioHub will not run with accessibility turned off. I found
on 2 different computers that Accessibility on, running Standalone had the
result of freezing the computer for ~30 seconds at a time. I tried to
understand what was frozen by running Activity Monitor, but that was frozen

With Mojave: Anaconda, the two programs ran flawlessly.
Only with Accessibility turned on.

    Second, High Sierra, **Accessibility off**, Standalone

PsychoPy ran part of both programs, but kb_events = keyboard.getEvents() never
returns anything.

With
Anaconda both programs work fine (they need an io.exit() at the end).

Summary, when Apple went from High Sierra to Mojave they
changed many things about Security/Accessibility that breaks Standalone
PsychoPy. There are many post like https://www.appleworld.today/blog/2018/9/28/mojave-security-changes-make-sure-your-backups-are-running-properly
. Second, there are parts of psychoPy3 that didn’t make it into the Standalone
version (i.e., keyboard responses).

What about my original problem, running a Tobii eye
tracker? I know I can only run it on High Sierra which is a problem because I
can’t go backwards in OS and all but one lab computers are running Mojave. Or I can write strictly code, which I am not going to
do. I have been writing code since 1965
and that is the reason I went to PsychoPy. No more code only. In a few days I
will try to see what works with High Sierra and eyetracking, possibly writing experiments
in builder but transferring code to Anaconda.

P.S. Apple is making it increasingly difficult to let
independent developers distribute code not through the App Store. At some point
they may cross the line.

#12

Thanks very much for all your testing Bill.

For any version of macOS, iohub experiments need to have Accessibility enabled for the app that is starting the iohub process or you will not get keyboard / mouse events. So part of your findings are expected.

So it sounds like there are issues running iohub on macOS 10.14 when using the standalone PsychoPy installer but not when using an anaconda environment.

It sounds like when using the standalone PsychoPy installer on macOS 10.14 the experiment process is not able to connect to the iohub server process. I think the timeout for that is set to a (very large) value of 30 seconds.

What version of the psychopy standalone were you running BTW?

This is good news. Can you use the Anaconda env. you have on macOS 10.14 until the standalone issue is resolved then?

Since Accessibility was off, this is expected behavior.

What were the results of running stand alone on 10.13 with Accessibility enabled for the PsychoPy3 app?

(using) Mojave …

If your anaconda setup is working on macOS 10.14, I wonder if you could start PsychoPy Coder/Builder from anaconda:

python psychopy/app/psychopyApp.py

You may still need to run your built scripts from console, which you have confirmed you can do.

This is also good and matches what I find.

I will be away (moving) for a couple weeks so I may not be able to reply immediately.