Jittering of fixation

OS (e.g. Win10): MacOS Monteray
PsychoPy version (e.g. 1.84.x): 12.3.1

What are you trying to achieve?:
I am trying to use jittering for my fixation routine. The goal is for 8s, 10s, and 12s to be randomly selected as the fixation length within one loop. However each value should only be used 6 times (without replacement) to keep the overall timing of the overall constant

What did you try to make it work?:
Begin Experiment Tab Code:
x_duration = 0

Begin Routine Tab Code:
#creating jitter of 8, 10, and 12 seconds
#if trials_RunA_Round1.thisN in [0,17]:
if trials_RunA_Round1.thisN == 0:
x_duration = list_name.pop()

Text Fixation Component:
Entered in $x_duration for the duration

What specifically went wrong when you tried that?:
The experiment ran, however the only fixation length that was used was 8s (For some reason, the 10s and 12s lengths were completed excluded). So the without replacement part of the code is not working as well as the sampling from the other fixation length times. Thanks in advance!

creating jitter of 8, 10, and 12 seconds

fixation_lengths = [8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12]

for i in range(len(fixation_lengths)):
x_duration = fixation_lengths[i]


put the list-creation and shuffle in a Begin Experiment tab and the assignment in the Begin routine tab.

Begin Experiment

dur = 0
durations = [8,10,12]*6

Begin routine

dur = durations.pop()

BTW, surround your code with triple `, then it is properly formatted.

Best wishes Jens

1 Like

thank you both for your help! I tried the second response and the code worked. The only other change I made was entering $dur in the blank for duration of my fixation component.