Visual stimulus frame flip - outputting TTL pulse via USB

Hello

We are trying to carry out a very precise visual stimulus experiment (neuroscience) and would like to know when the screen is refreshed by PTB.

I am not a matlab expert, but as far as I can see this is the code that draws our stimulus.

function showObject_(self, object_features)
            Screen('DrawTextures', self.window.ptr, object_features.texture_ptr, [], ...
                object_features.destRect, [], [], [], [], [], kPsychUseTextureMatrixForRotation);
        end

We currently use a simple USB TTL device like this (and we think we can figure out how to find the COMport via matlab/PTB):

What’s not clear is where the draw command is being updated and run by PTB. Is there any instructions / manual I can read on this function? Or is this not the right function?

Thanks so much,

This is an old question, but a critical one for the precise trigger.
The code you showed is drawing into the buffer only. The real stimulus onset is Screen('Flip', ....) later. The practical way is to send the trigger immediately after Flip by IOPort('Write', ...).

Thanks so much, i will search for the function and see if we can access it.
C

But that is only half of the problem if you care about stimulus timing. Screen('flip') will return just before stimulus is scheduled for presentation, and if you read the documentation it can also provide an estimate of stimulus onset and does lots of setup to ensure timing is well monitored (at least on Linux):

http://psychtoolbox.org/docs/Screen-Flip

What PTB cannot know is whether the display is temporally precise or not. Almost all flat panel displays ARE NOT! They exhibit lag between when a signal is sent and when luminance changes onscreen. Therefore in addition to a TTL that is sent out after the first Screen('flip') you should also use a photodiode placed on the screen to actually monitor a luminance change (you can draw a small black to white square in the top left corner that the photodiode can measure). I use AMS TSL-251 light-to-voltage photosensors as they do not require external circuitry (you can record the voltage output directly), and 70µs rise time is good enough. You will find the TTL can precede the photodiode signal by 10s of milliseconds on average for most displays. This is mostly deterministic lag (though may vary based the luminance to luminance transition), but this lag is huge in terms of thinking about signal processing by the brain (enough time to hop several synapses)… You could work this lag value out for your stimuli before the experiment, then offset the real time-0, but it does make sense to just always record the photodiode signal when collecting your data to ensure fidelity.

If you really want good temporal precision, professional vision display tools like the Display++ and DataPixx/ViewPixx have TTL output locked precisely to actual display output.

Thanks so much, the diode was also part of the plan, but it seems like it should be done asap.
Will try to find this sensor.
All the best,
c