[open] Keyboard Response stops working at random
Hi all,
Thanks for your time.
I am helping out with a PhD study and have had a horrendous time with the opensesame program breaking at random.
We have setup the study and tested it on several different computers with Windows 7 and 8.
70% of the time it works without issue, but 30% of the time it doesn't collect keyboard responses and then times out. Unfortunately that 30% of the time it has broken when participants are testing and we've lost 4 people (out of 16)!
We can't figure out what the issue is, hence the post here. We would really appreciate any insight into the problem and how to fix it.
Simplifying it, the protocol has two paradigms, pictures and word.
1) show 120 words or pictures
2) recall words or pictures (out of 240, 120 old stimuli shown previously, 120 new) and press z if you've remembered it or m if you haven't seen it before
In the Run phase of the python script (adapted from scripting on the forum) I have:
from openexp.keyboard import keyboard
# The keypress timeout
timeout = 5000
# We poll for two responses. The first 'keyboard_response_1'
# waits for a 'z'. The second waits for a 'm' These
# responses can be given in arbitrary order, are stored in
# different variables, and can time out indendently of each
# other.
exp.set('keyboard_response_1', None)
exp.set('keyboard_response_time_1', None)
keylist_1 = ['z']
exp.set('keyboard_response_2', None)
exp.set('keyboard_response_time_2', None)
keylist_2 = ['m']
# Create a keyboard object that doesn't block the
# experiment, so we can use it to poll for keypresses
# continuously.
my_keyboard = keyboard(exp, timeout=0)
my_keyboard.flush()
# Loop until we timeout
start_time = self.time()
while self.time() - timeout < start_time:
key, key_time = my_keyboard.get_key()
# If a key from keylist 1 is pressed, set keyboard_response_1
# and keyboard_response_time_1. Also, set key_list_1 to [], so
# that we do not capture multiple keypresses from this list.
if key in keylist_1:
exp.set('keyboard_response_1', key)
exp.set('keyboard_response_time_1', key_time - start_time)
keylist_1 = []
break
# The same principle is applied for keylist 2.
if key in keylist_2:
exp.set('keyboard_response_2', key)
exp.set('keyboard_response_time_2', key_time - start_time)
keylist_2 = []
break
I don't have anything in the prepare phase. But as I said I don't understand why occasionally it breaks.
Thanking you all in advance.
Comments
Hey,
On first inspection, I can't tell for sure what could be the reason for an occasional breaking of the
experiment
(I have a hunch, though). Would you mind uploading the entire experiment with a subset of all images (otherwise the file be too big)? Then I can have a more careful look on it.Thanks,
Eduard
Thanks so much Eduard!
Is it possible to share this with you via email? Not allowed to post the stimuli on a public forum.
If it's only about the stimuli, you could also just replace your stimuli with some random pictures you can find now. One image per condition that you repeat a few times would be enough.
Eduard
Done !
It only goes through 3 pictures of dogs now. No words either.
https://drive.google.com/file/d/0B1L-ZQ3KAhQ8QlFadHU0Zy01Q2M/view?usp=sharing
Let me know if it works as it should
It seems that I can't reproduce the bugs. I ran the experiment 7-8 times and it went alright each time. Also your code doesn't seem to have an obvious error in it.
However, if you believe that the problem has to be in that part, there is good news. You can replace it entirely by an
keyboard_response
item. Actually, I don't know why you decided to do it in aninline_script
. You're doing nothing akeyboard_response
item couldn't do.And if the problem persists afterwards, you know that you're in bigger trouble.
Let me know, if you need help doing it.
Good luck,
Eduard
Btw. Those are pretty dogs!