How to display a fixation cross for variable durations as a ratio

Hi Everyone,

I have a routine that loops for 10 reps (10 trials). I would like to display a fixation cross for 2, 3, or 5 seconds at the beginning of each trial. However, I want these presentations to occur in a 6:3:1 ratio respectively. In other words, I want 6 of the 10 trials to have a 2 second fixation cross, 3 of the 10 trials to have a 3 second fixation cross, and 1 of the 10 trials to have a 5 second fixation cross.

I have tried the following code:

fix_time = [2, 2, 2, 2, 2, 2, 3, 3, 3, 5]
random.shuffle(fix_time)

I have a trial counter that = 0 at the start of my a block but increases by 1 at the end of each trial. I use this counter to index my fix_time list such that:

counter = 0 #increases by 1 at the end of every trial
#my Fixation Cross is a text component so in the text properties window:
Start $time(s) = 0
Stop $time(s) = fix_time[counter]

The idea being: since the counter will range from 0 - 9, I can use it to index the elements of my fix_time list such that the list shuffles once at the beginning of a block, and from that shuffled list I index fix_time[0] for trial 1, fix_time[1] for trial 2, …, fix_time[9] for trial 10. Thus, allowing me to change the duration of the fixation cross every trial and still achieve my desired 6:3:1 ratio

Now, this works in that my experiment does not crash. However, my problem is that sometimes the cross is displayed, sometimes it’s not, and when it is displayed, the durations are about .5 - 1.0 seconds less than what they are supposed to be.

Are there better ways to code the presentation of this fixation cross to not only change in duration from 2, 3, or 5 seconds in each trial but also maintain a 6:3:1 ratio of the 2, 3, 5 second durations respectively?

Thank you!

Your code looks fine (for 10 trials).

Please could you show a screenshot of your routine and your text component?

Sure thing! The routine shown in the screenshot is the routine where the fixation cross and images are being displayed. For more context: We have 5 blocks where there are 10 trials in each block. Within each trial, there are 17 images presented in rapid succession.

What does the fixation_cross text component look like?

The Start Time (s) was change to 2 seconds since my original post to see if having a blank period within the routine would help solve the issue. The Stop Time (s) is using the same indexing logic except ‘current_lag’ is the official name of the counter I mentioned before and the + 2 is to account for the 2 second blank period duration of the TrialBlankStart text component.