I am trying to record participant responses to visual stimuli which need to be shown for a fixed duration (500ms). However, I would also like to record their responses after this fixed duration within a 1 sec time window from stimulus onset. The following code allows me to record responses only when a key is pressed during the presentation of the stimulus (500ms).
StimulusSecs = 0.50001;
StimDuration = round(StimulusSecs / ifi);
ISISecs = 0.50001;
ISI = round(ISISecs / ifi);
ITISecs = [1.00001, 2.00001, 3.00001];
intertrial = round(ITISecs / ifi);
waitframes = 1;
vbl = Screen('Flip', mainwin);
t2wait = 1;
[~, Onset]=Screen('Flip', mainwin); keyIsDown=0; rt=0;
tic % Stimulus Onset
for frame = 1:StimDuration
Screen('DrawTexture', mainwin, pics(picCounter));
vbl = Screen('Flip',mainwin, vbl + (waitframes - 0.5) * ifi);
[keyIsDown, secs, keyCode] = KbCheck;
FlushEvents('keyDown');
if keyIsDown
if keyCode(spaceKey)
rt = 1000.*(secs-Onset);
keypressed=find(keyCode);
% break; is missing as this would
% escape the loop
elseif (secs-Onset) > t2wait
break;
elseif keyCode(escKey)
ShowCursor; fclose(outfile); Screen('CloseAll');
return;
end
keyIsDown=0; keyCode=0; keypressed=0;
end
end
S2dur = toc;
I am new to psychoolbox and any help would be greatly appreciated!!!