Routine Being Skipped/Not Showing

I have created an experiment where participants type in answers to simple math problems. They do this for 20 trials, then their average reaction time is multiplied by .95 and used as the end time for the next set of math problem routines. Participants see the math problems, type in their answers, see a feedback screen with their answer and the correct answer, and then repeat. The math problem and the feedback are two different routines.

As per usual, this runs fine locally. When I try to run it in pilot mode on Pavlovia, it works as planned for the first set of untimed trials. When the timed trials start to run, it only shows some of the math problems, but shows the feedback for all iterations of the loop. So to a participant, it looks like they do a math problem, see feedback, then see new feedback (with their answer blank, since they never saw a problem to answer).

I am struggling to figure out why this is happening. It seems to be random which ones are shown - I have a line of code in ‘Begin Routine’ grabbing the current time and writing it to the dataset, and then in ‘Every Frame’ it grabs the time at the end of the routine and writes that. The datasets from a few iterations of the experiment show that it is skipping routines at random, but it does appear to “start” the routine since the current time at the end gets written as a 0 for those skipped instances.

What is particularly odd, to me, is that this works perfectly on the routines without the timing code. I thought that the problem must be in the timing code, but if I comment it out, then I get a new error about undefined properties, and I feel stuck in a loop of errors that I can’t decipher.

Below is the flow of the section that doesn’t work and the code.

Begin Routine:

#create random numbers for the math problem
numOne = randint(1,10)
numTwo = randint(1,10)
numThree = randint(1,10)
numFour = randint(1,10)

corrResp = numOne + numTwo + numThree + numFour

textFill = ''

timer.reset() #timer is timer = core.Clock() in Begin Experiment

numList = [numOne, numTwo, numThree, numFour]
expTime = timer.getTime() #this was for my debugging purposes

Each Frame

t = timer.getTime()

if t >= newTime:  #newTime is created in an earlier routine and I can see that it is written correctly because it appears properly in the data on these trials
continueRoutine = False
expTime = t #for debugging purposes - expTime gets written to the data

My experiment is in pilot mode because I do not yet have credits, so I am not sure if I can post the URL for it. I can upload the file for the experiment, if necessary.

t is automatically set to the routine time so your code might be interfering.

I would print t and newtime to the console when the routine ends

I edited my code across all routines to remove reference to “t” and instead use something else. I wrote t and the new time variable (routTime) to the data and it is writing the same number for both of them. They are all non-zero numbers, but it was still skipping routines. Here is the new code for each frame:

routTime = timer.getTime()

if routTime >= newTime:
continueRoutine = False

I have it writing to the dataset during End Routine:

And the output looks like this from the most recent run, where the routine was sometimes being skipped visually.

time routineTime
0.6067 0.6067
0.0012 0.0012
0.6087 0.6087
0.001 0.001
0.607 0.607
0.0013 0.0013
0.6 0.5999
0.001 0.001
0.6002 0.6002
0.0013 0.0013
0.6001 0.6001
0.001 0.001
0.6002 0.6002
0.0013 0.0013
0.5999 0.5999
0.0015 0.0015
0.575 0.575
0.6065 0.6065
0.0012 0.0012
0.6069 0.6069

I have a number of nested loops in my experiment to handle the consent form and such, so I am also going to try a version of the experiment with just the barebones and then slowly add the other components, and see if that helps.

That looks fine. Try printing the value of newtime

Here’s the code for newTime being created in an earlier routine:

Begin Experiment

rt_trial = 0
timer = core.Clock()
multNum = .95

Each Frame

if mouse.isPressedIn(next_button):
respTime = timer.getTime()

End Routine

rt_trial += respTime
rtMean = rt_trial/20
newTime = rtMean*multNum #uses a variable instead of a number because I intend to have it change based on loop number later

It prints out newTime for me after each routine and it looks all correct to me. Here is the output from the trials where newTime is being calculated

newTime rtMean rtTrial
0.05051625 0.053175 1.0635
0.080142 0.08436 0.6237
0.100282 0.10556 0.424
0.1197285 0.12603 0.4094
0.1461385 0.15383 0.556
0.17608725 0.185355 0.6305
0.19826025 0.208695 0.4668
0.21840025 0.229895 0.424
0.24487675 0.257765 0.5574
0.27251225 0.286855 0.5818
0.2950415 0.31057 0.4743
0.31242175 0.328865 0.3659
0.33022475 0.347605 0.3748
0.349239 0.36762 0.4003
0.36982075 0.389285 0.4333
0.39273 0.4134 0.4823
0.41282725 0.434555 0.4231
0.4285735 0.45113 0.3315
0.44597275 0.469445 0.3663
0.46538125 0.489875 0.4086
0.48392525 0.509395 0.3904
0.50298225 0.529455 0.4012
0.55642925 0.585715 1.1252
0.57617025 0.606495 0.4156
0.5998395 0.63141 0.4983

And newTime for the timed trials consistently says .5998395, as it should.

I want to see newtime on a trial where t is small because it got skipped

That’s the thing - newTime is correct. I just edited the code in the timed trials to write newTime as a new variable in the data (newTime_timed) just to ensure it was copying correctly from the initial trials to the timed trials, and it is. newTime at the end of the last initial trial on the most recent test was 0.81861975, and it is also writing 0.81861975 in the newTime_timed, even though it skipped every other trial when I ran it.

It doesn’t always skip every other trial, sometimes it is random, but it does seem to have that pattern more often than not. If it helps, I’m attaching the data ouput here.
627244_MathVersion_V1_2024-01-30_16h18.20.057.csv (51.4 KB)

Figured out the issue. It actually was an issue I thought I had addressed, but hadn’t fully fixed.