psychopy.org | Reference | Downloads | Github

Show stimuli 1 if respond, show stimuli 2 if no response

OS (e.g. Win10): macOS Catalina
PsychoPy version (e.g. 1.84.x): 2.3.2
Standard Standalone? (y/n) If not then what?: Yes
What are you trying to achieve?:
I am trying to make a stimuli 1 appear 3 seconds after the cue if Spacebar is pressed. And make stimuli 2 appear 3 seconds after the cue if nothing is pressed.

What did you try to make it work?:
I have tried to put
$keyRespTrial.keys == 'space' in the Start field of stimuli 1
and
$keyRespTrial.keys == 'None' in the Start field of stimuli 2.

What specifically went wrong when you tried that?:
When space is pressed, stimuli 1 appears, when nothing is pressed, stimuli 2 does not appear. Also after the cues have disappeared, I come to a blank screen and the experiment stops to run after a while. I.e. it fails to go to the next routine.

I also don’t know how to make the stimuli appear 3 seconds after the start of the cue.

'None' is the literal sequences of letters 'None'. It isn’t equivalent to the Python keyword None.

I suspect what you want to do is compare to an empty list, like this:

$keyRespTrial.keys == []

or maybe

$keyRespTrial.keys is None

or something similar.

Thank you, that seemed to solve one of the issues.

It still fails to go to the next routine after implementing this on the start field of the two stimuli:

$keyRespTrial.keys == 'space' and keyRespTrial.status == FINISHED

and

$keyRespTrial.keys == [] and keyRespTrial.status == FINISHED

I just come to a blank screen and nothing happens. Only way to get out of there is to press Esc. When I don’t implement the abovementioned code in the start field, the next routines load as it should. Seems strange that it should have any effect on the loadin of the next routine, any ideas what is happening?

Instead of putting the conditions in the start field, I put it in a code component:

In Each Frame:

if keyRespTrial.keys == 'space' and keyRespTrial.status == FINISHED:
    rectChoiceUp.opacity = 1
    rectChoiceDown.opacity = 0
elif keyRespTrial.keys == [] and keyRespTrial.status == FINISHED:
    rectChoiceUp.opacity = 0
    rectChoiceDown.opacity = 1

In End Routine:

rectChoiceUp.opacity = 0 # reset
rectChoiceDown.opacity = 0 # reset

Thank you for the help!

Hey there!
I’m trying to accomplish something exactly similar - getting responses for one stimulus, and no responses for another. But, for me, both the stimuli occur alternatively and are defined as conditions instead of start field. Is there any way I can accomplish the same results with that? Because as far as I see, the auto code does not separately identify the two stimuli defined.

Any leads would be appreciated. Thanks!