psychopy.org | Reference | Downloads | Github

Clear history of cedrus response pad: button.clear_response_queue()


#1

Hi There,

I have recently started working with a “Cedrus RB-730” response pad.

Problem:

If a participant accidentally presses a button twice the second button press is taken as a response to the following stimulus. The problem is illustrated using the code below in which participants should press a button, when a button is pressed the response queue should be cleared and there should be 4 seconds until the next trial. If you run this you can see that if you try pressing a button twice the second key press is taken as the response to the next trial :
##--------------------------------Code start------------------------

import pyxid 
from psychopy import core, event
devices = pyxid.get_xid_devices()
print devices
stimTrig = devices[0] # leg box ADJUST WHERE NEEDED
button = devices[1]# response pad
print devices
count=0

for i in range(10):
    core.wait(1)
    print 'waiting for response'
    response=0
    responseMade=0
    while responseMade==0:
        button.poll_for_response()
        if button.response_queue_size()>0:
            response=button.get_next_response()
            if response['pressed']:
                responseMade=1
                print response
    button.clear_response_queue()
    core.wait(4)

##--------------------------------Code end------------------------

I think my issue is that I am clearly not implementing button.clear_response_queue() correctly. As this should clear the response queue and mean the experiment waits for the next response key press in the next trial.

Any advice at all would be greatly appreciated !!

Thank-you in advance!

Becca


#2

I don’t have a cedrus box so I don’t have any experience with this, but on first glance I wonder if your call to clear_response_queue() comes too quickly after you collect the first response.

At the moment, you collect response #1, and then immediately clear the response queue. Try moving clear_response_queue() after your core.wait(4) line.

PS: If you enclose your code in three back-ticks, it gets formatted as code:

```
import pyxid
from psychopy import core, event
devices = pyxid.get_xid_devices()
print devices
stimTrig = devices[0] # leg box ADJUST WHERE NEEDED
button = devices[1]# response pad
print devices
count=0
```

becomes

import pyxid 
from psychopy import core, event
devices = pyxid.get_xid_devices()
print devices
stimTrig = devices[0] # leg box ADJUST WHERE NEEDED
button = devices[1]# response pad
print devices
count=0

#3

Hi Jan.freyberg,

I thought this initially as well. However I have tried placing the clear_response_queue() after the core.wait(4) and also at the start of the for loop (so it should refresh at the start of each trial!) however I still seem to get the same problem which is strange!

Thanks for the tip on how to format me comment ! I have edited the post as you suggest (this is much better thanks!)

Becca


#4

In that case I don’t know what’s going on, sorry - maybe someone on here with a cedrus box will be able to help you out.


#5

Hi,

Did you ever solve this - I have exactly the same issue.

Kind regards,

Gabriela


#6

sorry I can’t be more help here ! never managed to fix it so used a keyboard !! let me know if you get any further with it ! would be great to see what the issue is!


#7

Hi,

We didn’t find a fix for this problem here, but we inserted these lines to run between each trial which has cured the symptoms

#Nasty Hacky fix to avoid multiple button presses cascading through subsequent trials
     for i in range(1,100):
         dev.poll_for_response()
         dev.clear_response_queue()

It doesn’t add any significant delay (although currently we don’t care about inter trial intervals, so YMMV) and being as the first button press is all we’re after in each trial and can safely ignore anything that happens before the next trial starts this works for us right now. That said, if anyone knows an actual fix for this, I’d love to get this cludge removed from our code :slight_smile:


#8

If you could timestamp the button presses and you timestamped the stimulus onsets then you could reject repeated button presses which occurred before stimulus onsets by comparing the the timestamps.

I don’t have a Cedrus keypad but I had quick look at their API on GitHub. Looks like it might timestamp button presses, though their readme says that their clock drifts. Perhaps that is correctable by measuring the drift rate?

Allen


#9

Hi Allen,

Nice idea, but what does currently work is resetting the on-board timer to stimulus onset/trial start (avoiding the drift issue), so the timestamps aren’t as informative for this as you might hope! :slight_smile:

Additionally the dev.response_queue_size() command doesn’t seem to give accurate readings - i.e. doesn’t reflect this problem - and the dev.poll_for_response() command pops only the next button press in the queue - so even with a plan to discount erroneous responses by timestamp you’d still end up needing to iterate the dev.poll_for_response() command a high (and arbitrary) number of times to find out how many there had been - my cludge will fail if somehow there’s 101 erroneous button presses in a trial :smile:

Cheers,

Martin