Weird One frame delay with flip

Hi All,

I am having a weird one frame delay problem with PTB. I am using version 3.0.8 with a Matrox Parhelia PCI card and a CRT monitor setup to 100Hz.

Below is the smallest code snippet I managed to crop which nicely demonstrates the problem. I am flipping between middle gray to white.

I am using a DAQ to signal events and to record with a photodiode the screen response.

You can see the response here: http://brainstory.info/PTB.pdf

Basically, the blue curve shows the event signaled. You can see that I call Flip quite early in the cycle, and that the actual refresh only happens two frames later. The update should have been at ~4473, but only happens at ~4483.

I already ruled out any potential reasons for this that might be caused by the DAQ/photodiode equipment.

Any idea why or how to fix this ?

Many thanks,

Shay


----------------------------------------

hScreen = Screen(0,'OpenWindow',0,[],[],2);
Screen(hScreen,'FillRect',[128 128 128]);
Screen(hScreen,'Flip');
WaitSecs(1 + 2/1000);

fnDAQ('SetBit',1,1);
Screen(hScreen,'FillRect',[255 255 255]);
Screen(hScreen,'Flip');
fnDAQ('SetBit',1,0);

WaitSecs(1 + 3/1000);

fnDAQ('SetBit',1,1);
Screen(hScreen,'FillRect',[128 128 128]);
Screen(hScreen,'Flip');
fnDAQ('SetBit',1,0);

Screen('CloseAll');

----------------------------------------
Hey Mario,

All the sync tests passed without any major issue.
But you did raise a valid point which I completely overlooked. I placed the photo-diode at the button right corner of the screen. This should explain why it took 10ms until I got the response.

I will move it to the top left corner and see if this makes a difference.

Thanks for your help!

-- Shay


--- In psychtoolbox@yahoogroups.com, "kleinermario" <mario.kleiner@...> wrote:
>
> I assume this is running under WindowsXP with the latest PTB 'beta'?
>
> The most important two questions are: Did you try turning it off and on again? Where is the photo-diode placed on your monitor?
>
> And then...
>
> What is the Matlab output of Psychtoolbox? Any warnings/errors wrt. timestamping, timing etc.? Does the PerceptualVBLSyncTest and VBLSyncTest scripts perform correctly? Single-Display or multi-display setup?
>
> -mario
>
> --- In psychtoolbox@yahoogroups.com, "shayo1979" <shayo1979@> wrote:
> >
> > Hi All,
> >
> > I am having a weird one frame delay problem with PTB. I am using version 3.0.8 with a Matrox Parhelia PCI card and a CRT monitor setup to 100Hz.
> >
> > Below is the smallest code snippet I managed to crop which nicely demonstrates the problem. I am flipping between middle gray to white.
> >
> > I am using a DAQ to signal events and to record with a photodiode the screen response.
> >
> > You can see the response here: http://brainstory.info/PTB.pdf
> >
> > Basically, the blue curve shows the event signaled. You can see that I call Flip quite early in the cycle, and that the actual refresh only happens two frames later. The update should have been at ~4473, but only happens at ~4483.
> >
> > I already ruled out any potential reasons for this that might be caused by the DAQ/photodiode equipment.
> >
> > Any idea why or how to fix this ?
> >
> > Many thanks,
> >
> > Shay
> >
> >
> > ----------------------------------------
> >
> > hScreen = Screen(0,'OpenWindow',0,[],[],2);
> > Screen(hScreen,'FillRect',[128 128 128]);
> > Screen(hScreen,'Flip');
> > WaitSecs(1 + 2/1000);
> >
> > fnDAQ('SetBit',1,1);
> > Screen(hScreen,'FillRect',[255 255 255]);
> > Screen(hScreen,'Flip');
> > fnDAQ('SetBit',1,0);
> >
> > WaitSecs(1 + 3/1000);
> >
> > fnDAQ('SetBit',1,1);
> > Screen(hScreen,'FillRect',[128 128 128]);
> > Screen(hScreen,'Flip');
> > fnDAQ('SetBit',1,0);
> >
> > Screen('CloseAll');
> >
> > ----------------------------------------
> >
>
That explains it and was my top suspect. I'd actually love to see the Matlab output for your Matrox Parhelia anyway. It is a rather exotic card, so it is nice to see how it behaves.

Also if you intend to do work that requires timing precision, make sure to familiarize yourself with the scripts i mentioned. VBLSyncTest is a perfect example on how to do optimally timed stimulus onset and on how to use the various timestamps returned by Screen('Flip') to verify your timing even without a photo-diode. And the PDF file in the PsychDocumentation folder is also a good read (Your slightly weird use of WaitSecs in your example somehow tells me that you really should read that PDF and look at the example code).

Oh one more thing: The plots of VBLSyncTest will give you a feeling for the latency to expect from stimulus onset to the point in time when your DAQ trigger function is executed -- a measure of the timing variability for this digital trigger approach.

Our timestamps are normally sub-millisecond accurate on correctly working setups -- better than the timestamps you can get with the photo-diode. Which doesn't mean you shouldn't use a photo-diode for occassional verification.

best,
-mario

--- In psychtoolbox@yahoogroups.com, "shayo1979" <shayo1979@...> wrote:
>
> Hey Mario,
>
> All the sync tests passed without any major issue.
> But you did raise a valid point which I completely overlooked. I placed the photo-diode at the button right corner of the screen. This should explain why it took 10ms until I got the response.
>
> I will move it to the top left corner and see if this makes a difference.
>
> Thanks for your help!
>
> -- Shay
>
>
> --- In psychtoolbox@yahoogroups.com, "kleinermario" <mario.kleiner@> wrote:
> >
> > I assume this is running under WindowsXP with the latest PTB 'beta'?
> >
> > The most important two questions are: Did you try turning it off and on again? Where is the photo-diode placed on your monitor?
> >
> > And then...
> >
> > What is the Matlab output of Psychtoolbox? Any warnings/errors wrt. timestamping, timing etc.? Does the PerceptualVBLSyncTest and VBLSyncTest scripts perform correctly? Single-Display or multi-display setup?
> >
> > -mario
> >
> > --- In psychtoolbox@yahoogroups.com, "shayo1979" <shayo1979@> wrote:
> > >
> > > Hi All,
> > >
> > > I am having a weird one frame delay problem with PTB. I am using version 3.0.8 with a Matrox Parhelia PCI card and a CRT monitor setup to 100Hz.
> > >
> > > Below is the smallest code snippet I managed to crop which nicely demonstrates the problem. I am flipping between middle gray to white.
> > >
> > > I am using a DAQ to signal events and to record with a photodiode the screen response.
> > >
> > > You can see the response here: http://brainstory.info/PTB.pdf
> > >
> > > Basically, the blue curve shows the event signaled. You can see that I call Flip quite early in the cycle, and that the actual refresh only happens two frames later. The update should have been at ~4473, but only happens at ~4483.
> > >
> > > I already ruled out any potential reasons for this that might be caused by the DAQ/photodiode equipment.
> > >
> > > Any idea why or how to fix this ?
> > >
> > > Many thanks,
> > >
> > > Shay
> > >
> > >
> > > ----------------------------------------
> > >
> > > hScreen = Screen(0,'OpenWindow',0,[],[],2);
> > > Screen(hScreen,'FillRect',[128 128 128]);
> > > Screen(hScreen,'Flip');
> > > WaitSecs(1 + 2/1000);
> > >
> > > fnDAQ('SetBit',1,1);
> > > Screen(hScreen,'FillRect',[255 255 255]);
> > > Screen(hScreen,'Flip');
> > > fnDAQ('SetBit',1,0);
> > >
> > > WaitSecs(1 + 3/1000);
> > >
> > > fnDAQ('SetBit',1,1);
> > > Screen(hScreen,'FillRect',[128 128 128]);
> > > Screen(hScreen,'Flip');
> > > fnDAQ('SetBit',1,0);
> > >
> > > Screen('CloseAll');
> > >
> > > ----------------------------------------
> > >
> >
>