Hi PTB Community,
In my experiment I have breaks that occur after a certain amount of trials designed to "pause" the experiment (turn on and off EEG recording). However, I don't have something that subtracts the time occupied by the break from the experiment run time. Since my code outputs out time vectors into a log file, after every break there is a large difference between times made up of the duration of the break. I want to figure out a way to pause the time until a keypress is registered. So far, I have a function I call "mykb" that checks for this key press and is called in the break code, and looks like this:
function mykb
letter1=KbName('z');
while 1
[keyIsDown,secs,keyCode]=KbCheck;
if keyIsDown && keyCode(letter1)
break
end
end
The thing is, in my break code I also want it to stall the time until a key press is detected. The break code looks like this:
%% CHECK FOR BREAKS %%
if ((mod(trialCounter,15) == 1) && (trialCounter ~= 1)) %dividing trialCounter by 15, and checking if the remainder of 1 (this checks for every trial one after every 15 trials pass)
if strcmp(expType,'EEG')==1
breakStartEvent = GetSecs;
NetStation('Event',codes.breakStart,breakStartEvent,stimulus.codeDur,codes.breakStart,codes.codeVals.breakStart);
NetStation('StopRecording');
end
text = 'Wait for experimenter...';
Screen('FillRect',stimulus.window,backgroundColor);
drawCenteredText(stimulus.window,stimulus.rect,text,textColor,44,defaultFont);
Screen('Flip',stimulus.window);
fprintf('Waiting for z-key to resume...\n');
WaitSecs(.1); %needed for mykb to be called without moving on (there is a slight delay before mykb is called, therefore we need a slight wait)
mykb;
if strcmp(expType,'EEG')==1
NetStation('StartRecording');
breakEndEvent = GetSecs;
NetStation('Event',codes.breakEnd,breakEndEvent,stimulus.codeDur,codes.breakEnd,codes.codeVals.breakEnd);
end
block = block+1; %move to next block
end
Is there any way to stall the actual run time using by WaitSecs without having to set up break time anchors that subtract from time points I extract using GetSecs past the break? Does WaitSecs somehow have a drift free approach that can work with my function mykb?
Thanks PTB community for all the help so far! I would appreciate any insights or ideas offered :)