# Randomness limits based on previous selections - won't end routine

Win11
PsychoPy version 2022.2.5
Hello - coding is not my strong point and I think I’m hacking rather than coding. I’m trying to achieve some randomness in the length of several inter-stimulus intervals, but certain stimuli must appear at a specific time and ISI later in the sequence vary based on the random outcome of previous ISIs.

I have 7 distractor stimuli. Dist1 is fixed onset. Dist2, Dist3 & Dist7 have fixed minimum and maximum limits of randomness. Dist4, 5 & 6 have bottom limits that vary algorithmically as a function of previous random outcomes.

I think I have this code done, if a little poorly. The issue I’m having is that the routine won’t end and I don’t know why.

My code chunk:
Before experiment:
dist2Min = 0.150 # minimum: 750 ms
dist2Max = 0.250 # maximum: 1250 ms

dist3Min = 0.550 # minimum: 750 ms
dist3Max = 0.800 # maximum: 1250 ms

dist7Min = 1.550 # minimum: 750 ms
dist7Max = 1.700 # maximum: 1250 ms

Begin Routine:

dist2 = np.random.uniform(dist2Min, dist2Max) # random between minimum and maximum
thisExp.addData(‘distractor2_start’,dist2) # document the duration in your logfile

dist3 = np.random.uniform(dist3Min, dist3Max) # random between minimum and maximum
thisExp.addData(‘distractor3_start’,dist3) # document the duration in your lo

dist7 = np.random.uniform(dist7Min, dist7Max) # random between minimum and maximum
thisExp.addData(‘distractor7_start’,dist7) # document the duration in your lo

dist4Min = (dist3 + 0.150)
dist4Max = 950
dist4 = np.random.uniform(dist4Min, dist4Max) # random between minimum and maximum
thisExp.addData(‘distractor4_start’,dist4) # document the duration in your lo

dist5Min = (dist4 + 0.150)
dist5Max = 1100
dist5 = np.random.uniform(dist5Min, dist5Max) # random between minimum and maximum
thisExp.addData(‘distractor5_start’,dist5) # document the duration in your lo

dist6Min = (dist5 + 0.150)
dist6Max = 1250
dist6 = np.random.uniform(dist6Min, dist6Max) # random between minimum and maximum
thisExp.addData(‘distractor6_start’,dist6) # document the duration in your lo

Any help would be greatly appreciated!
J

You’ve written some of your max values in ms instead of s.

1 Like

d’oh - thanks. That fixed it.