QUICK GUIDE TO TRANSITIONING TO GRAPHICS IN PSYCHOPHYSICS TOOLBOX 3

If you've previously used Psychophysics Toolbox 2 (PTB-2), there are few differences to presenting visual stimuli in Psychophysics Toolbox (PTB-3).

Screen Statement

The syntax for the Screen statement is different in PTB-2 versus PTB-3. In PTB-2, you'd say things like:

	Screen(YourWindowName, 'TextSize', 24);

Now, the syntax is:

	Screen('TextSize', YourWindowName, 24);

In other words, the order of the sub-command and the window are flipped. PTB-3 will generally understand the PTB-2 order if you use it by mistake ... but PTB-2 definitely does not understand the PTB-3 syntax.

Flipping

After you have finished drawing a set of pictures & text, in PTB-3 you need to use the Screen('Flip') statement to SHOW it to the participant in the experiment:

	Screen('Flip', YourWindowName);

The reason why this exists has to do with the low-level mechanics of how computer monitors work. But, the general rule is that whenever you have finished drawing the next screen of stimuli, you need to Flip. The advantage of Flip is that it allows you more precise timing of when exactly things appear. PTB-2 automatically flips after every stimulus you draw, which means that the presentations can be asynchronous if you are trying to display multiple things on the same screen.

Retaining Previous Screens

By DEFAULT, Screen('Flip') doesn't retain any of the previous screen once you start drawing the next screen. In other words, if you do:

The 2nd screen will JUST have picture 2 on it, not picture 1. If you want to retain all of the picture 1 stuff (so that the 2nd screen would have BOTH picture 1 and picture 2), replace the FIRST flip with:

	 Screen('Flip', YourWindowName, [], 1);

This keeps picture 1 in the offscreen buffer even after you do the flip.

Text Sizing

In PTB-2 you'd use Screen('TextWidth') to get the size of text before you put it on the screen. In PTB-3, it's Screen('TextBounds'), which returns the full X & Y rect for your text.

Text Positioning

In PTB-2, the Y position (vertical position) specified the BOTTOM of the text on the screen. If PTB-3, the Y-position now specifies the TOP of the text on the screen. For example, if writing the letter A, the Y coordinate now specifies where the peak of the A is, rather than the leg of the A.

Unless you have a really complex display, this may not matter; it will just shift your text around by a few pixels. If you want to change back to the old PTB-2 system, just add the line:

	 Screen('Preference', 'DefaultTextYPositionIsBaseline', 1);

to the beginning of your experiment.

Miscellany

PTB-3 also has a new feature called "Textures" that is supposed to allow for faster drawing than off-screen windows. Off-screen windows are still supported. Personally, I haven't tried textures much yet, and if you aren't too worried about precise timing of your stimuli I don't think they're necessary.

Supposedly, Psychophysics Toolbox 3 has a mode that will cause it to emulate PTB-2, and run PTB-2 code. My experience is that this mode does not really work. It might be more effort to get the emulation working than it would be to just update your code. But if you want to try it, add this line to the start of your experiment:

	Screen('Preference', 'EmulateOldPTB', 1);