Best way to code very short image presentations

Hi,

I am building a visual masking experiment and image presentation is very important. I need to make sure that I present images for the shortest possible duration for a 60Hz Monitor, which I believe is something like 16-17ms. I build my task in the coder. And the way I execute my presentation times is with a while loop. Something like this:

# Get images onset, show images, draw fixation cross, flip and wait
image_onset = global_clock.getTime()
current_target.draw()
current_distractor.draw()
fixation_cross.draw()
win.flip()

while global_clock.getTime() < image_onset + image_duration:
    pass

# Get images offset and measure actual image duration
image_offset = global_clock.getTime()
actual_image_duration = image_offset - image_onset
print(f"Trial {i}: Image duration = {actual_image_duration}")

where image_duration=0.017

Do you think this will do what I am asking it to do or likely my code will fail in reality due to the extremely short duration I need? So having the double of that time already messes up with my task.

If you have any other solutions to my problem which may be more precise please let me know.

If you want just one frame then why wait at all? You could flip to present the image and then flip again to hide it.

Is the while loop method likely to fail? also will it be possible to ask how to edit the code? Would it be something like this:

image_onset = global_clock.getTime()
current_target.draw()
current_distractor.draw()
fixation_cross.draw()
win.flip()
—> win.flip()

Hello @antoniyaaboyanova

As I read the code, fixation_cross is displayed for the same duration as the images current_targert and current_distractor (image_duration) because all three stimuli are flipped together and then remain visible until the end of the while loop. I think that you need two win.flip to show the fixation cross for one refresh. One to show target, distractor and fixation cross and a second to show the target and the distractor. Then comes your while-loop.

Best wishes Jens