Matlab Psychophysics ToolBox Code (PC/WIN)

Currently I do all my psychophysics development under Windows with the Psychophysics ToolBox, version 2.54. It's pretty mature and mostly bug free, at least under Matlab 6.5 - 2007a. Sadly, it's not really updated anymore, and there's at least one show-stopper bug in WaitSecs, so if you use this platform be sure to download the patch here, or download my forked PTB  2.54 version which has all the official patches plus a few additions back-ported from the new version of 3.x (my changes are described here). Note that I have not tested Matlab versions later than 2007a, and it is possible that these versions may not work with my code, due to changes in how mex code is loaded. 

Note: I hear that the new openGL version (3.x) of Psych Toolbox is pretty good, but for now I use 2.54 since 3.x breaks backwards compatibility. 

Use this code on this page as you wish. If you find the code here to be significantly useful, feel free to acknowledge its source. If you have any questions about this code, feel free to contact me.

"Full fledged" experiments

imgShow is a simple tool for experiments with multiple trials, where each trial is made up of multiple images. The code is relatively well documented.

psycho_sin_demo is a example of animating a sine wave grating and reading keyboard input. Not a full fledged experiment, but a place to start. We use it for teaching the basics of the toolbox, and then ask students to write the program below, which usually takes about 2-3 hours for moderately capable Matlab programmers. 

psycho_detect_motion - experiment for finding a contrast detection threshold for a moving grating. Based on psycho_sin_demo. Designed for teaching purposes, this experiment is written to be easy to understand, and does not control for timing as well as would be necessary on a low-end machine.

 

Monitor calibration

Monitor Linearization Toolkit - a collection of code that attempts to linearize the output of your monitor by setting the Windows gamma ramp. Makes no assumptions about how luminance relates to DAC values, but instead uses interactive approximation driven by a CRS colorCAL photometer. 

 

Code for getting input

[key, time] = waitForKey(seconds)
% Waits for seconds, or key press (whichever is first)
% returns key pressed and when it was pressed


[buttons,x,y,time] = waitForMouse(seconds)
% Waits for seconds, or mouse press (whichever is first).
% Returns matrix of buttons states, x and y location at press, and when it was pressed.
% If no button was pressed, then returns empty matrix, and x,y state at timeout.

 

Drawing code

drawXhair(window, point)
% draw a crosshair at x,y location [point]

displayText(window, filename)
% prints the text in file <filename> to the screen.

timedDisplayText(window, filename, seconds)
%show text in <filename> on screen for exactly <seconds>

 


(c) 2008 Alan Robinson (robinsoncogsci.ucsd.edu)