Unstable routine duration

**Hey, everyone!

OS**: Lenovo IdeaPad Gaming 3, Windows 11 Home laptop;

Processor: AMD Ryzen 5 5600H with Radeon Graphics (3.30 GHz)
Graphics card: NVIDIA GeForce GTX 1650 (4 GB)
AMD Radeon™ Graphics (2 GB)
RAM: 8GB

Laptop monitor specs:

15in screen
Display resolution: 1920x1080
Refresh rate: 120Hz

PsychoPy version: 2026.1.1
Standard Standalone Installation?: Yes
Do you want it to also run online?: No
What are you trying to achieve?: I am trying to stabilize the duration of a routine (“primescreen”). Given that it’s a masked priming paradigm, it requires the duration of the prime to be very precise (50ms or 250ms depending on the experimental task). However, for example, the mean duration of the 50ms trials for me is 47.3627 ms, with an SD of 4.5893 ms.

My code in the routine (Begin Routine section):

if expInfo[‘time_prime’] == “50”:
prime_dur = 0.05
else:
prime_dur = 0.25

What did you try to make it work?:

I tried shutting off other applications running at the same time, and the problem still persisted. I ran both in Pilot and Experiment mode and it gave me the same result. I tried running the same experiment on other computers that have half the refresh rate of my laptop (60Hz) and it turned out well on other computers.

I also tried switching to presenting the duration by frames instead of seconds given Timing Issues and synchronisation — PsychoPy v1.82

if expInfo[‘time_prime’] == “50”:
prime_frames = 6
else:
prime_frames = 30

But then it gave me an even weirder mean duration of 15.643 ms and SD of 2.6857 ms which I have no idea what that is about

Link to the most relevant existing thread you have found:

I found nothing on the topic given that this is probably not a PsychoPy problem. However, given that most people here have a better knowledge of how all this works than I do, I wanted to give the question a try and to see if there’s any way to be able to run the experiment from my laptop at some moment in time. I don’t know what else could be affecting these times except for the refresh rate which is higher on my computer than on others that I’ve done it with.

Hello @Srdan_Tomic

A refresh rate of 120 Hz means that the screen is refreshed every 8.33 milliseconds (1,000 ms ÷ 120 = 8.33 ms). Therefore, it is impossible to achieve an exact prime duration of exactly 50 ms. Using frames instead of absolute duration, as you have done, should give you a more accurate and stable duration if properties like vsync aso are turned off. How did you measure the prime duration?

Well, I am conducting masked priming experiments myself. From what I’ve seen, the length of time your prime is presented for doesn’t really affect your experiment, no matter if it’s 47.3627 ms, 50 ms or 52 ms. If you really want to be sure that your prime is masked, conduct a post-hoc experiment in which your participants have to respond to the prime and not the target. Their performance should be random in the 50 ms condition and much better in the 250 ms condition.

By the way, it might be better to calculate the number of frames if you want to run the experiment online instead of hard coding it.

frames_50ms  = round(0.050 * frame_rate)
frames_250ms = round(0.250 * frame_rate)

Best wishes Jens