IOHub basic Stroop Demo not working

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)

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.

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!!!

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.

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.

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.

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.

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.

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.

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

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.

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.

(Sol have a good vacation. I am taking time off this quest.)

All
I will go through your questions 1 by 1 but I have 2 general conclusions.
1. PsychoPy3 standalone with MacOS 10.14.5 will not work with IOHub because it requires Security and Privacy > Accessibility. When I check PsychoPy3 (3.1.2) and launch PsychoPy3 (or 2), my system freezes for ~20 seconds at a time. Launching a program takes several mins. I have found this also on a friends computer.
2. PsychoPy3 Standalone (3.1.2) with MacOS 10.13.6 does work, but not all of IOHub is properly installed. I know this because I can get the (coder) demos keyboard.py and mouse.py work in an Anaconda/Spyder environment where I added: pip install psychopy. However in the standalone, anywhere that requires a keyboard response (keyboard.py or keyboard input to mouse.py) does not work. Neither does the stroop demo (with yaml file) — displays stimulus but will not take a keyboard response.

I am not sanguine about my ability to get the tobii to work with PsychoPy now. In one email to Jon you asked was tobii_research (tobii-research? tobiiresearch?) installed in the standalone PsychoPy3. How can I tell? How would I add it to Spyder. I tried “pip import tobii_research” (and all variations) and got nothing. Once that worked in the terminal, but not now.

Now to your questions:

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.
Exactly!

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.
It takes about a few minutes before a program runs (as described above), but I think you are correct, ball of death for ~30 secs and then ~ can not connect to iohub.
What version of the psychopy standalone were you running BTW?
Sorry that is critical. Standalone 3.1.2. But I have also tried everything with 1.90.3. (I wasted a lot of time with below 3.1.2, like 3.1.0.)

I should take some time off from making tobii work with PsychoPy. The book made it sound so easy. There is the matter of getting the correct yaml file (the one referred to in book is wrong). Knowing what components are installed and what I need to worry about.

Bill Prinzmetal
(510)685-8623
billprinzmetal@gmail.com

Yes, that was a typo; the package is called tobii-research, latest version is 1.7 and it supports Python 3.6. It is on pypi.

I installed it into my python env using:

pip install tobii-research

I can not really help you get it working on macOS 10.13+ as I do not have that OS. If you have a Windows computer you could test on I can help with that.

I have tried to do “pip install tobii-research” (https://pypi.org/project/tobii-research/ ) . Always fails. I usually get something like:

No matching distribution found for tobii-research on a PC and a Mac (both command line[PC] or terminal [Mac]) and also in the respective (PC and Mac) Anaconda/Spyder consoles.

I can make the coder demo for Mouse.py, Keyboard.py and stroop_keyboard apps work with PsychoPy on a PC and with Spyder on Mac.

When I try the eye movement examples, e.g., selectTracker the first hiccup is

"try:
import tobii_research #in tobiiwrapper.py”

But I don’t remember whether that error message was from PsychoPy standalone or Spyder.

Question, if I am running standalone PsychoPy 3.1.2 on a PC is it necessary for me to install the tobii-research to run the tobii eye-tracker?* It may be replaced by Psychpy code or installed in standalone psychPy. The textbook (“Building experiments…”) does not mention a step like that. If I need it for the anaconda version (to run on a mac) then I will put it off. The programs I have tried and failed are selectEyetracker, stroop_eyetracking (stroop.psyexp), and simple.py. But the cause of the failure could be anything, like the .yaml file or in programs without a .yaml file, my code editing, or some change from Python2 to Python 3. If “install tobii-research” not necessary I will stick to standalone PsychoPy on a PC until the next version of PsychoPy comes out. I am hoping that that version will overcome Apple’s security problem with Privacy>Accessibility. It must be possible because Anaconda/Spyder ioHUB programs (stroop, keyboard.py, mouse.py) runs fine on my mac. Its too bad that I can’t simply “pip install tobii-research” like I installed “pip install psychopy” because Spyder is easier for me to work with. But if standalone PC will run programs to control the tobii, I will stick to that while I am learning.

If install tobii-research is necessary I will have to spend several days installing the .whl file.

(Attachment tobii_std.txt is missing)

I have tried to do “pip install tobii-research” (https://pypi.org/project/tobii-research/ ) . Always fails. I usually get something like:

No matching distribution found for tobii-research on a PC and a Mac (both command line[PC] or terminal [Mac]) and also in the respective (PC and Mac) Anaconda/Spyder consoles.

I can make the coder demo for Mouse.py, Keyboard.py and stroop_keyboard apps work with PsychoPy on a PC and with Spyder on Mac.

When I try the eye movement examples, e.g., selectTracker the first hiccup is

"try:
import tobii_research #in tobiiwrapper.py”

But I don’t remember whether that error message was from PsychoPy standalone or Spyder.

Important Question, if I am running standalone PsychoPy 3.1.2 on a PC is it necessary for me to install the tobii-research to run the tobii eye-tracker?* It may be replaced by Psychpy code or installed in standalone psychPy. The textbook (“Building experiments…”) does not mention a step like that. If I need it for the anaconda version (to run on a mac) then I will put that project off for a while. The programs I have tried and failed are selectEyetracker, stroop_eyetracking (stroop.psyexp), and simple.py. But the cause of the failure could be anything, like the .yaml file or in programs without a .yaml file, my code editing, or some change from Python2 to Python 3. If “install tobii-research” not necessary I will stick to standalone PsychoPy on a PC until the next version of PsychoPy comes out. I am hoping that that version will overcome Apple’s security problem with Privacy>Accessibility. It must be possible because Anaconda/Spyder ioHUB programs (stroop, keyboard.py, mouse.py) runs fine on my mac. Its too bad that I can’t simply “pip install tobii-research” like I installed “pip install psychopy” because Spyder is easier for me to work with. But if standalone PC will run programs to control the tobii, I will stick to that while I am learning.

bp

The https://pypi.org/project/tobii-research/ site allows one to download lots of different “wheel” files but I do not know what do with them.

Hal (and others)

I finally figured out why I couldn’t install tobii-research. Small detail, which maybe obvious to everyone but me:
Console (windows) must be run as administrator.
Terminal (mac) must be run with root user enabled.

I know they both are installed because I can type to the shell: install tobii_research without an error.

But that is as far as I got.
I gave up using a mac with iohub, that is a mess (even with PsychoPy3.0.3). I will post separately about that.

With a PC I can run with iohub

  1. stroopkeyboard (builder)
  2. mouse.py
  3. keyboard.py

But all the demo programs with a tobii fail:

  1. stroopeyemovement (builder)
  2. validation.py (set us for tobii)
  3. selectTracker

They all end with this on the screen:
“Press SPACE to Start Calibrate: esc to exit”

I will list sample error message below. This is with Windows Home Edition 64
(The tobii works with tobii’s software.)

File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\iohub\devices\eyetracker\hw\tobii\eyetracker.py”, line 166, in runSetupProcedure
calibrationOK = genv.runCalibration()
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\iohub\devices\eyetracker\hw\tobii\tobiiCalibrationGraphics.py”, line 361, in runCalibration
calibration.enter_calibration_mode()
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\tobiiresearch\implementation\ScreenBasedCalibration.py”, line 168, in enter_calibration_mode
interop.calibration_enter_calibration_mode(self.__core_eyetracker)
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\tobiiresearch\interop\interop.py”, line 217, in calibration_enter_calibration_mode
interop.calibration_enter_calibration_mode(self.__core_eyetracker)
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\tobiiresearch\interop\interop.py”, line 217, in calibration_enter_calibration_mode
_on_error_raise_exception(status[0])
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\tobiiresearch\implementation\Errors.py”, line 176, in _on_error_raise_exception
raise EyeTrackerDisplayAreaNotValidError("The display area is not valid. " + str(status))
tobiiresearch.implementation.Errors.EyeTrackerDisplayAreaNotValidError: “The display area is not valid. ‘display_area_not_valid’”

Apparently after 9 months of messing around, the tobii 4c will not work with PsychoPy:
https://discourse.psychopy.org/t/eyectracker-tobii-4c-works-on-psychopy/2774

It seems all the inexpensive eye trackers will not work with IOHub unless one finds a used model of one that will. I hope to find out which models work. EyeX? or ?

No I never got the eye movement working properly. The big problem that I had was that I had a Tobii 4c and that will not work with PsychoPy, see this Post:

So then I bought a Tobii EyeX (used on eBay) and I couldn’t get that to work either, but I didn’t spend much time on it. I started to have health problems which made me have to start doing research. I think I may have been able to get the Tobii to work, but dealing with illness and software was a little too much. You didn’t say what kind of eyetracker you were using. Also are you using a Mac or PC?

A friend sent me a more recent article about another library that uses Psychopy to do eye movements. I can’t find that now. But I’ll keep looking and if/when I find it, I’ll post it.

I found many examples that used a yaml file, but only a very few that didn’t use a yaml file. The problem is, within PsychoPy I couldn’t find any documentation on how one writes a yaml file. There are many many sample programs hidden within the PsychoPy container. Both builder and coder. Poke me in a week, and I’ll see if I found anything. billprinzmetal @ gmail . com

The iohub Tobii interface uses the tobii-research (tobii_research) package, which as I understand, should support all Tobii trackers (EDIT: I was wrong it only supports their research grade eye trackers). I have an old T120 to test with. I was told in the Fall of 2019 that it had also been tested and worked with a Tobii Spectrum running at 1200 Hz.

I mainly use a PC (win10), but am in the process of retesting the demo’s on all platforms. What os are you using? For macos I’m testing with Catalina.

I have also recently fixed some general iohub bugs that have come up over the year because of changes in python packages used by iohub. I think Jon is planning on doing a build that will include these fixes in a few weeks.

Let me know when you are looking at this again and I can try to help figure out what is going wrong.

Thank you.