psychopy.org | Reference | Downloads | Github

Display message after button press, but don't end routine, online

My laptop specs:
MacOS Mojave Version 10.14.6
PsychoPy version 2020.1.2

What I want to happen:
I want the message “response recorded” to appear as soon as a participant has pressed a key but I don’t want it to force the end of the routine. Participants look at an image of a face for 5 secs and press 1 if the eyes are looking at the camera and 0 if not. This is a face learning task so the image needs to stay up for the full 5s. I want to acknowledge their button press without ending the trial. I’m not fussed about telling them if they were right or wrong, but if that’s easier to do I’m happy to do that. This needs to work on Pavlovia so any code component fixes need to be Pavlovia-friendly.

Things I’ve tried:

  • Without any feedback, the experiment works locally and on Pavlovia.

  • Based on another post, I believe there’s an old bug where you can’t change the opacity of the text, so that won’t work.

  • I tried the method where you have a polygon cover the text and you set its opacity to 0 after a button press, but my background colour changes every trial so I don’t think this is possible.

  • I tried adding this code component.
    Under Begin Routine I have:

    msg = " "
    

And under End Routine I have:

    msg = " "

  if gaze_key_resp_1.keys == 1:
       msg = "Response recorded!"

  if gaze_key_resp_1.keys == 0:
       msg = "Response recorded!"

There is a text component which has $msg in. I tried that second bit of code in the End Routine box and the Each Frame box. Both attempts have not displayed the text and caused my screen to turn grey and stay grey after 1 trial. It doesn’t crash, it just turns grey and I have to press esc to crash out.

Under Start Experiment I have:

msg = 'doh!' #if this comes up we forgot to update the msg!

And under Begin Routine I have:

if gaze_key_resp_1.keys:
    msg="Response recorded!"

I set the text component to end at 5.5s so the screen no longer stays grey, it moves onto the next trial. However, it only says “doh!” and if I press an allowed key at any point it still says “doh” and doesn’t change to “response recorded.”

I have tried moving the if statement code to the Each Frame box. It starts the trial showing the word “doh” and if I press a key it stays that way, but on the next trial it changes to “response recorded” but stays stuck showing that for the rest of the experiment.

I have tried every combination of putting msg=" " and the if statement in under every tab in the code component, I just can’t get it to work.

Any help would be very gratefully received.

Thank you!

Lydia

You could use a conditional start time for the text component with a short duration. I recently did something like this with key_resp.keys as the condition. I’d be happy to set this up as a demo.

Hi @wakecarter,

Thank you for your response! I tried your suggestion and I’ve almost got it to work.

If I press one of the keys it successfully displays the message ‘response recorded’ now, but if I don’t press a key then after the trial the screen turns grey and stays like that.

Press a key and it works:

Don’t press a key and it freezes:

Here is what my builder view looks like:

What do I need to change to allow the next trial to start even if the participant doesn’t press a key? If the participant doesn’t press a key I’m happy for the ‘response recorded’ message to simply not appear, or if it’s easier I’m happy to display a message saying ‘no response recorded’.

Thank you!

Lydia

Interesting. A component that never starts won’t let the routine end.

The easiest option is to add a code component with:

if t > 5.5:
    continueRoutine = False

in each frame.

That worked locally but when I pushed the edits to Pavlovia it doesn’t display the feedback anymore. It does allow the next trial to start and I downloaded my csv file and it is recognising the button presses. Any ideas?

Thanks,

Lydia

You did use an Auto code component, didn’t you?

Yes I think so, I copied and pasted your code as follows:

Please could you add me as a developer and unprotect the master branch so I can take a look?

Hi @wakecarter ,

The first thing I did when I opened my laptop today was to try run it again online, I didn’t touch anything else, and it’s working now… Not quite sure what happened there but it works locally and online now! Thank you so much for your help.

Lydia

1 Like