# [visionegg] Re: Sync swap buffers and triggers

• From: Andrew Straw <astraw@xxxxxxxxxxx>
• To: visionegg@xxxxxxxxxxxxx
• Date: Mon, 20 Dec 2004 11:59:43 -0800
Dear Alessandra,

Sorry I've taken so long to respond -- I've been quite busy lately. My answers are below.

alessandra.stella@xxxxxx wrote:

Dear Andrew,
thank you so much, it works great!!!
I'm sorry to bother you, but I have several questions to ask you:
every time I run a script I obtain this message in the vision-egg log file:
-----------------------------------------------------------------------------------
2004-12-06 12:28:03,190 (3480) INFO: Script C:\Documents and
settings\Alessandra\Documenti\esperimento
shift visionegg\programmi python per exp shifting\in progress\un solo
trigger_prova
senza tgt.py started Vision Egg 1.0-cvs with process id 3480.
2004-12-06 12:28:09,628 (3480) INFO: Requesting window 1280 x 1024 32 bpp
(8 8 8 0 RGBA).
2004-12-06 12:28:09,736 (3480) INFO: OpenGL 1.3.0 - Build 4.14.10.3691,
Intel Springdale-G, Intel
2004-12-06 12:28:09,736 (3480) INFO: Video system reports 32 bpp (8 8 8
8 RGBA).
2004-12-06 12:29:09,721 (3480) WARNING: Calculated frames per second was
85.560, while the VISIONEGG_MONITOR_REFRESH_HZ variable is 70.0.
2004-12-06 12:29:09,721 (3480) WARNING: One or more frames took 36.8 msec,
which is signficantly longer than the expected inter frame interval of 14.3
msec for your frame rate (70.0 Hz).
2004-12-06 12:29:09,721 (3480) INFO: 5135 frames were drawn.
Mean frame was 11.69 msec (85.56 fps), longest frame was 36.82 msec.
histogram:
3686                               *

 3277                               *

 2867                               *

 2458                               *

 2048                               *

 1638                               *

 1229                               *

  819                               *

  410                               *    *

    0      *    *              *    *    *    *    *    *    * *
Time:    0    2    4    6    8   10   12   14   16   18   20   22   24
+(msec)
Total:      5    4    0    0   256  +++  719   33   3    3    2    0 13
-----------------------------------------------------------------------------------

Can this have something to do with the synchrony of swap buffers with the
vertical blanking period?

Here's what I think is happening:

Your graphics drivers are synchronizing buffer swap with vsync (which is happening at 85 Hz, not 70 Hz as you input in the Vision Egg GUI dialog). In Windows this is usually set, on nVidia cards at least, in the Settings->Control Panels->Display->Advanced under some sort of "Apps use VSYNC" setting. The Vision Egg does nothing to override the default settings from the OS/graphics drivers. Nevertheless, it appears that somehow there are a few frames drawn extremely quickly (<4 msec IFI) and 13 frames where a frame was skipped. I'm not sure why either should happen, but neither have I ever used your graphics card ("Intel Springdale-G").

When I check "attempt to synchronize swap buffers"
in the dialog box of Vision Egg, the program doesn't start (but It works
perfectly if I don't check this option) and I got an error printed in the
console, which I can read just a first part, because it closes immediately
the program and there's no trace of this in the vision egg log file. The
error is the following:

Pygame Parachute Traceback:
File "C:\Python23\lib\site-packages\VisionEgg\PlatformDependent.py", line
187,
in sync_swap_with_vbl_post_gl_init (?)

This is indeed strange, and I cannot explain it without serious debugging... Basically, there is a low-level crash of the kind that shouldn't happen in Python. Given that you're in Windows, where you can override all the default vsync settings from the display control panel (at least with nVidia cards), I would suggest ignoring the "vsync" checkbox in the Vision Egg GUI and using just the Windows Control Panel.

----------------------------------------------------------------------------------------
Must I synchronize swap buffers, also in order to have correct trigger timing?

It depends on how accurately you want the triggers. If within-the-nearest-IFI (1.0/85 Hz is approx. 12 msec) is OK, then no, you don't have to synchronize the buffer swap to vsync. Otherwise, yes, it's a good idea and also a bit trickier.

Another question is about the triggers (again, I know!): now I have the
triggers for the Gabors (thank you!). I need also to trigger, to the computer
recording EEG, when other two stimuli (two small arrows, one on the left
and one on the right) appear, alternately, on the screen.
I tried to add a controller to presentation like I the one I saw in the
demo DAQ\ trigger_out but the output are several triggers that last the
duration the stimulus is on; I just need a pulse that triggers the
first moment (frame?) that the stimulus appears on the screen. Also, I can?t ?name? the trigger to understand which trigger belongs to
which arrow.
I tried to use the simple_lpt_out, too, but I guess I should add it to Presentation
at some point (?), and I don?t know how to do that. I attached the script
below.

I think I get what your saying, and I've modified your script to do just this. Please let me know if this works.

--
Andrew D. Straw  Post-doctoral scholar
,-.              Dickinson Lab
\_/              California Institute of Technology
8||}             Mailcode 138-78
/ \              Pasadena CA 91125, USA
-^
email:  astraw@xxxxxxxxxxx
office: +1 626 395 5828`