This page is a work in progress

!!Precision timing in computer displays

Many people ask about how precisely PsychoPy can time stimulus presentation. This page is devoted to answering those queries.

The main timing implications come from the fact that PsychoPy uses OpenGL and does so in in double-buffered mode (usually synchronised to the vertical blank of the screen). Since nearly all modern stimulus display methods share these features, the information below is relevant to all those methods.

The questions this page will answer are

I need millisecond precision in timing of responses. Can PsychoPy give me that?

Probably, given some additional hardware. The clocks that PsychoPy uses do have sub-millisecond precision but your keyboard has a latency of 4-25ms depending on your platform and keyboard. You could buy a response pad (e.g. Cedrus RB-530) and use PsychoPy's serial port commands to retrieve information about responses and timing with a precision of around 1ms.

For most experiments, however, sub-millisecond accuracy is probably not actually that useful, given that your stimuli are presented with a temporal resolution limited by the screen (and your visual system).

When you update the your CRT screen, the pixels at the bottom are drawn up to 10ms later than the pixels at the top of the screen. At what point are you going to say your stimulus 'appeared' to the participant? If you use an LCD panel (or LCD projector) your image will be presented simultaneously all over the screen, but it takes up to 20ms(!!) for your pixels to go all the way from black to white. So, if you're using a regular computer display, you have a hardware-limited temporal precision of 10ms irrespective of your response box or software clocks etc... and should bear that in mind when looking for effect sizes of less than that.

Fig1: The image below shows the luminance trace of a CRT recorded by a fast photo-sensitive diode at the top of the screen when a stimulus is requested (shown by the square wave). Note shortly after the 'bright' stimulus is requested the flash of the screen increases.

Fig2: The image below shows comes from exactly the same script as the above but the photodiode is positioned at the bottom of the screen. In this case, after the stimulus is 'requested' the current frame (which is dark) finishes drawing and then, almost exactly 10ms later than the above image, the screen goes bright at the bottom.

go to top

Can I have my stimulus to appear with a very precise rate?

Yes. Generally to do that you should time your stimulus (it's onset/offset, its rate of change...) using the frame refresh rather than a clock. e.g. you should write your code to say 'for 20 frames present this stimulus' rather than 'for 300ms present this stimulus'. Provided your graphics card is set to syncronise page-flips with the vertical blank, the frame rate will always be absolutely constant. One caveat is that you should check that you don't drop any frames see below.

There are two reasons this is important for extremely precise timing. The first is that if you ask PsychoPy to present your stimulus for 300ms you might forget that it could never be exactly 300ms (25 frames would give 294ms on an 85Hz monitor, 26 frames would give 306ms).

go to top

How do i synchronise PsychoPy with other hardware?

How would I know if I dropped a frame?

Valid XHTML 1.0! Valid CSS!