Welcome! Log In Create A New Profile

Advanced

Handling adapters of different durations so the shorter one does not override the longer ones?

Posted by jamesbutler01 
Hi Jaewon.

I wish to monitor and log eye position events, but only progress the task when a joystick action occurs. I have the following code:


while 1
  
   % Eye tracker
    eye_fix = SingleTarget(eye_);  
    eye_fix.Target = [0 0];  
    eye_fix.Threshold = 3;
    eye_wth = WaitThenHold(eye_fix);
    eye_wth.WaitTime = 5000;
    eye_wth.HoldTime = 100;

    % Joy tracker
    joy_fix = SingleTarget(joy_);  
    joy_fix.Target = [4 4];  
    joy_fix.Threshold = 3;
    joy_wth = WaitThenHold(joy_fix);
    joy_wth.WaitTime = 5000;
    joy_wth.HoldTime = 500;

    % Link them together
    or = OrAdapter(eye_wth);
    or.add(joy_wth);
    scene = create_scene(or);
    run_scene(scene);

    if joy_wth.Success
           % Break out the loop and continue to next stage of the task
           break
    elseif eye_wth.Success
          % Do eye response
          eventmarker(eye_event_marker);
    end

end

But joy_wth will never be set to Success if they are also correctly doing the eye fixation, due to the shorter hold time needed for eye_wth. Is there a way around this?

Thanks!
Okay. Just to be sure if I understood correctly, does the subject need to move joystick with peripheral vision while holding fixation at the center? I am not sure whether you want the subject to do two responses simultaneously or sequentially and, if it has to be simultaneous, why the hold time for eye is shorter.
I wish to track when the subject looks at the target (and other targets on the screen, I just didn't include them in the example code), in addition to when he moves the joystick to the target.

So four targets will appear on the screen which subject will look at and then move joystick to one of them to make a choice, and I need event markers to be triggered whenever he saccades to any of the targets (which will be really fast and happen lots) and then the loop to break when he makes one movent and choice with the joystixk
I don't think your script will work well, but it is not because of the reason you said.

When run_scene() is called, the scene restarts from the beginning and so does the 5000-ms wait time. You should make the whole thing as one scene.

The only condition necessary to proceed to the next scene is the acquisition of joystick movement at [4 4], so you should design your scene to be stopped only when it occurs. Whether the subject looks at a particular target is not relevant, which means that you should not include eye_wth to the scene.

The OnOffMarker adapter does something similar to what you want with eventmarkers. And, to avoid stopping the scene while checking eye positions, you can use the Concurrent adapter. So you may write the scene like this:

joy_fix = SingleTarget(joy_);
joy_wth = WaitThenHold(joy_fix);

target1 = SingleTarget(eye_);
marker1 = OnOffMarker(target1);
target2 = SingleTarget(eye_);
marker2 = OnOffMarker(target2);
target3 = SingleTarget(eye_);
marker3 = OnOffMarker(target3);
target4 = SingleTarget(eye_);
marker4 = OnOffMarker(target4);

con = Concurrent(joy_wth);
con.add(marker1);
con.add(marker2);
con.add(marker3);
con.add(marker4);

scene = create_scene(con);

However, using eventmarkers to record free-viewing patterns in the scene framework is not a good idea, because of the reason described in the following manual page.
https://monkeylogic.nimh.nih.gov/docs_CreatingTask.html#RuntimeVersion2_Background

If I were you, I would check only joystick during the scene and analyze looking behavior offline with recorded eye signals.

----------

By the way, if you want to wait for the longer adapter chain in general, you can use AnyContinue.
Thanks Jaewon, this explained it perfectly for me.

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.