How to randomize different breaks duration between two stimulus

Hi everyone,
I’m using PsychoPy version 2021.1.2.
I’m trying to create an emotional task using builder. Each trial starts with a fixation
cross presented at the center of the screen for 1000ms, followed by
a negative or a neutral picture for 100 ms. The picture was followed by
an interval of 50, 100, or 150 ms. Then, a target squarewas presented for
1000 ms. Participants were asked to indicate whether the target square
was blue or green by pressing a key on the response box. They were requested
to respond as fast and as accurately as possible. Each trial ended
with an inter-trial interval (ITI) of 2000, 2250, or 2500 ms
I’m trying to figure out how to add those intervals randomly, I’ve tried to create 3 different routines and then to add a random loop. the problem is that the randomization applies to all of the intervals (50/100/15 ms). I’ve also tried to create xlsx file with a time duration variable (‘duration’)- I added a blank text stim, at the ‘stop’ line I wrote $duration , I got an error when I was trying to run the experiment.

At this point I haven’t figured out how to do it,
any help will be useful :slight_smile:

Ilana


EmotionTask

I would use a code component.

Begin Experiment

intervals=[50,100,150]
itis=[2000,2250,2500]

Begin Routine

shuffle(intervals)
shuffle(itis)
thisExp.addData(‘interval’,intervals[0])
thisExp.addData(‘ITI’,itis[0])

Duration in test or isi component (which much come below code component)
$intervals[0]/1000

and then $itis[0/1000

Thank you for answering,
I’m trying to figure out what is the
thisExp.addData(‘interval’,intervals[0])
thisExp.addData(‘ITI’,itis[0])

is this a file I need to create?
Right Now when i copied the text to the code component i’m getting an error:
/* Syntax Error: Fix Python code */

Switch the ‘smart’ quotes for 'dumb' quotes.

This refers to the data file that’s automatically created – nothing for you to do.

got it! I added a code component and then an ISI component. Then I’ve tried to insert the $intervals[0]/1000 in different slots in the ISI component and now the experiment runs, but it stops when it gets to the Interval routine.