Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
frankdopamine

Junior Member
Registered:
Posts: 5
Reply with quote  #1 

Hi everyone,

I'm Francesco, a PhD student in the Aldo Genovesio’s Lab at Sapienza University.

We carry out behavioural experiments and electrophysiological recording with monkeys in order to study the neuronal activity in a variety of cognitive domains.

For developing our behavioural tasks, we used another software called NIMH Cortex, but we have started to use Monkey Logic for some months. My co-worker Simon Nougaret and I have been designing two tasks with the first version of trialholder, and so I’d like to thank Jaewon for his work on this fantastic software.

Now I’m moving to the new version of trialholder (v2) to develop other tasks. We’re having a problem that we already had with the first version of trialholder  (previous post: http://forums.monkeylogic.org/post/touch-out-of-a-defined-taskobject-9688837?pid=1303636144).

In these tasks, the monkey must touch a central target or one of two objects and to maintain his touch for half a second on a touchscreen.

We want to add the possibility to detect the touch of the monkey not only in the area of a defined target/s but also out of this area/s. In this way, if the monkey touches out of the object/s, the trial must be aborted.

This is the code for “the Central Target scene”

wait_for_touch_CT = 5000;

holding_CT = 500;

fix_radius = 3;

 

touch1 = SingleTarget(touch_);

touch1.Target = CT;

touch1.Threshold = fix_radius;

wth1 = WaitThenHold(touch1);

wth1.WaitTime = wait_for_touch_CT;

wth1.HoldTime = holding_CT;

 

scene1 = create_scene(wth1, CT);

%TASK EVENT:

%---------SCENE 1: Touch and holding of CT BEFORE the peripheral target appearence----------

run_scene(scene1, 25); %CT ON

if ~wth1.Success  %No touch or brake touch  

    if wth1.Waiting %No touch      

        trialerror(1);

        eventmarker(19);% NO_TOUCH CT WITHIN FIXED TIME

        eventmarker(98);% ABORT DURING NO SURE TRIAL

        eventmarker(99); %GENERAL CODE FOR ABORT

    else      

        trialerror(3);% Brake touch during holding

        eventmarker(14); %Hand control during PRE_holding

        eventmarker(98);% ABORT DURING NO SURE TRIAL

        eventmarker(99); %GENERAL CODE FOR ABORT

    end

   

    run_scene(endscene);   

    return  

else % TOUCH

    eventmarker(32);

end

 

This is the code for “Two peripheral object scene” and the monkey must choose one of them:

max_mvt_time = 3500;

prefeedback = [600 400];

fix_radius = 3;

 

%---------SCENE 6: PERIPHERAL TARGET SELECTION--------------------

mul1 = MultiTarget(touch_);

mul1.Target = [target_left, target_right];

mul1.Threshold = fix_radius;

mul1.WaitTime = max_mvt_time;

mul1.HoldTime = prefeedback;

mul1.TurnOffUnchosen = false;

 

scene6 = create_scene(mul1,[target_left, target_right]);

%TASK EVENT:

run_scene(scene6);    

if ~mul1.Success   

    if mul1.Waiting      

        trialerror(2);   

    else

        trialerror(3);   

    end

    run_scene(endscene);

    return

end

if target_right ==mul1.ChosenTarget

    trialerror(0); % correct

    goodmonkey(50, 'NumReward',3); % 50ms of juice x 3

    return

else

    trialerror(6); % wrong

    run_scene(endscene);

    return

end


Therefore, my question is:

Is there a way with SingleTarget (plus WaitThenHold) and MultiTarget adaptor to define the condition in which the monkey touch out of the detection window?

Thank you in advance for your response,
Francesco Ceccarelli.

0
Edward

Administrator
Registered:
Posts: 251
Reply with quote  #2 

Hello frankdopamine,

You can define another touch adaptor touch2. touch2 will define the "outside" area where if the monkey touches, the trial aborts. Then you can use the OrAdaptor to combine both touch1 and touch2 such that if the monkey touches any one of the areas defined by them, the trial stops immediately. Then you can use the Success property of both adaptors to determine which one the monkey's touch has triggered.

Let me know if you have any further questions

0
Jaewon

Administrator
Registered:
Posts: 727
Reply with quote  #3 
First of all, the old scripting method and the scene framework are rather complementary. If you can build your task with toggleobject() and eyejoytrack(), there is no need to switch to the scene framework.

Second, to avoid unnecessary delays between scenes, all scenes must be created before any run_scene() is called. Please see this manual page.
ftp://helix.nih.gov/lsn/monkeylogic/ML2_doc/runtimefunctions.html#HowToCreateAdapterChains

Third, I don't think there is an easy way to do what you want with the current adapters, but you can modify SingleTarget and MultiTarget and make your own adapters. Inverting the threshold windows for multiple targets is not possible in the trialholder v1, either, I believe.
0
Jaewon

Administrator
Registered:
Posts: 727
Reply with quote  #4 
By the way, what do you want to do, if touching outside of the window can be detected? Are you going to abort the trial immediately?
0
frankdopamine

Junior Member
Registered:
Posts: 5
Reply with quote  #5 
Hi Jaewon and Edward,

First of all, thank you for your answers.

Quote:
Originally Posted by Jaewon
By the way, what do you want to do, if touching outside of the window can be detected? Are you going to abort the trial immediately?

In our task every trial starts with the presentation of a target (white circle, please see the second attached file), the monkey has to keep the target pressed for a specific interval of time (Holding time: 500 ms) and he has to touch it within a specific time window (5000 ms).

 Taking this into account, we would like to abort the trial if:

1)      The monkey touches the whole area out of the threshold window around the target, also for few milliseconds (without keeping this area pressed). In other words, when the monkey touches any part of the touchscreen except the threshold window around the target.

2)      The monkey does not touch the screen during the whole-time window for touch (5000ms).

3)      The monkey starts to touch the target but does not keep it pressed for the whole holding time (500ms).

After the creation of the scene, when run_scene( ) is called we would like to define these three conditions in order to mark these behavioural events with eventmarker( ) function and after that cleaning the scene and stopping the trial (and starting a new one after an intertrial time).

In the same way, we would like to do that when two targets are displayed (please see the first attached file).

Quote:
Originally Posted by Jaewon
First of all, the old scripting method and the scene framework are rather complementary. If you can build your task with toggleobject() and eyejoytrack(), there is no need to switch to the scene framework.

Second, to avoid unnecessary delays between scenes, all scenes must be created before any run_scene() is called. Please see this manual page.
ftp://helix.nih.gov/lsn/monkeylogic/ML2_doc/runtimefunctions.html#HowToCreateAdapterChains

Third, I don't think there is an easy way to do what you want with the current adapters, but you can modify SingleTarget and MultiTarget and make your own adapters. Inverting the threshold windows for multiple targets is not possible in the trialholder v1, either, I believe.

We’re actually moving to the new version of trialholder (v2) because in this new task the monkey has to observe and make a decision about the direction of motion in a dynamic random-dot display (It’s similar to Micheal Shadlen’s task http://science.sciencemag.org/content/324/5928/759?casa_token=pkPCOSJuoHUAAAAA:0w6vs_wLqwgwAVozZSwib4Ylx4TZI7RhKbiFolUkiGKjUHvz1eTdkE4s1-jwQZ3dcFWr7YmTeM246Q). And so, for this reason, I used your RandomDotMotion adaptor. I have already finished writing the task, but I must add this abort conditions. I'm reading your manual and the example tasks that you have written, they have been very useful.

Let me know if you have any further questions.

Attached Images
jpeg 20181130_114341.jpg (3.53 MB, 4 views)
jpeg 20181130_111838.jpg (3.16 MB, 4 views)

0
Edward

Administrator
Registered:
Posts: 251
Reply with quote  #6 
Hello frankdopamine,

For condition #2 and #3, use a WaitThenHold on top of a SingleTarget adapter. Set the WaitTime property of the WaitThenHold adapter to 500ms to satisfy #2, and set the HoldTime property to 500ms to satisfy #3. You can then use the Success and Waiting property of the WaitThenHold adapter to determine whether a touch have been made and if so, whether it has been maintained for 500ms.
 
Now for #1 I need some clarification. If the monkey touch outside of the stimuli area, does the trial abort immediately? If not, does the trial abort after a fixed amount of time (say 500ms) if the monkey maintains the touch? What if the monkey no longer touches outside the stimuli area within that 500ms?
0
frankdopamine

Junior Member
Registered:
Posts: 5
Reply with quote  #7 
Quote:
Originally Posted by Edward
Hello frankdopamine,

For condition #2 and #3, use a WaitThenHold on top of a SingleTarget adapter. Set the WaitTime property of the WaitThenHold adapter to 500ms to satisfy #2, and set the HoldTime property to 500ms to satisfy #3. You can then use the Success and Waiting property of the WaitThenHold adapter to determine whether a touch have been made and if so, whether it has been maintained for 500ms.
 
Now for #1 I need some clarification. If the monkey touch outside of the stimuli area, does the trial abort immediately? If not, does the trial abort after a fixed amount of time (say 500ms) if the monkey maintains the touch? What if the monkey no longer touches outside the stimuli area within that 500ms?


For the condition #1, if the monkey touches outside of the stimuli area for one single frame (with our touchscreen 16,6ms), yes the trial will abort immediately. We do not want the monkey to keep the area out of the target pressed for a fixed amount of time (holding target 500 ms), as I told you if the monkey just touches it for few milliseconds, the trial will abort immediately.

Let me know if you have any further questions.

0
Edward

Administrator
Registered:
Posts: 251
Reply with quote  #8 
You can create a custom adapter. Let's say it's called MySingleTarget.m. You can copy over everything in \ext\SingleTarget.m, but you will need to modify lines 82-87:

if isscalar(obj.ThresholdInPixels)
obj.In = sum((data-repmat(obj.ScreenPosition,ndata,1)).^2,2) < obj.ThresholdInPixels;
else
rc = obj.ThresholdInPixels;
obj.In = rc(1)<data(:,1) & data(:,1)<rc(3) & rc(2)<data(:,2) & data(:,2)<rc(4);
end

In original SingleTarget.m obj.In is set to true if the input signal (eye, touch etc) falls within the stimuli. You can modify this part of code to set obj.In to true whenever the monkey touches outside of the stimuli area and save the modified code in MySingleTarget.m. Then you can use an OrAdaptor to combine MySingleTarget adapter and the WaitThenHold adapter mentioned above for satisfying #2 and #3. This combined adapter should achieve your #1, #2 and #3 simultaneously. You can then use the Success property of these adapters to determine whether the monkey successfully touch and hold the stimuli or touched outside the stimuli area, and send the relevant event code.



0
Edward

Administrator
Registered:
Posts: 251
Reply with quote  #9 
Additionally, if you want MySingleTarget adapter to trigger whenever the monkey touches outside the stimuli, you can simply pass the stimuli to MySingleTarget and invert the final obj.In by adding a single line of code:

if isscalar(obj.ThresholdInPixels)
obj.In = sum((data-repmat(obj.ScreenPosition,ndata,1)).^2,2) < obj.ThresholdInPixels;
else
rc = obj.ThresholdInPixels;
obj.In = rc(1)<data(:,1) & data(:,1)<rc(3) & rc(2)<data(:,2) & data(:,2)<rc(4);
end
obj.In=~obj.In;

You can do the same for multiple targets.
0
Jaewon

Administrator
Registered:
Posts: 727
Reply with quote  #10 
Eddie,

Unfortunately your last comment doesn't work for touch. When there is no touch, 'data' is NaN and 'obj.In' becomes false. Since 'obj.In' will be false as well when the outside of the window is touched, 'no touch' and 'touch outside the threshold window' are not distinguishable by negating 'obj.In'.

It gets more complicated in the case of multiple targets. When there are two targets, Target 1 & Target 2, Target 1 is outside of Target 2's threshold window and vice versa. So any touch to one target can be detected as a touch outside of the other target, if it is not checked carefully.

For condition #1, making custom adapters is the easiest solution, I guess, but let me think if we can use the existing adapters without sacrificing the performance.

0
Jaewon

Administrator
Registered:
Posts: 727
Reply with quote  #11 
Hi frankdopamine,

The attached is a custom adapter I made for your experiment as an example. I don't know how your task shifts from SCENE 1 to SCENE 6, but there should be some break between the two scenes so that the touch made during SCENE 1 can be removed. Otherwise, the trial will be aborted as soon as SCENE 6 starts.


----- Beginning of the test script -----
% scene 1
fix1 = SingleTarget(touch_);
fix1.Target = [0 0];
fix1.Threshold = 3;
wth1 = WaitThenHold(fix1);
wth1.WaitTime = 5000;
wth1.HoldTime = 500;
stop1 = GetStopStatus(wth1);  % for condition #2 and #3

out1 = ComplementWindowTester(touch_);  % for condition #1
out1.setTarget(fix1);

or1 = OrAdapter(stop1);
or1.add(out1);

scene1 = create_scene(or1);

% scene 2
mul2 = MultiTarget(touch_);
mul2.Target = [-5 0; 5 0];
mul2.Threshold = 3;
mul2.WaitTime = 5000;
mul2.HoldTime = 500;
stop2 = GetStopStatus(mul2);  % for condition #2 and #3

out2 = ComplementWindowTester(touch_);  % for condition #1
out2.setTarget(mul2);

or2 = OrAdapter(stop2);
or2.add(out2);

scene2 = create_scene(or2);

% task
error_type=0;

run_scene(scene1);

if out1.Success
    error_type = 7;  % touch outside of the window
else
    if ~wth1.Success
        if wth1.Waiting
            error_type = 3;  % no touch
        else
            error_type = 4;  % touch not held
        end
    end
end

if 0==error_type
    idle(2000);  % not to make the trial aborted by touch extended from scene 1
    run_scene(scene2);

    if out2.Success
        error_type = 7;  % touch outside of the window
    else
        if ~mul2.Success
            if mul2.Waiting
                error_type = 3;  % no touch
            else
                error_type = 4;  % touch not held
            end
        else
            mul2.ChosenTarget
        end
    end
end

trialerror(error_type);
----- End of the test script -----

 
Attached Files
m ComplementWindowTester.m (2.12 KB, 4 views)

0
Edward

Administrator
Registered:
Posts: 251
Reply with quote  #12 
Hey Jaewon,

Thank you for the clarification. I had thought SingleTarget for _eye and _touch behaves in the same way so a simple inversion suffices.

Sorry about the misinformation. It's good to learn how the adapter work in more depth. Thanks!
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.