Start a component only if no valid response has been registered in the mouse

Hello! This is probably a simple question but I would appreciate some help with it.

I have a routine with 3 components:

  • An image called “button” where the participant can decide wether to click or not.
  • A mouse component that has “button” as clickable stimuli
  • A sound that should be presented only if the participant has NOT clicked the button

I would like to set the sound component to start when such condition is met by writing something in the “condition” field

I have tried different things based on what I found in the forum but I am starting to think that I will need to insert a code component for doing so. I would appreciate any help regarding what should I write in either the condition field or such code component.

I am using version 2022.1.1

Hi again,

I am trying to achieve the same but in a different way.

Now I am trying to play a “silence.wav” file if the participant has not clicked in the “button” image during the routine, and an “aversive.wav” file if he/she has clicked there.

My sound component does not refer to a specific file. Instead, I have used the variable $sound as shown in the picture

And I have now a code component that determines which .wav file does the variable $sound refer to depending on the participants’ response.

The begin routine tab specifies the default wav file.

sound = 'Aversive.wav'

The Each Frame tab is intended to set sound to be “Silence.wav” if the participant has clicked with the mouse in the button image at any moment during the routine:

if av_mouse.isPressedIn(button):
        sound = 'Silence.wav'

The problem is that the “if” statement does not seem to be accomplished never. The aversive.wav sound is always presented.

I would appreciate any clue of what I am doing wrong :nerd_face:



For anyone having this same issue… I think the problem is that the value of the sound variable cannot be changed within the trial (e.g., in every frame). So the value it takes at the beginning will last for the whole trial.

Based on a previous post (link below), the problem is solved by placing the sound component in a separate routine.