Hi everybody, I have prepared a naming task which consists of 50 pictures. I use the Blackbox kit so that the device sends “0” when the participant starts to say what the picture is. This way I will get the response times. The pictures are shown in a loop, and each picture is displayed for 3 seconds, during that 3 seconds period, there is no end of the routine, even if the keyboard code 0 comes from the blackbox kit. But rarely, there will be answers that will come in more than 3 seconds, and I want to be able to get these times. How can I add to this loop that if no 0 is sent within 3 seconds, the routine continues until 0 is sent? Thank you.
How to code "if" or "else" for finishing the cycles with keyboard 0 in picture naming task routine?
you could start a countdown in “Begin routine” and check every frame, whether the countdown is 0 AND the Blackbox “0” was received:
timer = core.CountdownTimer(3)
keys = event.getKeys() if timer <= 0 and "0" in keys: continueRoutine = False
Here, I assume that the Blackbox “0” is recognized just as a regular key press. If that is not the case, the code has to be adapted to actually read the proper input.
My pictures and keyboard key have 3 seconds stop time. Should I change the stopping time?
When I put your codes I see a this error
TypeError: ‘<=’ not supported between instances of ‘CountdownTimer’ and ‘int’
Experiment ended with exit code 1 [pid:9288]
blackbox “0” is just a regular key press, yes. and I need the response times when the “0” is received. Thanks for your answer and help. I hope we will manage to get it sorted.
Sorry, I forgot something in the code. This is correct:
keys = event.getKeys() if timer.getTime() <= 0 and "0" in keys: continueRoutine = False
Yes, you should delete both stopping times so they are displayed until the condition in the code is met and don’t go away before.
Thanks for the new code, now the trial works without problem. But still something needs to be changed. Because each picture displayed at least 3 seconds yes but I need to press 0 again to continue to the next picture. I can see the response time because of storage of first key but It needs to go next picture automatically if the 0 's received in 3 seconds. now I have to press key 0 again after 3 seconds. Thank you so much
Ah, yes. Next version
To “Begin routine” add
received_response = False
keys = event.getKeys() if "0" in keys: received_response = True if timer.getTime() <= 0 and received_response: continueRoutine = False
Yes, It works definitely how I want. Thank you so much. You literally made my day
Have a nice weekend and take care!