Hello PTB Community,
I'm currently working on getting a simple dot stimulus to work properly on my work setup.
The problem I have is, that the predefined stimulus time for fixation (simple dot in the center) is 2s, but the actual time in the running experiment is 6s. Every single frame takes roughly 3 times as long. The setup also doesn't pass the sync test. I'm a complete beginner at this, trying to get the stimulus to work on that new setup. The same code works flawlessly on a different setup (that also uses a ViewPixx monitor).
Down below I'll first post the part of my code up to the point where the additional 'time' is created and after that I'll post the error message from MatLab. I hope someone here can help me out with this. I know that my implementation of using a ViewPixx monitor is very poor at best, but that problem only persists with that one setup and works fine with a different one.
Thanks in advance,
Christian.
PS: Up to the point I posted the code it should just display a white dot in the center of the screen for 2s. You can ignore the eyelink integration, as it's disabled in the trial runs. The part that causes they increased delay is the Screen('Flip'...) in the for-loop for the frames. As for the frame flip number in the error, the second part of the code I didn't post is basically another 2s frame loop with a dot at a different position. In the end I close all open files, connection to eyelink as well as the DataPixx connection.
Basic Info:
Windows XP
MatLab v 7.11.0.584 (R2010b)
32-bit
August 16, 2010
PTB 3.0.10
Multimonitor setup. A simple 60Hz LCD display and Viewpixx 3D 120 Hz display. (the code works on the same PC using the 60Hz display, but not the Viewpixx Display)
Code:
%----------------------------------------------------------------------
% Initialisation
%----------------------------------------------------------------------
% Clear the workspace
close all;
clear all;
sca;
%Auf "schlechten" LCD-Monitoren muss man diese Zeile einfügen, damit sich
%die Psychtoolbox nicht beschwert und das Experiment trotzdem läuft. Im
%Setup diese Zeile dann auskommentieren!
Screen('Preference', 'SkipSyncTests', 1);
%Experiment-Parameter festlegen
ExperimentName='blindspot_prosakkade';
subjectnumber = 0; % 0 = Christian
isbinocular = 0;
% Now we set the number of trials we want to do
numTrials = 1;
%Setup-Parameter --- muss angepasst werden, in cm
monitorwidth = 52.25;
monitorheight = 29.39;
monitordistance = 47;
%Sehwinkel 2° ober-/unterhalb des horizontalen Meridians, als Anteil
%der Monitorhöhe um später die Pixel zu bestimmen
FOVverticalDeg = 2;
%Abstand vom vertikalen Meridians (hier geplant:nach links), Bereich in dem Exp stattfinden soll, als Anteil
%der Monitorbreite
FOVminDeg = 7;
FOVmaxDeg = 22;
%Wird Eyelink verwendet (0 für Demo)
UseEyelink=0;
%Dateien zum abspeichern Initialisieren
datum=clock();
edfNametemp = sprintf('S%s%02d%02d%02d.edf',char(datum(2)+64),datum(3),datum(4),datum(5));
edfName = sprintf('%05d.%s.%04d%02d%02d_%02d%02d%02d.edf',subjectnumber,ExperimentName,datum(1),datum(2),datum(3),datum(4),datum(5),floor(datum(6)));
savePath=['.\', sprintf('%04d\\%02d\\',datum(1),datum(2))];
if exist(savePath,'dir')~=7 %%% Existenz des Verzeichnisse prüfen, sonst erstellen
mkdir('.',savePath);
end
% Seed the random number generator. Here we use the older way to be
% compatible with older systems. Newer syntax would be rng('shuffle'). Look
% at the help function of rand "help rand" for more information
rand('seed', sum(100 * clock));
% Set the screen number to the external secondary monitor if there is one
% connected
screens=Screen('Screens');
%screenNumber=max(screens); %Bei manchen Multi-Monitor-Setups stürzt MATLAB ab, wenn man keine explizite Screen-Nummer angibt!
screenNumber=2;
% %DataPixx Monitor in der PsychBox 1 initialisieren
Datapixx('Open');
Datapixx('StopAllSchedules');
Datapixx('RegWrRd'); % Synchronize Datapixx registers to local register cache
% Define black, white and grey
white = WhiteIndex(screenNumber);
grey = white / 2;
black = BlackIndex(screenNumber);
background = black;
foreground = white;
% Open the screen to initilize Psychtoolbox
[window, windowRect] = Screen('OpenWindow', screenNumber, background, [], 32, 2, [], [], kPsychNeed32BPCFloat);
% Flip to clear
Screen('Flip', window);
% Query the frame duration
ifi = Screen('GetFlipInterval', window);
% Set the text size
Screen('TextSize', window, 40);
% Query the maximum priority level
topPriorityLevel = MaxPriority(window);
% Get the centre coordinate of the window
[xCenter, yCenter] = RectCenter(windowRect);
% Get the size of the on screen window in pixels.
% For help see: Screen WindowSize?
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
%%% Prepair Eyelink
if UseEyelink==1
el = ELPH_EyelinkInitDefaults(window,background,foreground); %% Load Default-Values
ELPH_initEL2(edfNametemp);
fprintf('EDF wird geöffnet\n');
Eyelink('Command','screen_pixel_coords = %d %d %d %d',0,0,screenXpixels-1,screenYpixels-1);
Eyelink('Message','DISPLAY_COORDS %d %d %d %d',0,0,screenXpixels,screenYpixels);
Eyelink('Message','%s',sprintf('DISPLAY_SIZE %6.1f %6.1f %6.1f',monitorwidth,monitorheight,monitordistance));
end
%--------------------
% Dot information
%--------------------
% Enable alpha blending for anti-aliasing
% For help see: Screen BlendFunction?
% Also see: Chapter 6 of the OpenGL programming guide
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
% Set the color of our dots to full white, red and blue. Color is defined by red green
% and blue components (RGB).
FixdotColor = [255 0 0];
StartdotColor = [0 0 255];
StimdotColor = [255 255 255];
%Fixationspunkt im Zentrum des Bildschirms
fixXpos=xCenter;
fixYpos=yCenter;
% Dot size in pixels
dotSizePix = 12;
fixSizePix = 12;
%----------------------------------------------------------------------
% Online Eye Tracking
%----------------------------------------------------------------------
%Größe der tracking fenster
fix_windowX = 4;
fix_windowY = 4;
sac_windowX = 4;
sac_windowY = 4;
%Delay für die Überprüfung. Testperson braucht eine Vorlauffzeit zum Fixieren
%sonst bricht der Trial sofort ab. Delay in Sekunden -> Frames
fix_delay = round(1.0 / ifi); %1s bedeutet die letzten 500 ms Fixation müssen stimmen
%Pixel per Degree - vertical
pixperdegY = monitordistance * tand(1) / monitorheight * screenYpixels;
%Pixel per Degree - horizontal
pixperdegX = monitordistance * tand(1) / monitorwidth * screenXpixels;
%Bestimme Fix-Window für Online-Überprüfung der Augenposition
fixwindow = [round(fixXpos - fix_windowX/2 * pixperdegX) round(fixXpos + fix_windowX/2 * pixperdegX) round(fixYpos - fix_windowY/2 * pixperdegY) round(fixYpos + fix_windowY/2 * pixperdegY)];
%----------------------------------------------------------------------
% Timing Information
%----------------------------------------------------------------------
% Presentation Time for the Fixation-Dot in seconds and frames in which
% there is only fixation
presTimeSecs = 1.5;
presTimeFrames = round(presTimeSecs / ifi);
% Interstimulus interval time in seconds and frames (Bereich in dem Stimulus erscheinen kann)
isiTimeSecs = 0.5;
isiTimeFrames = round(isiTimeSecs / ifi);
% Response Time for the Saccade in seconds and frames
respTimeSecs = 2;
respTimeFrames = round(respTimeSecs / ifi);
% Numer of frames to wait before re-drawing
waitframes = 1;
%----------------------------------------------------------------------
% Keyboard information
%----------------------------------------------------------------------
% Define the keyboard keys that are listened for. We will be using the left
% and right arrow keys as response keys for the task and the escape key as
% a exit/reset key
KbName('UnifyKeyNames');
escapeKey = KbName('ESCAPE');
space = KbName('space');
%----------------------------------------------------------------------
% Experimental loop
%----------------------------------------------------------------------
%%% EL Kalibration;
if UseEyelink==1
Eyelink('Message','start experiment');
Eyelink('Message','Calibration');
fprintf('Kalibration wird gestartet');
ELPH_dotrackersetup(el);
end
% Animation loop: we loop for the total number of trials
for trial = 1:numTrials
HideCursor; %Mauszeigen ausblenden
%Kommunikation mit dem Eyelink-Rechner
if UseEyelink==1
trialText=sprintf('TRIALID %d-%d',trial,numTrials);
Eyelink('Message','%s',trialText); %%% Geht nicht direkt, keine Ahnung warum???
Eyelink('Command','record_status_message "%s Trial %d von %d"',edfName,trial,numTrials);
Eyelink('StartRecording');
WaitSecs(0.05); %%% kurzes Warten auf Eyelink
Eyelink('Message','start recording');
end
data.Trialstart(1,trial)=GetSecs(); %Trialstart für später speichern
% Flashposition (horizontale) randomisieren
dotXpos = xCenter - (pixperdegX * FOVminDeg) - round(rand * (FOVmaxDeg - FOVminDeg) * pixperdegX);
% Flashposition (vertikale) randomisieren, entweder 2° oben oder unten
topbottom = rand;
if topbottom < 0.5
topbottom = 1; %Stimulus oben
else
topbottom = -1; %Stimulus unten
end
dotYpos = yCenter - topbottom * pixperdegY * FOVverticalDeg;
% Now we calculate a random time interval after which the saccade dot
% should appear
saccadeTimeFrames = round(isiTimeFrames); %DEBUG, Fixtime = 2s
% Change the blend function to draw an antialiased fixation point
% in the centre of the screen
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
% If this is the first trial we present a start screen and wait for a
% key-press
if trial == 1
DrawFormattedText(window, 'Press Any Key To Begin', 'center', 'center', white);
Screen('Flip', window);
KbStrokeWait;
end
% Flip again to sync us to the vertical retrace at the same time as
% drawing our fixation point
% Der Fixationspunkt soll ein größerer Punkt mit einem kleinen Punkt im
% Zentrum in Hintergrundfarbe sein, um die Fixation akkurater zu machen
% (siehe Eyelink-Kalibration)
Screen('DrawDots', window, [fixXpos fixYpos], fixSizePix, FixdotColor, [], 2);
Screen('DrawDots', window, [fixXpos fixYpos], 1, background, [], 2);
vbl = Screen('Flip', window);
%Initialisierung von skip_trial für die online-Fixkontrolle
skip_trial = 0;
% Now we present the pres interval with fixation point minus one frame
% because we presented the fixation point once already when getting a
% time stamp, initial fixation
time_start_fixation(trial) = vbl; %DEBUG
for frame = 1:(presTimeFrames + saccadeTimeFrames) - 1
% Draw the fixation point
Screen('DrawDots', window, [fixXpos fixYpos], fixSizePix, FixdotColor, [], 2);
Screen('DrawDots', window, [fixXpos fixYpos], 1, background, [], 2);
time_frame_inter_fixation_start = GetSecs(); %DEBUG
% Flip to the screen
vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi);
time_frame_inter_fixation_total(trial,frame)= GetSecs() - time_frame_inter_fixation_start; %DEBUG
% time_frame_inter_fixation_surplus(trial,frame) = time_frame_inter_fixation_total(trial,frame) - ifi; %DEBUG
%% DEBUG zur Zeitmessung
if frame==(presTimeFrames + saccadeTimeFrames) - 1
time_end_fixation(trial) = vbl;
time_fixation_total(trial) = time_end_fixation(trial)- time_start_fixation(trial);
time_factor(trial)= time_fixation_total(trial)/((presTimeFrames + saccadeTimeFrames)*ifi);
time_fixation_given(trial)=((presTimeFrames + saccadeTimeFrames)*ifi);
time_frame_inter_fixation_total_multiplicator = time_frame_inter_fixation_total / ifi;
end
%% Debug Ende zur Zeitmessung
end
Error:
PTB-INFO: Multi-display setup in explicit multi-display mode detected. Using the following mapping:
PTB-INFO: Screen 0 corresponds to the full Windows desktop area. Useful for stereo presentations in stereomode=4 ...
PTB-INFO: Screen 1 corresponds to the display area of the monitor with the Windows-internal name \\.\DISPLAY1 ...
PTB-INFO: Screen 2 corresponds to the display area of the monitor with the Windows-internal name \\.\DISPLAY2 ...
PTB-WARNING: Screens 1 and 2 do have non-equal width and height. This will probably cause wrong behaviour
PTB-WARNING: when trying to open a fullscreen window on Screen 0 that is supposed to fully cover displays 1 and 2.
PTB-WARNING: In that case, either change your screen settings to matching size and refresh rate in the display control
PTB-WARNING: panel and retry after a 'clear all', or manually specify a [rect] parameter for the window in the
PTB-WARNING: Screen('OpenWindow', 0, [color], [rect]); command to manually enforce creation of a proper onscreen window.
PTB-INFO: This is Psychtoolbox-3 for Microsoft Windows, under Matlab (Version 3.0.10 - Build date: Sep 28 2012).
PTB-INFO: Type 'PsychtoolboxVersion' for more detailed version information.
PTB-INFO: Most parts of the Psychtoolbox distribution are licensed to you under terms of the MIT License, with
PTB-INFO: some restrictions. See file 'License.txt' in the Psychtoolbox root folder for the exact licensing conditions.
PTB-WARNING: Couldn't even collect one single valid flip interval sample! Sanity range checks failed!
PTB-WARNING: Could be a system bug, or a temporary timing problem. Retrying the procedure might help if
PTB-WARNING: the latter is the culprit.
WARNING: VBL Calibration run No. 1 failed. Retrying...
PTB-WARNING: Couldn't even collect one single valid flip interval sample! Sanity range checks failed!
PTB-WARNING: Could be a system bug, or a temporary timing problem. Retrying the procedure might help if
PTB-WARNING: the latter is the culprit.
WARNING: VBL Calibration run No. 2 failed. Retrying...
WARNING: Will enable VBL busywait-workaround before trying final VBL Calibration run No. 3.
WARNING: This will hopefully work-around graphics driver bugs of the GPU sync-to-retrace mechanism. Cross your fingers!
PTB-WARNING: Couldn't even collect one single valid flip interval sample! Sanity range checks failed!
PTB-WARNING: Could be a system bug, or a temporary timing problem. Retrying the procedure might help if
PTB-WARNING: the latter is the culprit.
PTB-INFO: OpenGL-Renderer is NVIDIA Corporation :: GeForce 7600 GS/PCIe/SSE2 :: 2.1.2
PTB-INFO: VBL startline = 1080 , VBL Endline = 1242
PTB-INFO: Measured monitor refresh interval from beamposition = 7.986439 ms [125.212254 Hz].
PTB-INFO: Will use beamposition query for accurate Flip time stamping.
PTB-INFO: Measured monitor refresh interval from VBLsync = 0.000000 ms [1.#INF00 Hz]. (0 valid samples taken, stddev=10000000.000000 ms.)
PTB-INFO: Reported monitor refresh interval from operating system = 8.333333 ms [120.000000 Hz].
PTB-INFO: Small deviations between reported values are normal and no reason to worry.
WARNING: Couldn't compute a reliable estimate of monitor refresh interval! Trouble with VBL syncing?!?
WARNING: Mismatch between measured monitor refresh interval and interval reported by operating system.
This indicates massive problems with VBL sync.
WARNING: Measured monitor refresh interval indicates a display refresh of less than 20 Hz or more than 250 Hz?!?
This indicates massive problems with VBL sync.
PTB-WARNING: Unable to measure monitor refresh interval! Using a fake value of 8.333333 milliseconds.
----- ! PTB - ERROR: SYNCHRONIZATION FAILURE ! ----
One or more internal checks (see Warnings above) indicate that synchronization
of Psychtoolbox to the vertical retrace (VBL) is not working on your setup.
This will seriously impair proper stimulus presentation and stimulus presentation timing!
Please read 'help SyncTrouble' for information about how to solve or work-around the problem.
You can force Psychtoolbox to continue, despite the severe problems, by adding the command
Screen('Preference', 'SkipSyncTests', 1); at the top of your script, if you really know what you are doing.
PTB-INFO: Psychtoolbox imaging pipeline starting up for window with requested imagingmode 1056 ...
PTB-INFO: Will use 32 bits per color component floating point framebuffer for stimulus drawing. Alpha blending may not work on your system with this setup, but only for lower precision modes.
PTB-INFO: Will use 32 bits per color component floating point framebuffer for stimulus post-processing (if any).
PTB-WARNING: Screen('Blendfunction') called to enable alpha-blending on a window (handle=10) which doesn't support
PTB-WARNING: alpha-blending at its current color resolution of 32 bits per color component on your hardware.
PTB-WARNING: Won't enable blending. Either lower the color resolution of the window (see help PsychImaging) or
PTB-WARNING: upgrade your graphics hardware.
PTB-WARNING: Screen('Blendfunction') called to enable alpha-blending on a window (handle=10) which doesn't support
PTB-WARNING: alpha-blending at its current color resolution of 32 bits per color component on your hardware.
PTB-WARNING: Won't enable blending. Either lower the color resolution of the window (see help PsychImaging) or
PTB-WARNING: upgrade your graphics hardware.
INFO: PTB's Screen('Flip', 10) command seems to have missed the requested stimulus presentation deadline
INFO: a total of 483 times out of a total of 483 flips during this session.
INFO: This number is fairly accurate (and indicative of real timing problems in your own code or your system)
INFO: if you provided requested stimulus onset times with the 'when' argument of Screen('Flip', window [, when]);
INFO: If you called Screen('Flip', window); without the 'when' argument, this count is more of a ''mild'' indicator
INFO: of timing behaviour than a hard reliable measurement. Large numbers may indicate problems and should at least
INFO: deserve your closer attention. Cfe. 'help SyncTrouble', the FAQ section at www.psychtoolbox.org and the
INFO: examples in the PDF presentation in PsychDocumentation/Psychtoolbox3-Slides.pdf for more info and timing tips.
WARNING: This session of your experiment was run by you with the setting Screen('Preference', 'SkipSyncTests', 1).
WARNING: This means that some internal self-tests and calibrations were skipped. Your stimulus presentation timing
WARNING: may have been wrong. This is fine for development and debugging of your experiment, but for running the real
WARNING: study, please make sure to set Screen('Preference', 'SkipSyncTests', 0) for maximum accuracy and reliability.