Cedrus Community Forums

Cedrus Community Forums (http://community.cedrus.com/index.php)
-   General (http://community.cedrus.com/forumdisplay.php?f=5)
-   -   problems with Cedrus response pad communicating with PsychoPy via pyxid (http://community.cedrus.com/showthread.php?t=2149)

mcohen1 December 13th, 2015 09:10 AM

problems with Cedrus response pad communicating with PsychoPy via pyxid
I have been trying to get a new fMRI study working with PsychoPy and a Cedrus response pad (via the Cedrus pyxid library). The scanner has an MRA response box that pyxid identifies as a Cedrus RB-834. In testing out my scripts, I've run in to two strange problems.

The first is that the box will work great for a while, but then at some point, it suddenly stops communicating with PsychoPy, and no more input comes in until I stop and reset the script. The amount of time it takes before that happens is variable...but clearly for an MRI study, we don't want that to ever happen, so I'd like to figure out what's causing this.

Another issue is that the communication between the response box and PsychoPy seems to be fairly reliable on a Mac (with the exception of the issue noted above), but on Windows, it's very sporadic. Specifically, when running the pyxid.get_xid_devices() command, it seems to alternate between working and not working, every other time I try to communicate with the button box. I can get around this by running it on my Mac, but it still seems worth seeing if there might be a solution to this, since using a Mac may not always be an option.

Finally, this button box seems to have a number of different modes for communicating with the computer, including XID for SuperLab, and ASCII for Presentation. Both of those seemed to work (although possibly the XID mode was a bit better, in terms of being less likely to fail sporadically). Can you clarify which is actually best for communicating with PsychoPy through pyxid?

I should also note that people using other programs don't seem to be having these issues with the button box, and they're also happening at such a basic level that I don't think my PsychoPy script is the problem; thus, it seems like the glitches are probably in the pyxid library. So any help that you would be able to provide would be really helpful.


Hisham December 15th, 2015 10:26 PM

There is a side effect with the pyxid library that is documented on GitHub, which is that the timer stops after about 4 hours and pyxid will stop reporting keypresses. The solution is simple, if thatís the issue: send a command to reset the built-in timer at least once every four hours.

See also the pyxid read me file.

pyxid can be used with the response pad only in XID mode. If you want to use another, simpler mode like ASCII, then you want to consider using pyserial instead and use it to simply open the serial port and wait for a single byte to arrive on the port, then close the port when youíre done at the end of the experiment.

mcohen1 December 16th, 2015 03:35 PM

1 Attachment(s)
Thanks for the reply. As it turns out, I'm pretty sure that the issue you indicated isn't the problem, as I do reset the base timer at the top of my script, and my test run lasts much less than 4 hours. Instead, with further troubleshooting, it's looking like the real problem is a different issue that has been documented on GitHub (https://github.com/cedrus-opensource/pyxid/issues/4). When I replaced the version of pyxid that is distributed with PsychoPy v1.83 with the one found at https://github.com/cedrus-opensource...7d309c274f4042 , I think the problem is resolved.

I'm a little bit confused because what's available online says that pyxid and PsychoPy were already updated two years ago to address this problem. And in fact, both the version of pyxid included with PsychoPy v1.82, and the version of pyxid currently listed as most recent on GitHub, both seem to include a version of the key code snippets in the above linked version. But the pyxid library in PsychoPy v.1.83 seems to be different, and the relevant code there matches the code from the v1.0 version of the library, released in 2011. I've attached here the internal.py file from the pyxid library included with PsychoPy v1.83 (with .txt added to go around the file type filters on this message board); could you confirm whether this is in fact an old version, or what the issue is? If so, I'd say it looks like this old version of pyxid was mistakenly included with the new version of PsychoPy.

Finally, thanks for the explanation about XID vs. ASCII response modes, that is helpful.


Eugene December 17th, 2015 03:10 PM

Thank you very much for looking into this and attaching the file!

It indeed matches a version of that file back from 2011, so that appears to be the issue. Someone over at PsychoPy should probably be notified of this, so the problem can be fixed in the next release.

All times are GMT -7. The time now is 08:06 PM.

© Copyright Cedrus Corporation, 1991-2014.