Home Questions How to display stimuli for exactly one frame (~16ms)

How to display stimuli for exactly one frame (~16ms)

DWQA QuestionsCategory: Custom Task DevelopmentHow to display stimuli for exactly one frame (~16ms)
Jonathan Michaels asked 4 years ago
Hello, This is a follow-up to my previous question (I couldn't add comments to it). I did as was suggested and used the last_frame_sent variable to display the stimulus for only one increment. However, doing this for only one frame leads to a blank screen most of the time, since last_frame_sent is actually incrementing at approx. ~600 Hz, much faster than the refresh of the monitor. Are there any other variables that might be synced to the refresh of the monitor? Thanks, Jonathan
Koloman Varady Staff replied 4 years ago

Hi Jonathan,

I talked to one of our programmers and I had given you some bad advice.

What you should do is store the last_frame_sent when you decide to draw something. Then the signal you should watch for is last_frame_acknowledged.

when last_frame_acknowledged > last_frame_sent then your frame has been drawn and the next frame is going to draw next.

Cheers,
Koloman

Jonathan Michaels replied 4 years ago

Hi Koloman,

Thanks for the response. I tried this approach, but it doesn’t work quite right, largely because the acknowledged frame lags quite a bit behind the current frame. However, I can get around this by estimating the refresh clock of the monitor based on previous acknowledged frames.

More importantly, I noticed a different problem. If I draw frames for a random amount of time drawn uniformly between 0-170ms and observe how long these targets were drawn using a photodiode, it seems to be impossible to draw targets for only one frame. Here’s a histogram: https://imgur.com/iqiAgNu. Notice that the 16.666 ms bin is empty. Zero means that the target was not drawn.

Do you guys have any ideas how this could be happening?

Thanks,

Jonathan

Koloman Varady Staff replied 4 years ago

Hi Jonathan,

Let me first respond to the initial inquiry. After further discussion with our developers, you are correct that using the acknowledgement to turn off a short stimulus will not be reliable. In addition to the delay that you noted, there is a certain amount of uncontrolled jitter in the timing of that acknowledgement. Your suggestion of estimating the timing based on previous acknowledged frames should be a robust solution.

In terms of the new issue, we have done lots of experiments and testing over the years, and we can certainly display stimuli for a single frame. In terms of why you are not see that, there are a couple of possibilities. My first thought is “what does the analog signal from the diode look like”? It is possible that there is a threshold problem – if the diode is somewhat slow to respond to the stimulus, then it might require a 30+ ms stimulus in order to reach threshold. I assume that your diode can put out an analog measure as well as a digital on/off? If so, then I would record that as well and look at it to see how the analog and digital responses of the diode compare. You may need to adjust the threshold of your diode. In terms of further investigation, I might also suggest to use an even distribution of stimulus commands, rather than randomly drawing from an even distribution. This will allow better quantification of what is happening under which conditions (i.e. a more controlled stimulus command).

Thanks,

Ian

Jonathan Michaels replied 4 years ago

Hi Ian,

Thanks for your detailed response.

Regarding the diode – I have been using the analog signal to determine the timing. The rise time is extremely quick, but it falls off slowly (which I compensate for), so we don’t see how the diode could cause this. Here is an example where I would say the stimulus was on for 2 monitor frames (Fig. 1 – https://imgur.com/a/J14HMHm).

I devised a more general test by making a program that’s stripped of all elements except testing the timing. The program drew a target for 0 to 60 iterations of the internal program exactly 4 times each. Here are those trials plotted against the corresponding stimulus draw time as determined by the photodiode (Fig. 2 – https://imgur.com/a/J14HMHm). As you can see, there is an ominous gap in the plot at 1 monitor cycle (~17ms).

Unless you have an answer, I would suggest that either I run some test program from you here to see if there’s something misconfigured with our setup, or you can run my program on your end?

Feel free to email me at jonathan.michaels@uwo.ca instead of commenting here.

Thanks,

Jonathan

Anne Vivian-Scott Staff replied 4 years ago

Hi Jonathan, With apologies, our website was not sending us notifications about your post. We believe we have now remedied this issues. Koloman will be following up with you directly.
Anne

1 Answers
Koloman Varady Staff answered 4 years ago
There is now an example task that will show how to display stimuli for a single visual frame https://kinarm.com/download/show-target-for-a-single-frame-on-subject-display/