Trigger delays are highly variable and imprecise

I am not sure what you mean by “static component”… I have moved up the code component where I send the triggers, hoping that it introduces less delay.

However, as I am loading each image at each trial iteration, I am not sure how can I load the image before the trial… would you have a solution for this? Should I introduce an extra routine before the routine “trial” to just load the image and then display it in the routine “trial”? Would that improve the situation?

I have another related question on how I am sending triggers… at the moment I using this function pulse, which is defined like this:

PULSE_MS = 20 # ms

def pulse(code, dur_ms=PULSE_MS):
port.setData(int(code))
if dur_ms and dur_ms > 0:
core.wait(dur_ms / 1000.0)
port.setData(0)

is this ok or there are better ways of defining a trigger function?

Thank you so much for this help