E-Prime button box

985 views
Skip to first unread message

Andrew

unread,
Mar 12, 2014, 2:20:08 PM3/12/14
to psychop...@googlegroups.com
Hi all,

My advisor would like to create a reaction time experiment, but the button box he gave me to work with is the PST E-Prime button box. Is there any way to use this box with PsychoPy? I have searched the documentation, but I couldn't find anything for the PST button box. Any help would be greatly appreciated!

Thanks,
Andrew

Jonathan Peirce

unread,
Mar 13, 2014, 1:10:55 PM3/13/14
to psychop...@googlegroups.com
I don't have one. Hehe, and I wonder how keen they'd be to help! ;-)
But you should be able to communicate with it easily enough if they provide a manual of how its communications work.

Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/f2a612cb-88c1-4ccc-935b-c8b59a9f41ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.


Andrew Poppe

unread,
Mar 13, 2014, 3:02:16 PM3/13/14
to psychop...@googlegroups.com
Yeah, for some reason I'm not optimistic about them sharing a lot of information :) I'm going to fool around with a serial to usb converter, but likely I'll recommend my advisor buy a new box. Would the ioLabs box be the most compatible with PsychoPy?

Andrew Poppe

Graduate Student, Clinical Science and Psychopathology Research Program
University of Minnesota
N427 Elliott Hall
75 E. River Rd.
Minneapolis, MN 55455

Popp...@UMN.edu


Jeremy Gray

unread,
Mar 13, 2014, 3:12:53 PM3/13/14
to psychop...@googlegroups.com
I am pretty sure that ioLabs is no longer in business, unfortunately.

--Jeremy


Sol Simpson

unread,
Mar 13, 2014, 4:19:51 PM3/13/14
to psychop...@googlegroups.com
Someone else had asked a couple months ago about adding PST button box support to iohub, using the streaming serial interface the box supports. That person was in Europe and could not lend me a button box so I could integrate and test it. If you are able to send me (to Ottawa, Canada) a PST BB to borrow for a couple weeks while I poke at adding it to iohub, I would be more than happy too.  

Jared Roberts

unread,
Mar 13, 2014, 4:51:15 PM3/13/14
to psychop...@googlegroups.com
Hi Andrew,

I imagine that it will just be a matter of pressing buttons and seeing what comes out in the serial stream.  Our lab purchased a cedrus response box.  It's pretty nice and the python xid package works fairly well.  I'm pretty sure that the cedrus box is able to emulate e prime's box, so I imagine that e prime's serial codes aren't too crazy.


--
Jared Roberts
Graduate Student
Neuroscience of Memory, Aging and Dementia Lab
Department of Neurobiology and Behavior
University of California, Irvine
"A lost cause can be as spiritually satisfying as a victory." - Robert Heinlein

Jonathan Peirce

unread,
Mar 14, 2014, 8:19:01 AM3/14/14
to psychop...@googlegroups.com
I've used the cedrus box myself and I'm not a particular fan (it has a rather long round-trip for communications and I've had issues with it failing/crashing during long runs.

One of my colleagues recently asked for a Current Designs box. Their fiber optic solution is very expensive, but I believe they have cheaper solutions if you don't need MRI compatibility. Looking forwards to testing that one out.

AND I've recently learned about a new player in the game, from the maker of the BlackBoxToolkit:
    http://www.blackboxtoolkit.com/urp.html
I guess I'm particularly hopeful about this one. They spend all their time on improving/testing timing for computer-based experiments (that's the whole point of the BBTK). It also supports the hardware direct line for use in EEG setups combined with USB for communicating with the host computer. They're bringing me a unit soon for us to test and build in PsychoPy support.

best wishes,
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Nate Vack

unread,
Mar 14, 2014, 9:43:53 AM3/14/14
to psychop...@googlegroups.com
For forp module already in psychopy should (will?) work with the PST
box; the two speak the same protocol. If it doesn't, let me know.

Best,
-Nate
> --
> You received this message because you are subscribed to the Google Groups
> "psychopy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to psychopy-user...@googlegroups.com.
> To post to this group, send email to psychop...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/psychopy-users/f2a612cb-88c1-4ccc-935b-c8b59a9f41ba%40googlegroups.com.

Andrew Poppe

unread,
Mar 14, 2014, 10:09:47 AM3/14/14
to psychop...@googlegroups.com

Great, these are really helpful suggestions/info. I'll try out the forp module first, and then look at trial and error with reading the serial port signal.

Nate Vack

unread,
Mar 14, 2014, 10:54:40 AM3/14/14
to psychop...@googlegroups.com
On Fri, Mar 14, 2014 at 9:09 AM, Andrew Poppe <popp...@gmail.com> wrote:
> Great, these are really helpful suggestions/info. I'll try out the forp
> module first, and then look at trial and error with reading the serial port
> signal.

If the PST box doesn't seem to be sending any data, you might try
writing the byte:

128+64+32+1+4+16

to the port. See Psychtoolbox's CMUBox.m file lines 619-624 for the spec.

It looks like you really only need 128+32. You can send other things
to turn the lights on and off (and maybe individual buttons as well?)

-n

Andrew

unread,
Mar 16, 2014, 8:34:19 PM3/16/14
to psychop...@googlegroups.com, njv...@wisc.edu

Thanks, Nate. I needed to send 128+32 for the box to enable data streaming and to enable button polling. After that, the forp module in psychopy is working correctly. I'll need to write my own code to do the RT stuff, but at least I'm picking up button events. Sol, I'm going to ask my advisor if we have an extra box that we can send you, as asynchronous timing would be preferable to polling the box once per frame. Thanks for offering to take a look at that, and thanks everyone else for your help!

-Andrew

Richard Höchenberger

unread,
Mar 17, 2014, 12:19:46 PM3/17/14
to psychop...@googlegroups.com
On Thursday, March 13, 2014 9:19:51 PM UTC+1, Sol Simpson wrote:
Someone else had asked a couple months ago about adding PST button box support to iohub, using the streaming serial interface the box supports.

That was actually me :) I am currently using the box via a plain PySerial interface. For collecting response times, I'm using threads and a global variable. Seems to be working thus far :)

    Richard

Andrew Poppe

unread,
Mar 17, 2014, 12:32:52 PM3/17/14
to psychop...@googlegroups.com

Hi Richard,

Would you be willing to share your code for setting up the threads for timing? I'd feel a lot better about doing that rather than polling the box once per frame.

Thanks
Andrew

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Sol Simpson

unread,
Mar 17, 2014, 4:23:44 PM3/17/14
to psychop...@googlegroups.com
You should check that the GIL is actually released by pyserial while waiting for serial input; otherwise it could cause main thread issues if it is holding the GIL and blocking the main thread from being scheduled frequently. This is assuming pyserial reads are setup to block for data in the first place; I think the default  in pyserial is a 1 second blocking time. This can be decreased or turned off if desired, but then CPU core usage will likely increase as pyserial constantly calls read checking for data; on top of the context switching overhead of the GIL switching between the extra thread.

If Richard has it running and has not seen any degradation in frame rates, then it is probably fine though. 

I obviously have a bias here. ;)

Richard Höchenberger

unread,
Mar 18, 2014, 9:45:11 AM3/18/14
to psychop...@googlegroups.com
Andrew, Sol,

I ran some rather extensive timing tests on my preliminary experiment, in which I intend to use the PST SRbox to collect response times. As soon as I start the thread that keeps polling the serial port byte-by-byte -- until either a response has been detected (remember the SRbox is sending a steady stream even if nothing has happened) or a time limit has been reached -- chances are that I'm dropping frames. This must be due to the GIL Sol mentioned. Dammit. I will try to get things to work with the multiprocessing package, although I'm afraid this might turn out to be pretty complicated.

Will get back to you later.

    Richard


PS: This is the code I am using to poll the srbox. Sorry, no documentation at the moment ;)

SRBOX_BUTTON = {'1': int('11111110', 2),
                '2': int('11111101', 2),
                '3': int('11111011', 2),
                '4': int('11110111', 2),
                '5': int('11101111', 2),
                '6': int('11011111', 2),
                '7': int('10111111', 2),
                '8': int('01111111', 2)}

def getSpeededResponse(srbox, t0, RTmax=2):
   
global RT

   
global responseButton

    gotResponse
= False
    srbox
.flushInput()

   
while not gotResponse and (core.getTime() - t0 <= RTmax):
        readByte
= srbox.read(1)
       
if readByte != '' and readByte != '\x00':
            k
= ord(readByte)
           
if k != 0:
                RT
= core.getTime() - t0

               
if k | SRBOX_BUTTON['1'] == 255:
                    responseButton
= 1
               
if k | SRBOX_BUTTON['2'] == 255:
                    responseButton
= 2
               
if k | SRBOX_BUTTON['3'] == 255:
                    responseButton
= 3
               
if k | SRBOX_BUTTON['4'] == 255:
                    responseButton
= 4
               
if k | SRBOX_BUTTON['5'] == 255:
                    responseButton
= 5
               
if k | SRBOX_BUTTON['6'] == 255:
                    responseButton
= 6
               
if k | SRBOX_BUTTON['7'] == 255:
                    responseButton
= 7
               
if k | SRBOX_BUTTON['8'] == 255:
                    responseButton
= 8

                gotResponse
= True



Jonathan Peirce

unread,
Mar 18, 2014, 10:14:43 AM3/18/14
to psychop...@googlegroups.com
The advantage of using button boxes, which typically have external clocks, is that you can reset that clock at the start of the trial (t=0) and then used the timestamp from the box to measure the reaction time. That should mean it doesnt matter that you only check it once per screen refresh; it's returned time will be given at whatever precision the box can manage (more importantly at whatever duration it takes to execute the USB call to reset the clock).

Is there some other reason you need to poll the box at a very high frequency?

Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Andrew Poppe

unread,
Mar 18, 2014, 10:52:15 AM3/18/14
to psychop...@googlegroups.com
I'm definitely learning as I go here :) I couldn't find any information about getting timestamps from this button box, but I can infer a time since a reset by counting the bytes that are returned from the button box (assuming that the rate is a constant 800 samples per second). 

So I would start data streaming from the box at the start of the trial, poll the box once per frame, keep a running count of the number of samples until a button press is detected, and use that count to calculate RT.

Is there another way of reading timestamp information? 

Andrew Poppe

Graduate Student, Clinical Science and Psychopathology Research Program
University of Minnesota
N427 Elliott Hall
75 E. River Rd.
Minneapolis, MN 55455

Popp...@UMN.edu


Jonathan Peirce

unread,
Mar 18, 2014, 11:12:47 AM3/18/14
to psychop...@googlegroups.com
Oh, I see, this box returns just a constant stream of bytes rather than information about keypress events? OK, that's pretty painful, and I'm not sure how you go about handling that. :-(

Jon

For more options, visit https://groups.google.com/d/optout.

Richard Höchenberger

unread,
Mar 18, 2014, 11:48:24 AM3/18/14
to psychop...@googlegroups.com
On Tuesday, March 18, 2014 4:12:47 PM UTC+1, Jon wrote:
Oh, I see, this box returns just a constant stream of bytes rather than information about keypress events? OK, that's pretty painful, and I'm not sure how you go about handling that. :-(

Right, it's constantly streaming at either 800 or 1600 chars/sec. Really annoying, ancient, and overpriced. But it's currently the only response time box I have available :(

    Richard

Richard Höchenberger

unread,
Mar 18, 2014, 11:54:15 AM3/18/14
to psychop...@googlegroups.com
On Tuesday, March 18, 2014 3:52:15 PM UTC+1, Andrew wrote:
So I would start data streaming from the box at the start of the trial, poll the box once per frame, keep a running count of the number of samples until a button press is detected, and use that count to calculate RT.

This sounds like a good idea! I think it would be sufficient to flush the serial input buffer at the beginning of the trial and then read the whole buffer once the trial is over (given, of course, you advance regardless of the participant's response). Then you could just look for the first non-null element in the read data and calculate the response time.

    Richard

Jonathan Peirce

unread,
Mar 18, 2014, 12:00:52 PM3/18/14
to psychop...@googlegroups.com
Obviously test that a few times for known periods (to make sure the change in time matches the expected number of samples) to make sure that the buffer does fill at a constant rate. [This is probably obvious but I thought I should mention it!]
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Sol Simpson

unread,
Mar 18, 2014, 6:44:49 PM3/18/14
to psychop...@googlegroups.com
This serial protocol is so simple I will try and make an iohub bbox device for it and just use another device to create a simulated SRbox serial stream for testing. Could you test it Richard when I get around to doing the iohub implementation?

Richard Höchenberger

unread,
Mar 19, 2014, 5:21:16 AM3/19/14
to psychop...@googlegroups.com
Hello Sol,

On Tuesday, March 18, 2014 11:44:49 PM UTC+1, Sol Simpson wrote:
This serial protocol is so simple I will try and make an iohub bbox device for it and just use another device to create a simulated SRbox serial stream for testing. Could you test it Richard when I get around to doing the iohub implementation?

I would even cancel my vacation to test this for you ;) There is also an implementation shipping with Psychtoolbox, which should give a pretty good overview of the protocol: http://docs.psychtoolbox.org/CMUBox

Thanks,

    Richard

Richard Höchenberger

unread,
Mar 19, 2014, 5:26:48 AM3/19/14
to psychop...@googlegroups.com


On Tuesday, March 18, 2014 5:00:52 PM UTC+1, Jon wrote:
Obviously test that a few times for known periods (to make sure the change in time matches the expected number of samples) to make sure that the buffer does fill at a constant rate. [This is probably obvious but I thought I should 

The box is streaming 787 chars/s for me on average. Measured for over different durations. The box is connected to a Windows 7 computer using some LogiLink serial <> USB adapter.


from __future__ import print_function, division
import serial
from psychopy import core

SRBOX_PORT
= "COM4"
srbox
= serial.Serial(SRBOX_PORT, timeout=0, baudrate=19200)

#
# Wait a short while, turn off all lights, and switch the box to streaming mode.
#
core
.wait(0.250)
srbox
.write(np.uint8(64))
srbox
.write('\xA0')
srbox
.flushOutput()

tSleep
= 5

for i in range(10):
    srbox
.flushInput()
    core
.wait(tSleep)
    waiting
= srbox.inWaiting()

    print(waiting, 'chars in input buffer. This makes', waiting/tSleep, 'chars/s.')


Cheers,

    Richard

Jonathan Peirce

unread,
Mar 19, 2014, 5:37:15 AM3/19/14
to psychop...@googlegroups.com
Richard, I've just noticed your comment about "switch the box to streaming mode". What other modes does it support?
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Richard Höchenberger

unread,
Mar 19, 2014, 9:45:57 AM3/19/14
to psychop...@googlegroups.com
Hello Jon,


On Wednesday, March 19, 2014 10:37:15 AM UTC+1, Jon wrote:
Richard, I've just noticed your comment about "switch the box to streaming mode". What other modes does it support?

to my understanding, the box can be either in streaming mode, which means it will continuously send data to the serial port (at ~800 chars/s); or it can be in non-streaming mode, where the user could control the 5 LEDs, e.g. by sending 'uint8(64 + 32 + 16 + 8 + 4 + 2 + 1)' to light them all.

A nice thing about the box is that you can easily connect the supplied photo diode or an external microphone, which will then generate fake 'button presses' as a certain input threshold is exceeded.

    Richard

Nate Vack

unread,
Mar 19, 2014, 11:29:55 AM3/19/14
to psychop...@googlegroups.com
On Wed, Mar 19, 2014 at 8:45 AM, Richard Höchenberger
<richard.ho...@gmail.com> wrote:

> to my understanding, the box can be either in streaming mode, which means it
> will continuously send data to the serial port (at ~800 chars/s); or it can
> be in non-streaming mode, where the user could control the 5 LEDs, e.g. by
> sending 'uint8(64 + 32 + 16 + 8 + 4 + 2 + 1)' to light them all.

In essence, you get to tell the device "spam me at 800 chars/second"
or "don't send me anything."

I don't totally understand it, because you could always just not read
the serial port.

-n

Jonathan Peirce

unread,
Mar 19, 2014, 11:49:59 AM3/19/14
to psychop...@googlegroups.com
This would make sense if, in non-streaming mode, you can then request
info about recent presses (send a command to receive a string back about
the last press)

Richard Höchenberger

unread,
Mar 19, 2014, 2:00:33 PM3/19/14
to psychop...@googlegroups.com
On Wednesday, March 19, 2014 4:49:59 PM UTC+1, Jon wrote:
This would make sense if, in non-streaming mode, you can then request
info about recent presses (send a command to receive a string back about
the last press)

Yep, but that's not possible. It is a completely overpriced, bulky, ancient, and ugly device :S

    Richard

Nate Vack

unread,
Mar 20, 2014, 11:06:28 AM3/20/14
to psychop...@googlegroups.com
On Wed, Mar 19, 2014 at 1:00 PM, Richard Höchenberger
<richard.ho...@gmail.com> wrote:

> Yep, but that's not possible. It is a completely overpriced, bulky, ancient,
> and ugly device :S

Y'know, I'm sure you've thought about this and have a good reason to
not use it, but! You do have another button box available. It has 104
buttons on it and probably connects to your computer via USB ;-)

Time resolution may be slightly less, but it looks like you can
increase the polling frequency for USB devices to 1000hz. And the
standard rate of 125hz is still pretty snappy relative to the speed at
which people press buttons...

-n

Richard Höchenberger

unread,
Apr 9, 2014, 1:32:43 PM4/9/14
to psychop...@googlegroups.com
Hey Sol,


On Tuesday, March 18, 2014 11:44:49 PM UTC+1, Sol Simpson wrote:
This serial protocol is so simple I will try and make an iohub bbox device for it and just use another device to create a simulated SRbox serial stream for testing. Could you test it Richard when I get around to doing the iohub implementation?

don't know if it's still on your todo list, but I am still willing to help ;)

Andrew, did you get the box to work finally?

    Richard 

Andrew Poppe

unread,
Apr 9, 2014, 1:43:36 PM4/9/14
to psychop...@googlegroups.com
I was just getting around to responding with an update. Sol, I have a box that we can send to you to work with if you're still interested. However, in the mean time my advisor has found a custom box that he built that connects via parallel port, so we are going to use that box instead. It's far less complicated and seems to work well. 

My solution for timing was just to use a while loop that polls the parallel port each time through the loop, looking to detect a button release, and when that release is detected it calls getTime() and ends the trial. 



Andrew Poppe

Graduate Student, Clinical Science and Psychopathology Research Program
University of Minnesota
N427 Elliott Hall
75 E. River Rd.
Minneapolis, MN 55455

Popp...@UMN.edu


--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Sol Simpson

unread,
Apr 10, 2014, 9:29:17 AM4/10/14
to psychop...@googlegroups.com
Hi Andrew and Richard,

I would still like to do this, but have not had time so far. Andrew, sending a box that I can borrow for 1 - 2 weeks would really help, as I would not have to write a simulator for the serial stream. I will send you my mailing address separately. Thanks very much.

Regarding the parallel port bbox, is it directly setting pport pins high / low based on if a button is pressed or not, and you therefore need to be able to catch each press-release combination using polling? So in theory, if the pport went high and then low again in 10 msec and you did not happen to poll the pport state during that 10 msec period (since you are polling at 16.66 msec), then you would not know that the pport event had occurred.

Of course button presses are going to be longer than 1 refresh interval, so the above would really be /in theory/, but it does point out that the resolution of the RT's and press durations will be equal to the retrace interval of the screen ( say 16.66 msec ) and the average error in time accuracy will be +/- half  retrace interval ( so +/- 8.33 msec), with the variability in the accuracy being between 0.001 and 16.665 msec).

If you were polling that pport every 1 msec, then you would be able to get response times with accuracy of  <= 1msec.

Thanks again,

Sol


Andrew Poppe

unread,
Apr 10, 2014, 10:16:31 AM4/10/14
to psychop...@googlegroups.com
Hi Sol, 

This box does set the pins high/low based on the buttons' press status. However, instead of polling once per frame, I'm actually just drawing my stimulus, flipping the window, and then starting a while loop that runs until a button release is detected (transition from pressed to released). Because my stimuli are static, it doesn't matter that I'm not updating them in the interim.

This should allow me to get pretty accurate RT, right? My thinking was that doing it this way avoids the issue of the screen refresh rate. If I'm wrong about that, I'd be happy to hear about it now rather than later!


Andrew 



--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Sol Simpson

unread,
Apr 10, 2014, 12:22:22 PM4/10/14
to psychop...@googlegroups.com
Sounds like you are doing the right thing to me. I (wrongly) had the impression from your last email that you needed to flip each retrace.

Thanks again.

Andrew Poppe

unread,
Apr 10, 2014, 12:34:46 PM4/10/14
to psychop...@googlegroups.com
Yes, I thought so too at the time :) It hadn't occurred to me yet that my stimuli weren't dynamic, so I didn't need to refresh the screen.

Andrew 

Michael MacAskill

unread,
Apr 10, 2014, 7:03:50 PM4/10/14
to psychop...@googlegroups.com
Hi Andrew,

Do make sure you issue time.sleep() calls periodically though. With tight loops like this, the rest of the OS can get backed up, and suddenly you'll find that you lose a couple of seconds while it catches up on its list of tasks.

This isn't something we normally need to worry about when using the drawing loop, as there is usually a few milliseconds per frame where the CPU is released for the OS to do its thing.

Cheers,

Mike

Michael MacAskill

unread,
Apr 10, 2014, 7:14:15 PM4/10/14
to psychop...@googlegroups.com
To expand: this might not be an issue if you are just polling for a few hundred milliseconds, and then move on to other things. Problems have generally arisen when people run tight lops for > a few seconds at a time. But do keep an eye out for very long intervals/missed detections, and use time.sleep if it is needed.

Cheers,

Mike

Andrew Poppe

unread,
Apr 11, 2014, 3:10:22 PM4/11/14
to psychop...@googlegroups.com

Hmm I definitely hadn't considered that. I am polling for a maximum of 2 seconds, so from what you said this could be a problem.

How would you recommend I do this? Include a time.sleep() call for a short duration every time through the loop, like for 5 ms or so? Or a longer sleep once every 200 ms?

I'm definitely glad you brought this up before I started losing data!

Thanks
Andrew

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Jonathan Peirce

unread,
Apr 13, 2014, 7:56:47 AM4/13/14
to psychop...@googlegroups.com
Try it first and see what happens; I expect this to be highly OS- and system-dependent. On a multi-core system I'd imagine it would still keep up? If need it then I expect you'll only need to add a break of 1ms or so to allow the OS to do its housekeeping.

best wishes,
Jon

For more options, visit https://groups.google.com/d/optout.
-- 
Jonathan Peirce
Nottingham Visual Neuroscience

Sol Simpson

unread,
Apr 17, 2014, 12:51:56 AM4/17/14
to psychop...@googlegroups.com
I've implemented a Serial device in ioHub with one of the uses being the PST box in serial streaming mode.

I'm basically just reading the specified serial port and generating an 'event' whenever the the value of byte N != N-1. Based on my understanding, this should result in an event being generated by iohub every time one of the button states changes. The event contains .prev_byte and .current_byte fields (uint8's) so you can tell what the transition of the event was.

The demo is in demos/coder/iohub/serial/pstbox.py. (and also attached)

This has not been tested with an actual PST box. To test I used a teensy 3 microcontroller to generate the serial stream (via a USB - serial connection) that just changed the byte value being issued every 500 msec. So testing with the real thing is important (please).

I have committed the code changes to the isolver/psychopy project clone on github ( https://github.com/isolver/psychopy/ ).   
if you are using the Psychopy standalone distribution, to test the code you should:

1) Backup your current psychopy directory that is in the psychopy python site-packages folder.
2) Put in the same directory from the zip download of isolver/psychopy.
3) Run the demo to test. 

** I would /strongly/ suggest you just use the isolver/psychopy source to test the PST box serial events and when done, switch back to using the official psychopy release you backed up.

If I can get some feedback / confirmation that the code seems to work with the box as expected, I'll do a pull request to psychopy/psychopy proper.

Thanks very much.
pstbox.py

Richard Höchenberger

unread,
Apr 29, 2014, 3:27:05 AM4/29/14
to psychop...@googlegroups.com
Hey Sol, sorry for the late response, I am currently very busy doing other lab stuff ;) Thank you so much for working on this!

On Thursday, April 17, 2014 6:51:56 AM UTC+2, Sol Simpson wrote:
If I can get some feedback / confirmation that the code seems to work with the box as expected, I'll do a pull request to psychopy/psychopy proper.

I did try the code on Sunday, and I am experiencing some problems. I will put together a  summary of what I've tried, which results I expected, and what I actually got in the next few days. May I message you off-list?

Best, and thanks again,

    Richard

Sol Simpson

unread,
May 9, 2014, 2:48:14 PM5/9/14
to psychop...@googlegroups.com
Hi Richard,

I am not sure how I missed your post; I was wondering if anyone had or was going to test it out. ;) Sorry about that!

Please email me with the issues you are having. It may be related to the bytes that need to be sent prior to the box starting to stream data. I have more info on this now thanks to David, so if that is the issue it may be easy to fix.

Talk soon.

Richard Höchenberger

unread,
Jun 24, 2014, 10:30:16 AM6/24/14
to psychop...@googlegroups.com, Sol Simpson, popp...@gmail.com
Hello Sol!

I _finally_ found some time for testing the serial response box again. Turns out the issues I was experiencing were caused by a wrong baud rate setting (should have been 19,200, was 115,200). With the correct settings I can successfully collect button press and release events, hooray! :-)

In the PsychToolbox CMUBox.m module I discovered the following comments regarding the PST response box:

% Bit 7 = 128 -> Enable/Disable streaming.
% Bit 6 =  64 -> Lower bits control lamp state.
% Bit 5 =  32 -> Enable/Disable button queries.
% Bit 0-4 = 1-16 = Enable/Disable Lamp 0-4.

So to enable data streaming and switch on the first lamp, one would do something like:

pstbox.write(chr(np.uint8(128+32+64+1)))

Writing 128+32 is always necessary to start data collection.

I extended the example code from you last mail and took some snippets from the ioHub docs to build a small visual response time experiment (code attached).

Thanks for your hard work on this!
Do you need help in further testing/documenting behavior before this can become an official part of ioHub/PsychoPy? Would be glad to give a hand.

Also CC'ing Andrew in case he's still interested.

Cheers,

    Richard
pstbox.py

Richard Höchenberger

unread,
Jun 27, 2014, 3:30:58 AM6/27/14
to psychop...@googlegroups.com
This is a cleaned-up version of the example, with corrected comments and tidied-up code.

    Richard
pstbox.py

Sol Simpson

unread,
Jun 28, 2014, 11:11:59 AM6/28/14
to psychop...@googlegroups.com
Thanks very much Richard, the demo looks great to me. I'll replace the current pstbox iohub demo with this one. 

Daniel Low

unread,
Sep 27, 2015, 5:28:56 PM9/27/15
to psychopy-users
Hi everyone! This is just what I needed, thanks!

I don´t program very well. Can I just insert this script into the Builder mode of PsychoPy? Would I insert it in the same place I would insert a keyboard response? Should I make any adjustments?

Thanks,
Daniel

Kyle Richard

unread,
Nov 16, 2016, 12:17:42 PM11/16/16
to psychopy-users
Are there any documentation pages for get events and clear events for the pst box function?
Thanks,

Kyle

Richard Höchenberger

unread,
Nov 17, 2016, 7:20:59 AM11/17/16
to psychopy-users
Hi,

On Wed, Nov 16, 2016 at 6:17 PM, Kyle Richard <morr...@hotmail.com> wrote:
> Are there any documentation pages for get events and clear events for the pst box function?

I will answer at
http://discourse.psychopy.org/t/using-an-e-prime-button-box/1483
Please don't post new messages to the Google Group anymore.

Richard
Reply all
Reply to author
Forward
0 new messages