Psychophysics Toolbox

Our visual stimulus package NewStim relies on the Psychophysics Toolbox, a library of tools for MATLAB. It runs on various configurations from Mac OS X, Windows XP/7, Linux, etc.

You can download the Psychophysics Toolbox at their website: . Then you can follow the instructions on their page (which at this point includes adding a line to the Java path of MATLAB when you are logged in as the administrator; PTB will give you the instructions at the end of the installation process.)

To update Psychophysics Toolbox to the latest version after you've installed it, run the command UpdatePsychToolbox from the Matlab command line. (Sometimes this fails; I've had success just running it multiple times until it completes.)

At this time (2011-04-16) we also use a couple of BETA features of Psychophysics Toolbox that need to be installed manually. See the file attachments below.

  1. Find where your PTB installation is located by typing, for example, which('PsychImaging'); The beginning of the path will vary from platform to platform (and is represented by PATH below, you'll have to change it to match your platform; in Mac OS X, PATH is /Applications).

  2. PsychImaging.m replaces the file PATH/Psychtoolbox/PsychGLImageProcessing/PsychImaging.m

  3. PsychHelperCreateRemapCLUT.m goes in the directory PATH/Psychtoolbox/PsychGLImageProcessing

  4. ClutAnimDemo.m replaces the file PATH/Psychtoolbox/PsychDemos/ClutAnimDemo.m

  5. After installing these files, you can test to see if your video card has the ability to perform OpenGL CLUTRemapping (needed for fine timing of our stims) by running ClutAnimDemo(2); the output should appear very similar to ClutAnimDemo(0) ; if not (for example, if ClutAnimDemo(2) fails or just produces a gray screen) then you'll need a newer video card with more OpenGL support (it would be great to have a link to recommended video cards for PTB here).

Here is the message from Mario Kleiner that describes this new feature:

From: Mario Kleiner <>

Subject: Re: BlackWhiteTest.m

Date: April 3, 2011 8:31:46 PM EDT

To: Steve Van Hooser <>

Cc: Psychtoolbox Forum <>

Hi Steve,

i changed my mind wrt. simple support for clut animation, because i'm such a people person and it was a sunny day ;-)

I've implemented a shader based "clut animation" compatibility mode. This applies a color clut on the gpu, thereby transforming the image. It doesn't use the hardware gamma tables, so it bypasses the problem of bad synchronization between flips and gamma table updates. It only works on non-ancient graphics cards (like not older than maybe 5 years). The gamma tables can be used independently for their intended purpose of gamma correction.

The nice thing is it is almost compatible with the way clut animation is normally done, so it should be easy to update old scripts to the new model:


PsychImaging('AddTask', 'AllViews', 'EnableCLUTMapping');

w = PsychImaging('OpenWindow', screenNumber, 0);

...instead of...

w = Screen('OpenWindow', screenNumber, 0);

This will enable the function. Then you use Screen('LoadNormalizedGammaTable', w, clut, 2); to update the clut at next Screen('Flip'). So a simple change of the flag from 1 to 2 will do.

The help for PsychImaging 'EnableCLUTMapping' explains more details. Run ClutAnimDemo(2) or BlackWhiteTest(4) to try it.

This will be part of the next 'beta' update, but if you have a half way recent or up to date beta, you can replace some files with the attached files and try it out.

This still doesn't mean one should use clut animation in new code though. There are usually much better methods today.