psychopy.org | Reference | Downloads | Github

Problem with feedback when no response is given

URL of experiment:

Description of the problem:
Hello, I’m trying to run an experiment online where participants have to respond to a stimulus within a given time frame. If they run out of time, there is a beep and the next trial begins.There is first a practice block where feedback is given. The experiment was created in Builder and the feedback code is in a code component. This is what it looks like:
if response.keys == None:
msg=“Too slow!”
else:
msg=“Success!”

It works perfectly offline but when run online, the experiment just hangs with no error message when no response is given (it runs fine and gives the right feedback when a response IS given).

There are various translations of the code I’ve tried such as:
if ((response.keys === null)) {
msg = “Too slow!”;
} else {
msg = “Success!”;
}

if ((response.keys === undefined)) {
msg = “Too slow!”;
} else {
msg = “Success!”;
}

if ((response.keys !== undefined)) {
msg = “Success!”;
} else {
msg = “Too slow!”;
}

if ((! (response.keys === null))) {
msg = “Success!”;
} else {
msg = “Too slow!”;
}

All of them have the same problem.
I’d very much appreciate your help.

What if you put it in the each frame tab?

I’m setting a variable called responsemade=0 (in both Begin Experiment and Begin Routine, then changing it to 1 for each possible response.

i.e. in Each Frame

if tick.contains(mouse):
    mouserec = mouseloc
    answer='tick'
    responsemade = 1
    continueRoutine = False
elif cross.contains(mouse):
    mouserec = mouseloc
    answer='cross'
    responsemade = 1
    continueRoutine = False

Then I have in End Routine

if responsemade == 0:
    cross_check='cross_white.png'
    tick_check='tick_white.png'
    feedtext = 'Too slow!';
    thisExp.addData('Score','')
    thisExp.addData('RT','')

Best wishes,

Wakefield

Thanks for the suggestion. Unfortunately, this has the effect that the “too slow” warning appears one trial too late offline and it still doesn’t work online.

Thank you, Wakefield. Sadly, I couldn’t get that method to work, either.

In what way didn’t it work? Please can you post the code you tried?

Sorry for disappearing for a while.
I realised from your posts that the problem is not with the feedback but with not giving a response. In the online version, the experiment won’t move on to the next routine when no response is given. This is the code I’ve tried based on your suggestion (the reponse is a keyboard reponse when given).

A code component at the end of the trial routine (also tried to put it in the next routine within the loop, with the same result):

responsegiven = 0 (in both Begin Experiment and Begin Routine)

in Each Frame:
if response.keys:
responsemade = 1
continueRoutine = False

in End Routine:
if responsemade == 0:
continueRoutine = False

I’ve also tried to replace “if response.keys” with “if len(response.keys) > 0”, which gave me an error message that Cannot read property ‘length’ of undefined

Is your keyboard component called response?

Each Frame is the correct place. There’s no point telling a routine to end when it has already decided to end.

Yes, “response” is the name of the keyboard component.
If I put the code

if responsemade == 0:
continueRoutine = False

in Each Frame, the experiment jumps right to the end of the whole block without showing any trials.

Sorry – I didn’t read this bit in detail. What is it supposed to do?

It’s supposed to force the routine to end. But it doesn’t seem to do anything because the routine still refuses to end.

You only run the code in End Routine when the routine is already ending. Presumably you want to end the routine after a given time period. Do you have any code doing that?

Thank you for not giving up on me!

There is a 0.3 sec beep 9 seconds after the start of the trial and the routine should end after the beep. I’ve tried inserting the code (in Each Frame):
if t >= 9.3:
continueRoutine = False

I’ve also tried:
if beep.status == FINISHED:
continueRoutine = False

But they didn’t do the trick, either.

This is the relevant bit of the Java script (I think): https://drive.google.com/file/d/1W0OpNdTd6Z_sEc7w4Emkl1pU7bFnX5qk/view?usp=sharing

And this is what it looks like in Builder:
image

Looking at that image you shouldn’t need any code at all to timeout unless you also have code objects . However, I can’t see a feedback routine. I normally put one inside the loop after the trial

I don’t need any code for the experiment to run offline. It runs perfectly without the code component. But when I try to run it online, it just hangs after the beep and nothing will make the trial routine end.

(The feedback routine used to be inside the loop after the trial but I deleted it when I thought that was the source of the problem. I’ll put it back once the never ending routine problem is solved.)

Try disabling the beep. It might be related to a sound component failing to stop. If so, code could be used to stop that.

Yes, that was it! I had the sound component generate a tone of 0.3 sec duration and the online version thought the sound component never ended. Now I’ve created a sound file of 0.3 sec duration, which is called by the sound component and it’s working fine.

Thanks for everything!