How to randomize picture stimuli in a certain duration

Hello, I’m now using Psychopy version 2020.2.4.
I’m going to create a mental rotation task.
There are all 24 pictures.
There doesn’t have a fixed presentation time for each trail,
but to give participants 3 minutes to complete as many pictures as possible.
So I want to know how I can set a loop and make the loop end in 3 minutes with builder.

Hopefully someone will be able to help with this!

Hi,

You want something like this :slight_smile:

In the routine before your loop add a code component, in the ‘end routine’ tab add:

#set up a clock (note that this is different for JS which uses util.Clock())
myTimer=core.Clock()
timeLimit = 60*3 #3 mins

In your routine that follows add a code component and on the ‘each frame’ tab add:

if myTimer.getTime()>timeLimit:
    continueRoutine=False
    trials.finished = True

Here is a demo file timerDemo.psyexp (6.4 KB)

Becca

Hi Becca,

I’ve seccessed with the code that you gave me.
Thank you soooo much for your help!

Fantastic - pleased to hear this helped - please could you mark that response as the ‘solution’ to the question for future users.

Thanks,
Becca