psychopy.org | Reference | Downloads | Github

Iohub demo is not working

OS Win10:
PsychoPy version 1.84.2:
Standard Standalone
Builder

Hi,
I am looking to measure “keyup” which, as I understand it, can only be done with ioHub. I downloaded the latest standalone version of PsychoPy and installed it on 2 different Windows 10 laptops. In both cases the ioHub demo runs but does not work (it does not register any keypresses after the initial screen). When I escape the experiment, I get the following error message (in green font):
“pygame audio lib was requested but not loaded: No module named Pygame”.
"… sitepackages\openpyx\reader\worksheet.py:322: UserWarning: Unknown extension is not supported and will be removed
warn(msg)"

It’s the same on both computers and interestingly, the ioHub demo seems to be the only demo that is not opening automatically from the Builder menu bar - I had to go to the demos folder and start it manually on both computers, while the other demos opened from within the demos tab in Builder.
Thanks,
Mark

Yeah apparently the code component contains bugs. Go to the trials routine and check out the iohub_keyboard code component. Under Each Frame, it currently says:

if frameN == 0:
    io.clearEvents('all')
    trial_start=core.getTime()
else:
    iokeys=iokeyboard.getEvents(EventConstants.KEYBOARD_CHAR)
    for iok in iokeys:
        if iok.key in [u'DOWN',u'LEFT',u'RIGHT']:
            response_event=iok
            continueRoutine = False 
            break

On my system, iokeyboard.getEvents(EventConstants.KEYBOARD_CHAR) does not record any keyboard events at all. So I changed it to iokeys=iokeyboard.getEvents(EventConstants.KEYBOARD_PRESS) to get PRESS events (you could also change it to ....KEYBOARD_RELEASE) for RELEASE events).

if iok.key in [u'DOWN',u'LEFT',u'RIGHT']: will also not work, because the keys are reported as lowercase letters.

So to fix the demo, change the abovementioned code block to:

if frameN == 0:
    io.clearEvents('all')
    trial_start = core.getTime()
else:
    iokeys = iokeyboard.getEvents(EventConstants.KEYBOARD_PRESS)
    for iok in iokeys:
        if iok.key in ['down', 'left', 'right']:
            response_event = iok
            continueRoutine = False 
            break
1 Like

Hi Richard,
Sorry for the very late reply and thanks very much for solving the problem.