Welcome! Log In Create A New Profile

Advanced

Maximum Latency

Posted by ntk1 
Maximum Latency
March 10, 2020 11:19AM
Hello,

I have a question about Max latency value in MonkeyLogic build 95 (October 2017) and build 204 (February 2020). What does Max latency value represent? When the task is running, we see the Max latency being updated in the very end of the trial, but not during the trial. Would it be possible for us to know the latency value during the trial (e.g. by adding a few lines of code to a timing script), so we could narrow down the causes of increased latency in our setups, etc.?

Thank you for your help
Re: Maximum Latency
March 10, 2020 08:14PM
Are you experiencing any problem due to an increased latency? I wonder why you want to do something with it, even though you do not know its meaning.

The eyejoytrack function has a loop inside. At each iteration of the loop, a new analog sample is retrieved and checked. Max latency is the longest interval between two consecutive iterations and Cycle rate is the mean number of iterations per second. Ideal values for Max latency and Cycle rate would be <1 ms and >1000 Hz, respectively, granting a millisecond-resolution monitoring. However, Max latency you actually get is typically larger than that, because MATLAB scripts are slow at their first run and therefore the intervals between the first few samples are usually longer than a millisecond. If your cycle rate is >1000 Hz and you don't see a particular problem in the Latency test, I don't think you should worry about a max latency of >1 ms.

There is nothing much you can do about it, even if you get a large max latency. A faster CPU is the only way to improve it. You cannot check the latency value just by adding some code to a timing script. If what you are interested in is just the performance of your code, try MATLAB profiler.

The scene framework does not use eyejoytrack, so what I explained above is not applicable to the scripts written with the scene framework.
Re: Maximum Latency
March 17, 2020 01:29PM
Thank you very much for your answer and sorry for my delayed response. We are in the process of getting a faster CPU and hopefully this will bring our high latency down. I was wondering how the maximum latency value might affect electrophysiology recordings. Say, the neural data is recorded while an animal subject touches the screen and the eventmarkers get sent to the ephys system. My initial worry was that there would be a significant delay between the detected screen touch (using eyejoytrack function) and the eventmarker which is recorded by MonkeyLogic as soon as the touch is made. Would the Maximum Latency affect the interval between the touch detected by MonkeyLogic and the eventmarker timestamp being made? I understand the delays related to the hardware. But internally, in MonkeyLogic/MATLAB, there should be no interrupton between the moment the touch is registered by MonkeyLogic and the eventmarker recorded, is that right? Thank you for your help.
Re: Maximum Latency
March 17, 2020 04:59PM
How high is your latency? As I said above, you may be concerned about it unnecessarily. And what is your usual cycle rate?
Re: Maximum Latency
March 26, 2020 08:07PM
Hi,

In some cases the maximum latency reaches 20ms and the cycle is around 2200Hz. We are upgrading our setup and the values are likely to come down. With the current values, should we worry, you think?

Thank you
Re: Maximum Latency
March 27, 2020 12:09AM
Do you get 20 ms in the 2nd trial as well or even after 5-6 trials? Otherwise, I think it is okay. Again the maximum latency is usually the interval between the 1st and 2nd sample checks, which occurs at the very beginning of a trial. For the rest of the trial, the latency must be less than 0.5.ms, as indicated by your cycle rate (1/2200 = 0.45 ms).
Re: Maximum Latency
March 27, 2020 08:16PM
Hi Jaewon,

It looks like we are ok then. Thank you very much for your help.

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.