Unwanted (brief) blank screen between stimulus image and ISI image

Hi, I am using PsychoPy version 2021.2.3. and am primarily working in the coder. I first initialized my experiment in the builder, but compiled that and have been editing it in the coder because the purpose of my experiment is to test (1) consistent ISI versus (2) randomized ISI timing in a short vigilance task (<10 min.). I was not able to randomize the timing in my excel condition file, so I switched to the coder and have stuck with using it.

Basic Information: I am presenting a stimulus image (target, 125 ms; non-target, 248 ms) followed immediately by an ISI (randomized within a range of .6 to 3 seconds). The stimulus image is a mask of dots with a letter in the center of the screen (target vs. non-target), and the ISI is just the mask alone. Essentially, I have a loop that is ISI → stimulus → ISI. I have attached my experiment below with the script and log file (in the data folder).

VigilanceExperiment.zip (58.7 KB)

My specific problem: I want the background (mask) to remain at all times on the screen during the trials’ routine, but the imageFlip from stimulus to ISI will occasionally occur inconsistently - so I end up with a brief blank screen that has neither the background mask nor the background mask and stimuli. This only seems to happen when the ISI is < 1 second, and for this post I set the ISI to a constant value of .6 seconds (Line 122) because it seems the issue is strictly at the minima. Doing this reproduces the error with every trial. It is worth noting that the closer the ISI gets to 1 second, the smaller the delay becomes. Because I am manipulating the ISI duration in a randomized way, I (1) can’t set a constant ISI duration and (2) have the imageFlip for when my stimulus starts as “when the ISI mask image finishes.”

Potential cause: In the log file (data folder), the points at which this imageFlip fails seems to correspond to points at which the stimulus image autoDraw sets to False before the new trial begins (thus creating the blank screen). The example for this is at index = 3, where stim_image autoDraw = False immediately prior to index = 4. However, in most of the trials in this log, stim_image autoDraw = True prior to the new trial, and this seems to correspond with the seamless transition from ISI to stimulus.

How exactly can I resolve this timing inconsistency? Should I switch from timing in milliseconds/seconds to frames? Or is there some way I can more consistently transition from ISI to stimuli? It is important that I have these exact timing parameters so I was worried about doing so.

Thank you for any help you can provide! Please let me know if there is more information I can provide, or conversely if this is too cluttered - this is my first post on here.

Is there a problem when you try the Builder version with the ISI set to 0.6?

Variable/ random ISIs are easy enough to set up in Builder code components.