psychopy.org | Reference | Downloads | Github

Ending the routine only when both the conditions are met

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10):
PsychoPy version (e.g. 1.85.x):
Dear all

In my experiment I want an image 1 to be displayed for 2 seconds. I set it to 2 seconds to achieve this. While the image 1 is displayed, I also want two other images (image 2, image 3 -named as ‘stimulus’ in code below) to appear, but it will last for two more seconds (i.e., 4 seconds). I am using mouse to collect my responses. Participants click on the image 2 or 3 (stimulus)to register the response. I used the following code to achieve this

for stimulus in [image_4, image_5]:

if mouse.isPressedIn(stimulus):
    thisExp.addData('items', 1)
    items=items+1
        # Yes, so store the reaction time in the data
    thisExp.addData('RT', t)
    if stimulus.image == corrAns:
        thisExp.addData('score', 1)
        a_sound.play()
    else:
        thisExp.addData('score', 0)
        b_sound.play()
    continueRoutine=False

###############
I have used another code component right under the image 2 to end the routine if no response was given for 4 seconds
########
if image_4.status == FINISHED:
continueRoutine = False
########

At the moment, the routine ends after the mouse click on ‘stimulus’. This is problematic as I want the image 1 to be displayed for a constant duration of 2 seconds, irrespective of the mouse response. But if the response was >2 seconds the routine shall end, which I have achieved in the present design. If the response was <2 seconds, I still want to store the response, but I want the routine to continue for at least till the completion of Image 1 default duration (i.e., 2 seconds). The purpose is of course I want to keep the image 1 display constant across trials.

More descriptively, I want to end the routine only both the conditions are met
First, the image 1 should have been displayed for its whole duration, i.e., 2 seconds
Second, mouse should have been clicked in stimulus
Third, no response for the duration of image 2 or image 3 (I have achieved this)

Thanks for your help in advance