bhv_code(15,'CenterOn',25,'CenterOff',30,'CenterCapture',40,'CenterHold',50,'TargetOn',60,'TargetOff',70,'CenterLeave',80,'TargetCapture',90,'RewardOn',100,'RewardOff'); % behavioral codes
% **** User parameters (times in ms, fixation_window size in degrees) ****
acquisition_time1=1000; % max time for the monkey to catch the center (ms)
hold_time1_min =100; % min time for which the center has to be touched (ms)
hold_time1_max =100; % min time for which the center has to be touched (ms)
release_time1 =1000; % max duration before the monkey has to let go of the center
hold_radius1 = 3; % determines the precision with which the center has to be hit
% Object 2 (peripheral target):
acquisition_time2= 1000; % max time for the monkey to catch the center (ms)
hold_radius2 = 3; % size of the side target
reward_dur = 200; % duration of solenoid activation
intertrial_interval_min = 1500; % minimal intertrial interval duration
intertrial_interval_max = 1800; % maximal intertrial interval duration
%calculate randomized parameters
intertrial_interval = intertrial_interval_min + rand*(intertrial_interval_max - intertrial_interval_min);
hold_time1 = hold_time1_min + rand*(hold_time1_max - hold_time1_min);
toggleobject([1 2 3],'status','off');
[~,button] = mouse_position();
while button(1) % if there is a mouse (=touch screen) input, task is stuck
[~,button] = mouse_position();
toggleobject([1],'status','on','eventmarker',15); % turn center object on
on_center = eyejoytrack('touchtarget',1,hold_radius1,acquisition_time1);
if~on_center % if center not hit within the appropriate time, the trial is being terminated
toggleobject([1 2 3],'status','off','eventmarker',25); % switch center off
trialerror(1); % report error type 1: did not touch center
eventmarker(30); % set eventmarker: CenterCapture
center_hold = eyejoytrack('releasetarget',1,hold_radius1,hold_time1);
if~center_hold % if the monkey relased the center too early ...
toggleobject([1 2 3],'status','off','eventmarker',25);
trialerror(2); % report error type 2: broke center target hold
eventmarker(40); % set eventmarker: CenterHold
toggleobject([1],'status','off','eventmarker',25); % turn center target off,
toggleobject([2],'status','on','eventmarker',50); % turn peripheral target on (= GO signal)
[center_release,rt] = eyejoytrack('releasetarget',1,hold_radius1,release_time1);
if center_release % if monkey has not reacted within the release_time1 window ...
toggleobject([1 2 3],'status','off','eventmarker',60);
trialerror(3); % report error type 3: did not react to target
eventmarker(70); % set eventmarker: CenterLeave
on_target = eyejoytrack('touchtarget',2,hold_radius2,acquisition_time2);
if ~on_target % if monkey has not acquired the peripheral target within the time allowed ...
toggleobject([1 2 3],'status','off','eventmarker',60);
trialerror(4); % report error type 4: did not capture target
eventmarker(80); % set eventmarker: TargetCapture
trialerror(0); % report error type 0: GoodTrial
toggleobject(3,'status','on'); % turn on sound
eventmarker(90); % set eventmarker: RewardOn
goodmonkey(200, 'juiceline',1, 'numreward',1, 'pausetime',500, 'eventmarker',80); % reward
toggleobject([1 2 3],'status','off','eventmarker',100); % turn the lights off
idle(intertrial_interval); % wait ...