Welcome! Log In Create A New Profile

Advanced

Blink detection on real time

Posted by IVanegas 
Blink detection on real time
February 03, 2023 02:47PM
Hi Jaewon.
We have noticed that our subject blinks right before making a saccade towards a target. We would like to have a real time blink detection so that we break and repeat the trial when this happens.
Please let me know if a blink detection adapter is already available, or what would be the best way to program a real time blink detection.
Thank you very much.
Re: Blink detection on real time
February 03, 2023 05:16PM
Can you tell when the blinks occurred from the recorded eye traces? If so, it may be possible to detect them.
Re: Blink detection on real time
February 07, 2023 01:52PM
Hi Jaewon.
I just looked at the analog data in the ML behavioral file.
The eye movements oscillate between -30 to 30 when the subject is looking at the target and stimuli within the screen area.
However, when there’s a blink, the eye traces jump suddenly to a value of 96, 97 (x), or -81, -118 (y).

Please let me know your advice on how to implement the real time blink detection using these values.

Thank you very much for your help, it is very much appreciated.

Isabel
Re: Blink detection on real time
February 07, 2023 02:28PM
You can set a fixation window around the point you found and then abort the trial if the fixation is made there.
Re: Blink detection on real time
February 07, 2023 05:52PM
Sure. Would you please suggest what adapter could I use for it?

I currently have the following code for the response period, I create the target, and nest it with a wait then hold adapter. The subject must make a saccade to the target location, but sometimes the subject blinks right before making the saccade, and that is the issue I am having, how to detect the blink on real time.

fixtrg = SingleTarget(eye_);
fixtrg.Target = [ X(TrialRecord.CurrentCondition) Y(TrialRecord.CurrentCondition) ];
fixtrg.Threshold = TargWinTh;
wthtrg = WaitThenHold(fixtrg);
wthtrg.WaitTime = TargWaitTime;
wthtrg.HoldTime = TargHoldTime;

Thank you very much.
Re: Blink detection on real time
February 08, 2023 09:01AM
A custom adapter would work best, but try SingleTarget first.

-----

I looked up our previous communication and found that you were already using a custom blink detector. Look at your old task codes.
Re: Blink detection on real time
February 08, 2023 12:24PM
Thank you Jaewon.
You are right, I used to have a blink detector adapter. However, in the current Matlab version and ML it stopped working. It gives me a strange error about the range, which I was not able to figure out.

If I understand correctly, can I nest the current code, within an additional SingleTarget that covers the area when a blink happens?
Re: Blink detection on real time
February 08, 2023 02:52PM
I do not think it has anything to do with the MATLAB version or NIMH ML. What was the range that you provided?

You can combine the new SingleTarget and your existing chain with AllContinue.
https://monkeylogic.nimh.nih.gov/docs_ScriptingScenes.html#AdapterAggregators

-----

Try this modified BlinkDetector (see the attached file). The original version draws the boundary of the area, but it can cause a problem, if the area is too large or Inf. So I removed the graphic. The new version is now included in the NIMH ML package.
https://monkeylogic.nimh.nih.gov/docs_RuntimeFunctions.html#BlinkDetector
Attachments:
open | download - BlinkDetector.m (1.8 KB)
Re: Blink detection on real time
February 17, 2023 04:42PM
Hi Jaewon.
I just tried the new version of BlinkDetector that you posted, and it works perfectly well!
The range that I am using is the same as I used to before, -18, 18 for X and -19, -14 for Y.

Thank you very much for your time to look into it and help me fixing this issue!
Isabel

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.