0

I am running a reaction time experiment with Psychtoolbox in MATLAB (R2014b). I'm using SyncTests, and that gives me an estimate of how many flip commands missed the requested response deadline when I run the experiment. What number of missed flips is too high (i.e., cause for concern)? I usually get around 140 per 1900 flips, so a little over 7%. Is that okay?

Here's the message I receive (the actual numbers vary slightly after each run of the experiment, naturally): "INFO: PTB's Screen('Flip', 10) command seems to have missed the requested stimulus presentation deadline a total of 130 times out of a total of 1900 flips during this session."

Here's the code I use to flip (and then to measure RT which is the most crucial part of my code):

WaitSecs(.2); [this is the intertrial interval, more or less]
Screen('DrawTexture', mainwin, Target);
Screen('Flip', mainwin);
timeStart = GetSecs;keyIsDown=0; correct=0; rt=0;
while 1 & (GetSecs - timeStart) < 3 
      [keyIsDown, secs, keyCode] = KbCheck;
      FlushEvents('keyDown');
          if keyIsDown
                nKeys = sum(keyCode);
                if nKeys==1
                        if keyCode(Left)||keyCode(Right)||keyCode(Down)||keyCode(Up)
                            rt = 1000.*(GetSecs-timeStart);
                            keypressed=find(keyCode);
                            Screen('Flip', mainwin);
                            [etc., I just close all loops/if statements and move on
                            to the next trial]

A bit of context: I'm running my paradigm on Windows 10, and there is also a "DPI-awareness" issue I can't get around (I get a warning that MATLAB is not DPI-aware on my computer). I'm unsure what problems this might create - but the paradigm seems to be doing what I want it to be doing plus it looks great (i.e., the images are displayed nicely), so I never worried about that that much. Should I have? Can that mess with the accuracy of reaction time measurement?

MGy
  • 25
  • 1
  • 7
  • It was a little unclear, you're missing 7% of flips using a Psychtoolbox test script / function, or within your experiment? – DMR Nov 20 '17 at 23:37
  • Sorry about the confusion: after I run my experiment, it reports that around 7% of flips (around 140 out of 1900) was missed. So the latter, I think. – MGy Nov 21 '17 at 00:02
  • Are you specifying the 'when' parameter to Screen 'Flip'? – DMR Nov 21 '17 at 00:13
  • Not explicitly, no. I just flip the screen, and then start a while loop for RT recording (using KbCheck). (I can paste a bit of this code into my original question, if necessary!) – MGy Nov 21 '17 at 00:44
  • I clarified my original post with examples. I guess my most important questions are: 1) are these numbers cause for concern? and 2) if everything looks okay, so visual stimulus presentation looks intact, do I have to worry about these issues (the missed flips + lack of DPI awareness) causing problems for my RT measurement? – MGy Nov 21 '17 at 10:27

1 Answers1

0

The below suggestion is a little incomplete because I don't have the rest of the experiment, but I think you'll get the idea. You should be able to get greater precision by scheduling the screen Flip in advance. In this example the time between the previous and current stimulus is computed as frames, and the current stimulus is then scheduled for 1/2 of one frame less then you'd like it to be presented. Psychtoolbox will then present it at the next possible frame, which is when you'd like it to be presented (since you can't present a visual stimulus between frames).

mainwin = Screen('OpenWindow');

% fetch the interflip interval of the screen
ifi = Screen('GetFlipInterval', mainwin);

% inter-trial interval
ITI = .2;

% start of block, flip a screen at an arbitrary time to get a reference
% point for the first trial
Screen('FillRect', mainwin, 0);
[~, lastVisualOnset] = Screen('Flip', mainwin);

% ID the number of frames until the next stimulus should be presented
% trial-by-trial timing jitter could also be added here if desired
nextStimFrameDelta = round( ISI / ifi);

Screen('DrawTexture', mainwin, Target);

% schedule the Flip in advance by .5 frames less than needed,
% so that the next available frame will be the one wanted
% this visual onset time stamp will then be the reference point for the
% next trial
[~, lastVisualOnset] = Screen('Flip', mainwin,  lastVisualOnset + ((nextStimFrameDelta - 0.5) * ifi));

keyIsDown=0; correct=0; rt=0;
while (GetSecs - lastVisualOnset) < 3
    [keyIsDown, secs, keyCode] = KbCheck;
    FlushEvents('keyDown');
    if keyIsDown
        nKeys = sum(keyCode);
        if nKeys==1
            if keyCode(Left)||keyCode(Right)||keyCode(Down)||keyCode(Up)
                rt = 1000.*(GetSecs-lastVisualOnset);
                keypressed=find(keyCode);
                Screen('Flip', mainwin);
            end
        end
    end
end
DMR
  • 1,479
  • 1
  • 8
  • 11
  • Thank you for this, this is a great suggestion, and I tried to implement it for the Target flip in the script. Number of missed flips didn't decrease significantly, but I could be doing something wrong. More importantly, is it fair to say that your solution makes the onset timing of the stim more precise (so ITI will be closer to intended value), but does not impact RT? I.e., both GetSecs - timeStart (my way) and GetSecs - lastOnset will yield similar values, as they both measure the time between a time stamp following the completion of stim presentation and a keypress. They seemed to, for me. – MGy Nov 23 '17 at 15:53