Imprecise Synchronization Between Stimulus and Mask

I noticed something off when running my PsychoPy experiment. I am a PsychPy newbie who is responsible for creating new versions of our experiment based on older versions created by previous lab members (who only used the PsychoPy UI to create experiments and never wrote extra codes).

The experiment is set up so that, for each trial, a stimulus is selected to presented at 0.0 local trial time and has a duration of 150ms. We only want the stimulus to be visible for 100ms so we set a mask to run at 0.1 local trial time and last for 100ms. This mask should overlay the stimulus at +100ms local trial time for the duration of 50ms, and continue to be visible for 50ms after stimulus offset.

However, when I wrote a code to calculate stimulus durations (time between when the mask is started and when the stimulus is started) from the data collected, I noticed that they only averaged below 80ms. The mask durations (time between mask offset and onset) look normal. I had previously thought that this might be due to the stimulus/mask overlay, but now I think there may be a delay in stimulus start time that could not be easily fixed by just removing the overlay.

Is this problem fixable?

OS (e.g. Win10):
PsychoPy version (2023.2.2):
Standard Standalone? (y)
What are you trying to achieve?:

  • Have (as precise as possible) stimulus durations for all trials

How big is the stimulus? Do you have the same issue if it’s smaller (or a text component).

Is this in a loop? If so, is the error less after the first iteration?