OnsetResp=0; rt_catch = 0; resp_text = 0; resp_catch = 'No_Response'; %Just in case we don't have response % Screen priority Priority(MaxPriority(window1)); Priority(2); % Show fixation cross drawCross(window1,W,H,barColor); tFixation = Screen('Flip', window1); Screen(window1, 'FillRect', backgroundColor); Screen('Flip', window1, tFixation + (fixationDuration + rand(1))- slack,0) %Adding between 0 and 1 second randomly to the minimum for the fixation duration % Show Object 1 Screen('DrawTexture', window1, objectodisplay, [], positiontodisplay,rottodisplay); startTime = Screen('Flip', window1); % Start of trial Onset_object_1 = startTime-ExpStart; %Onset press_trigger(trigger_object_1,triggers_on); while GetSecs - startTime < objectTimeout [keyIsDown,secs,keyCode] = KbCheck; % ESC key quits the experiment if keyCode(KbName('Q')) == 1 close all sca return; end respTime = GetSecs; pressedKeys = find(keyCode); % Check for response keys if ~isempty(pressedKeys) for i = 1:length(responseKeys) if KbName(responseKeys{i}) == pressedKeys(1) break end end end end % Empty screen between object offset and next fix cross % Screen priority Priority(MaxPriority(window1)); Priority(2); Screen(window1, 'FillRect', backgroundColor); Screen('Flip', window1 ) while GetSecs - startTime < postobjectTimeout1 % ESC key quits the experiment if keyCode(KbName('Q')) == 1 close all sca return; end [keyIsDown,secs,keyCode] = KbCheck; respTime = GetSecs; pressedKeys = find(keyCode); % Check for response keys if ~isempty(pressedKeys) for i = 1:length(responseKeys) if KbName(responseKeys{i}) == pressedKeys(1) resp_catch = responseKeys{i}; rt_catch = respTime - startTime; OnsetResp = GetSecs - ExpStart; break end end end end %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Subfunctions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Draw a fixation cross (overlapping horizontal and vertical bar) function drawCross(window,W,H,barColor) if nargin==3 barColor = [0 0 0]; end barLength = 16; % in pixels barWidth = 2; % in pixels %0.5; % number from 0 (black) to 1 (white) Screen('FillRect', window, barColor,[ (W-barLength)/2 (H-barWidth)/2 (W+barLength)/2 (H+barWidth)/2]); Screen('FillRect', window, barColor,[ (W-barWidth)/2 (H-barLength)/2 (W+barWidth)/2 (H+barLength)/2]); end