Welcome! Log In Create A New Profile

Advanced

Use OnOffMarker to send event code

Posted by Yidong_YANG 
Use OnOffMarker to send event code
January 09, 2024 11:06AM
Hi, I tried to use OnOffMarker to send the event code, but I didn't find the code in the data. I assume that the adapter fix1 will become true when the signal goes into the fixation window, which can trigger the OnMarker. Is there anything wrong?

fix1 = SingleTarget(eye_);  % fixation period
fix1.Target = 1;
fix1.Threshold = fix_window;
fix1_marker = OnOffMarker(fix1);
fix1_marker.OnMarker = FIX_START;
wth1 = WaitThenHold(fix1);
wth1.WaitTime = fix_wait;
wth1.HoldTime = fix_hold;
scene1 = create_scene(wth1,1);

fix2 = SingleTarget(eye_);  % cue period
fix2.Target = 2;
fix2.Threshold = saccade_window;
fix2_marker = OnOffMarker(fix2);
fix2_marker.OnMarker = SACCADE_ON;
wth3 = WaitThenHold(fix2);
wth3.WaitTime = saccade_wait;
wth3.HoldTime = saccade_hold;

Re: Use OnOffMarker to send event code
January 10, 2024 03:22AM
Your OnOffMarkers are not included in the chains. See below.

Also note that SingleTarget does not succeed until the tracker signal stays in the threshold window at least for one entire frame, while the Time property of SingleTarget indicates the time of the signal crossing the threshold. Therefore, the timestamp of OnOffMarker's eventcode is always later than the Time of SingleTarget. See the remarks of SingleTarget in the manual.
https://monkeylogic.nimh.nih.gov/docs_RuntimeFunctions.html#SingleTarget

fix1 = SingleTarget(eye_);
fix1.Target = 1;
fix1.Threshold = fix_window;
fix1_marker = OnOffMarker(fix1);
fix1_marker.OnMarker = FIX_START;
wth1 = WaitThenHold(fix1_marker);
wth1.WaitTime = fix_wait;
wth1.HoldTime = fix_hold;
scene1 = create_scene(wth1,1);  % not necessary for 2.2.36 (May 24, 2023) or later

fix2 = SingleTarget(eye_);
fix2.Target = 2;
fix2.Threshold = saccade_window;
fix2_marker = OnOffMarker(fix2);
fix2_marker.OnMarker = SACCADE_ON;
wth3 = WaitThenHold(fix2_marker);
wth3.WaitTime = saccade_wait;
wth3.HoldTime = saccade_hold;
Re: Use OnOffMarker to send event code
January 11, 2024 05:51AM
Thanks for your reply. However, I found that the reaction time and acquired time were recorded as NaNs using this way.


fix2 = SingleTarget(eye_);  % cue period
fix2.Target = 2;
fix2.Threshold = saccade_window;
fix2_marker = OnOffMarker(fix2);
fix2_marker.OnMarker = SACCADE_ON;
wth3 = WaitThenHold(fix2_marker);
wth3.WaitTime = saccade_wait;
wth3.HoldTime = saccade_hold;
wth3_marker = OnOffMarker(wth3);
wth3_marker.OnMarker = SACCADE_OFF;
scene3 = create_scene(wth3_marker,2);

But when I used Concurrent, the problem was solved.
fix2 = SingleTarget(eye_);  % cue period
fix2.Target = 2;
fix2.Threshold = saccade_window;
fix2_marker = OnOffMarker(fix2);
fix2_marker.OnMarker = SACCADE_ON;
wth3 = WaitThenHold(fix2);
wth3.WaitTime = saccade_wait;
wth3.HoldTime = saccade_hold;
wth3_marker = OnOffMarker(wth3);
wth3_marker.OnMarker = SACCADE_OFF;
conc2 = Concurrent(wth3_marker);
conc2.add(fix2_marker);
scene3 = create_scene(conc2,2);
Re: Use OnOffMarker to send event code
January 11, 2024 06:40PM
You are right, but using Concurrent is not how I want to fix it. I am working on this and will upload a fix soon.
Re: Use OnOffMarker to send event code
January 12, 2024 11:21AM
I made some modifications. Please download the package again. AcquiredTime and RT will be correctly recorded, even though there are intervening adapters between WaitThenHold and SingleTarget.

Thanks for letting me know what I overlooked.
Re: Use OnOffMarker to send event code
January 18, 2024 11:48AM
Hi,

Sorry for the late reply. I updated MonkeyLogic and yes I can record reaction times now. About the accuracy of the timing of OnOffMarker, I did a test and I do have some questions.

It's a simple saccade task, participants have to first fixate at the central fixation for 300 ms. When the fixation disappears, a target will appear simultaneously, they have to fixate on the target for 300 ms. So I have the event markers 10(Fixation On, sent by run_scene function), 11 (Fixation Start, OnOffMarker), 12 (Fixation Start, OnOffMarker), 40(Target On, sent by run_scene function), 41(Saccade On, OnOffMarker), 43(Saccade Off, OnOffMarker), and 50 (Reward, goodmonkey).

Then I did the task in the simulation mode and calculated the mean durations across all trials. There are some differences from the expected values.
1. The duration between Fixation On(11) and Fixation Off(12) should be fixation duration (300 ms), the empirical value is 288.4 ms;
2. The target appears when the fixation disappears, so the duration between Fixation Off(12) and Target On(40) should be ideally 0, but it's 32ms;
3. The duration between Saccade on(41) and Saccade off(43) should be the holding time on the target (300 ms), it's 315 ms;
4 The reward should be delivered immediately after Saccade Off (43), but there is a delay of 17 ms.

I'm not sure if it's normal and can be fully explained by the problems of OnOffMarker that you have mentioned.
Attachments:
open | download - saccade_map.m (2.3 KB)
open | download - saccade_map_userloop.m (1.5 KB)
open | download - verify_event_timing.m (361 bytes)
Re: Use OnOffMarker to send event code
January 19, 2024 06:58AM
I assume you know how the scene framework works. If not, please read the following manual page.
https://monkeylogic.nimh.nih.gov/docs_CreatingTask.html#RuntimeVersion2_Background

Another thing that you need to understand is the difference between stimulus events and behavioral events. For stimuli, it is you that determine when they will be presented, so you can set an eventcode in advance and make it recorded at the same time when the stimuli are presented. For behavior, however, you do not know when the subject will make a response and therefore can mark it only after you observed it. Keeping this in mind, see my comments below.

1. Your script assumes that the order of the recorded eventcodes will always be the same, but that may not be the case. During your test, I guess you located the mouse cursor inside the fixation window early before a trial started. In case the fixation is made before the scene start, the code 11 is stamped before the code 10. So, it is likely that you calculated the interval between 10 and 12, not between 11 and 12. Please check your data file.

2. The code 12 is not the time when the fixation point (i.e., stimulus) disappears but the time that the 300-ms fixation (i.e., behavior) is completed. It is at the time of the code 40 that the target appears and the fixation point disappears. The target graphic is activated (and the fixation point is deactivated) when the fixation requirement is fulfilled, which is right after the frame in which the code 12 is issued, and it takes another frame for the graphic to be actually displayed on the screen, so the interval between 12 and 40 is about two frames.



3. The interval between those two codes cannot be exactly 300 ms. You do not know whether the 300-ms fixation is completed until 300 ms has actually passed, so the interval is always greater than 300 ms. It seems that the multiple of the frame length nearest to 300 ms in your setup is ~299 ms, so one more frame is needed to fulfill the 300-ms fixation.

4. The saccade scene ends at the end of the frame in which the code 43 is issued and then the reward command is executed, so the interval between those two events is almost one frame.
Attachments:
open | download - scene_transition.png (10.3 KB)
Re: Use OnOffMarker to send event code
January 19, 2024 12:04PM
Thanks for your reply. The code 11 was indeed sent before the code 10 in most of the trials.

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.