Welcome! Log In Create A New Profile

Advanced

Problem with nonblocking in goodmonkey

Posted by Experimenter 
Problem with nonblocking in goodmonkey
March 02, 2022 09:46PM
Hi,

I have two scenes in my task. The first is a movie that moves across the screen. If the subject touched the movie then it would trigger a second scene where it plays another movie and also triggers the reward. I wanted to simultaneously play the second movie and trigger the reward. Therefore, I tried using goodmonkey nonblocking 1 or 2 to provide the reward in the background. When I added this optional input, it crashed monkeylogic and Matlab. Here is part of the code

%reward
if 0==error_type %fix.success
    idle(0,[]);
    goodmonkey(1000, 'numreward', 5, 'pausetime', 300, 'eventmarker', 40,'nonblocking', 1);    
    run_scene(scene_mov); %second movie scene
end
if 1== error_type %ct.sucess
    idle (3500,[]);
end
trialerror(error_type);


I was wondering if there is an adapter for goodmonkey or maybe I have to put it in a 'while' loop as in the brickbreaker example?

Thanks for your help!
Re: Problem with nonblocking in goodmonkey
March 03, 2022 12:46AM
I do not see any error in my testing. Is your NIMH ML up-to-date?
Re: Problem with nonblocking in goodmonkey
March 06, 2022 09:27PM
Hi Jaewon,
I just updated to the newest version but it is still crashing. It usually crashes after correct trial (trial error =0). Would it be because I am using the adapter chain incorrectly?

Here is my code:
if ~exist('touch_','var'), error('This demo requires touch input. Please enable it in the main menu or try the simulation mode.'); end

hotkey('x', 'escape_screen(); assignin(''caller'',''continue_'',false);');
hotkey('r', 'goodmonkey(1000, ''numreward'', 1);');   % manual reward

%event codes
bhv_code(10,'touched the screen',20,'reward',30,'go',40,'reward')
%bhv_variable('direction',direction);


%Editiable
touch_radius = 100000;
step = 100;
max_reaction_time= 2000;
target = [1];
stepunit='100';
editable('touch_radius','max_reaction_time','step','stepunit');

%choose directions
switch mod(TrialRecord.CurrentTrialNumber-1,8)
    case 0 %up to down
        Condition = 1; 
        x = linspace(0,0,1000)';
        y = linspace(9,-9,1000)';
        
    case 1 %down to up
        Condition =2;
        x = linspace(0,0,1000)';
        y = linspace(-9,9,1000)';
       
    case 2 %left to right
        Condition=3;
        x = linspace(18,-18,1000)';
        y = zeros(1000,1);
        
    case 3 % right to left 
        Condition =4; 
        x = linspace(-18,18,1000)';
        y = zeros(1000,1);
        
    case 4 % down left to up right
        Condition= 5; 
        x = linspace(-18,18,1000)';
        y = linspace(-9,9,1000)';
        
    case 5 % down right to left up
        Condition= 6;
        x = linspace(18,-18,1000)';
        y = linspace(-9,9,1000)';
        
    case 6 % up right to down left
        Condition = 7;
        x = linspace(18,-18,1000)';
        y = linspace(9,-9,1000)';
        
    case 7 % up left to down right 
        Condition = 8;
        x = linspace(-18,18,1000)';
        y = linspace(9,-9,1000)';
        
end 

%scene 1
ct = CurveTracer(touch_);
ct.Trajectory= [x y];
ct.Target= target;
fix=SingleTarget(ct);
fix.Threshold= touch_radius;
or = OrAdapter(ct);  % Finish either when all trajectory coordinates are used
or.add(fix);         % or fixation is acquired.
scene1 = create_scene(or,target);

%scene 2 with flashing LED
mov= MovieGraphic(null_);
mov.List= { 'Changing LED.mpg', [0 0],true,3};   % movie filename
tc= TimeCounter(mov);
tc.Duration= 5000;
scene_mov= create_scene(tc);

%run task
running= true;
rp = fix.Position;      % Assign rt for the position graph
error_type = 0;
run_scene(scene1,10);

trialerror(error_type);
if fix.Success
    error_type=0;
end
if ct.Success
    error_type=1;
end

%reward
if 0==error_type %fix.success
    idle(0,[]);
    goodmonkey(100, 'numreward', 5, 'pausetime', 300, 'eventmarker', 40,'nonblocking', 1);    
    run_scene(scene_mov);
end
if 1== error_type %ct.sucess
    idle (3500,[]);
end
trialerror(error_type);
Re: Problem with nonblocking in goodmonkey
March 06, 2022 09:38PM
Posting your timing file here is not helpful. You either do better debugging or send me all your files necessary to run the task.

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.