Psychophysics Toolbox
Questions
Future of the Psychophysics Toolbox?
How fast is G4?
Compatible with G3, G4, and Mac OS 9?
Computer seems to be frozen?
Out of memory?
Trouble installing new version of Psychophysics Toolbox?
Trying out Matlab cheaply?
Compatibility with Matlab graphical user interface?
Playing sounds while doing other things?
Keyboard input?
Measuring reaction time?
How to connect peripherals like relays and sensors?
Using a serial port?
Hardware interfaces?
Examining MEX and DLL files?
Unsigned-byte (uint8) images?
Calibrate my monitor?
Strange text?
Showing graphics files as a movie?
Superimposing movies?
Why is my movie torn?
Page flipping and double buffering?
Using multiple monitors?
Synchronizing two displays?
Stereo?
Better than 8-bit DACs?

You may also want to look at the Psychtoolbox forum, where you can post questions to the community of Psychophysics Toolbox users, and scan previous discussions. We monitor the forum and try to answer questions when we know the answer, as time allows. If the answer seems of lasting value, we may copy it here. The Psychtoolbox and VideoToolbox web sites, and the Psychtoolbox forum have lots of useful text. We recommend trying the Psychtoolbox search command (above), which searches the VideoToolbox site as well, and the forum's search command.


Future of the Psychophysics Toolbox

Q. What are the plans for the Psychtoolbox and Mac OS X?

All development efforts are focused on the imminent release of the Psychtoolbox for Mac OS X. This effort will be maintained until that release stabilizes, reaching the same level of reliability and polish as the Mac OS 9 version, which is practically bug-free. The Windows version has known bugs and limitations that we don't have the resources to address. The new Mac OS X release is built partly on OpenGL, a graphics library available for Mac, Windows, Linux and many other operating systems. We plan to port the new release to Windows but that will occur only after it reaches a polished state on Mac OS X. This is our attempt to give the maximum research-enabling benefit to the greatest number of users, since the user community for Psychtoolbox is still more than half Mac users.

Allen now spends most of his time writing this new version of the Psychtoolbox. Unlike previous versions, which were written using platform-native graphical APIs (QuickDraw on Mac OS and DirectX+GDI on Windows), the new version is being written using OpenGL, letting us build versions for many different operating systems from a single body of C source code.

Another feature of the OpenGL Psychtoolbox will be that Matlab's .mex and .mx API calls will be separated from the main body of code. This will allow people who want to, to call Psychtoolbox functions from C instead of from Matlab. Secondly, it makes easier the work of moving the Psychtoolbox from Matlab to other numerical programming environments such as Octave, Scilab, Mathematica, or Numerical Python. We have no such plans, but there are fans of these alternative environment, and we'd like them to be able to use what we've built, instead of having to reinvent the wheel.

For the Matlab user, the OpenGL version of the Psychtoolbox will be mostly backward-compatible with the current Mac and Win versions. This means that all your Matlab M files and scripts that work with the current versions of the Psychtoolbox will continue to work with the OpenGL version.

Additionally, there will be two new classes of functions available. First, we will allow users to call OpenGL commands directly from Matlab, as with Ben Singer's SimpleGL. Secondly we will add new psychtoolbox functions to take advantage the fancy features available in OpenGL, such as antialiasing.

Presently we have no plans to offer the Psychtoolbox for Linux, though we would be glad to cooperate with anyone who wishes to create Psychtoolbox work-alike for Linux.

An alpha realease of the OS X Psychtoolbox is now available. See the OS X page for more.

Macintosh

Matlab 5.2.1 is the best-ever release of Matlab on the Mac. It runs very well on Mac OS 8 and 9., and in the Classic environment provided by Mac OS X (see report). Note, however, that because the Classic environment provides no obvious way to synchronize with the display's vertical blanking, this is not a good enviroment for visual psychophysics. In particular, the OS 9 version of the Psychtoolbox will not synchronize to vertical blanking in this environment. Other hardware-dependent features of the toolbox may also not be reliable (e.g. PsychSerial).

Windows (Also see the Psychtoolbox Windows Changes page.)

We offer the Psychophysics Toolbox for computers running Windows. A National Eye Institute vision core grant to NYU is providing a full-time programmer to support the Psychophysics Toolbox: Allen Ingling. Allen continues to fix bugs in the Windows version, but most of his time is now spent developing the new OpenGL version of the Psychtoolbox.

For the Windows version, we had considered several approaches.

1. Mac OS X and Carbon. In 1998 we thought we might be able to stay with the Apple API, which seemed to be evolving towards platform-independence. Apple supports the Carbon API under Mac OS 9 and Mac OS X, and initially described plans for supporting Carbon on Windows machines. From a quick assessment (see the Carbon-compatibility report for Screen.mex), it seems that it would be fairly straightforward to move our current source to the Carbon API. We thought we would then be able to run on Windows with minimal porting effort. However, as of 11/99 this route no longer seems promising because Apple is showing little interest in providing Mac OS X or Carbon support on the Windows platform. We are not pursuing Carbon-compatibility at present because it offers no advantages to Psychtoolbox users. Carbon-compatibility doesn't seem likely to help with Windows, and the current Matlab, version 5.2.1, isn't Carbon compatible (report), so it will run in the "Classic environment" under Mac OS X, which supports non-Carbon applications. Update, 6/26/02: the forthcoming Mac OS X version of MATLAB would work with a carbon-based Psychtoolbox. Ben Singer has made some progress in carbonizing the VideoToolbox. However, our effort is now directed to producing the new OpenGL version, supporting all the platforms, rather than on carbonizing the old Mac-only version.

2. Microsoft DirectX. The second way is to write a work-alike using the Microsoft DirectX API for Windows. Xumei Zhang created an alpha version of the Psychophysics Toolbox for Windows using the DirectX API. It's available for downloading. Starting with Mei's alpha version, we continued development and now offer a more advanced version, integrated with the Mac version, using the same M files. It's available for download. [Note: DirectX 7 is supported on Windows 95/98 and will be supported on Windows 2000, but it's not supported on Windows NT. Windows NT 4.0, with Service Package 6a, does support DirectX 3, which is all that Psychtoolbox requires, as of September 2000.]

3. OpenGL is supported by Macintosh and Windows, and most unix machines. We are now in the process of replacing our platform-specific dependence on QuickDraw (Mac) and DirectX (Windows) by platform-independent calls to OpenGL. Ben Singer has already developed a Matlab extension file (for Mac) to use OpenGL, which he calls SimpleGL, and is available for download.

4. QuickTime is available (free) for both Macintosh and Windows (but not unix). Apple seems to be committed to supporting both platforms. They're supplying frequent updates, and bragging about how many internet desktops use QuickTime. The Psychtoolbox includes Showtime.mex, to create and show QuickTime movies. (It's the Matlab version of the ShowTime package.) We could rewrite much of the Psychophysics Toolbox to be based on QuickTime, since the QuickTime linking library includes most of QuickDraw. But we suspect we could not do it all this way. E.g. we currently control the CLUT by calling the video driver, which QuickTime does not support.

5. Game Sprockets is interesting. Apple created these extensions many years ago, but the company's level of commitment has waxed and waned. Unable to discern whether they were here to stay, we've never used them. Currently (11/99) the commitment seems to be at its highest ever, and Game Sprockets has been folded into the Mac OS. DrawSprockets, in particular, is functionally very similar to some of the key parts of the VideoToolbox. Apple has indicated that at least DrawSprockets will be supported under Mac OS X, and apparently DrawSprockets is now supported under Java. It's conceivable that DrawSprockets, like QuickTime, might come to be supported on Windows, in which case it would become a viable, platform-independent way of controlling the screen. Ideally Apple would reclassify DrawSprockets as part of QuickTime, which would guarantee the same multiplatform support as QuickTime now enjoys.


G4 floating point is TWICE as fast as G3

At the same clock rate, the G4 PowerMac processor performs floating point nearly twice as fast as the G3 does. We find this with our own benchmark, reported by DescribeComputer.m and ScreenTest.m, based on the FFT in Matlab. [Matlab on the G4/450 is twice as fast as on the G3/300, at 71 vs. 36 Mflops/s, as reported by ScreenTest.] And it shows up in industry comparisons. This is very good news for Matlab users since Matlab spends most of its time doing floating point, and prices for G4 computers and upgrades have become quite affordable.



Trouble installing new version

Q. I just installed the Psychtoolbox. Matlab can't find some of the new functions. When I started Matlab I got a warning saying that it was removing some paths that it couldn't find. What's wrong?

A. You need to tell Matlab to update its path. After making sure that the Command Window is frontmost, select the menu item File:Set Path. Click "Default path". Wait. When it's done, click "Save".

Q. The web site says that Mac OS 7 is enough, but the Psychtoolbox installer says it "requires Mac OS 8.6". What gives?

A. The web site is right; we'll fix the installer for the next release (4.45). The Psychtoolbox needs only Mac OS 7. In fact the installer allows you to override and install anyway. Just click "Continue". We recommend Mac OS 8.6 or better to achieve the most accurate timing. (Thanks to Mark Georgeson for alerting us to the misleading message.)



Computer seems to be frozen

Q. We sometimes find that the software hangs the system. Everything's frozen.

A. There may be cases where the software really hangs the system. More often, however, Matlab encountered an error in the execution of your program and control has been returned to the Matlab command window. The problem is that the command window is behind the experimental window and you can't see it, and Matlab ignores most mouse and keyboard input unless the Command window is in front.

The solution is easy. Command-zero brings the Matlab Command window forward. (Type a zero "0" while holding the apple-cloverleaf key down.) Once the Matlab command window reappears, you can type "clear screen" to bring your displays back to normal.

We wish the Command window automatically came forward whenever an error occurred. We have proposed this, and related ideas, to Mathworks, but haven't prevailed. When an error occurs in our Screen.mex, it automatically does a "clear screen" and brings the Command window forward before returning control to Matlab. But if Matlab itself detects an error, it terminates execution without notifying us. Ideally Mathworks would add to the Matlab API a mexAtError() function analogous to mexAtExit().



Out of memory?

People writing programs to show movies often write to us (e.g. see forum 52 or 122) asking why their program runs out of memory after using Screen CopyWindow to show a movie several times, typically once per trial of an experiment. The answer has often been that they opened a new offscreen window for each movie frame before the trial, but forgot to close the offscreen windows after the trial. Opening an offscreen window uses up memory until the window is closed. You should either open the offscreen windows before each trial and close them after the trial, or open them once, before the whole experiment, and reuse that set of offscreen windows for every trial, finally closing them when you're done.

Don't skimp on memory. You can buy a gigabyte for three hundred bucks! http://www.macresource.com/mrp/ramwatch.shtml


Trying out Matlab cheaply

Q. Before shelling out the $500 or so for Matlab (which I have not used previously) I wonder if there is some way to check it out?

A1. For Mac, buy the Prentice Hall Student edition. (That's "edition", not "version".) It's a slightly crippled version of Matlab 5.0 for $99. [ Alas, the Mathworks web site says this version is only available outside the US. Perhaps you can talk Prentice Hall into selling it to you anyway, since the student "version", below, is not available for Mac. Or perhaps Amazon can find you a copy in the out-of-print book market.] The differences from regular Matlab are that the Student edition of the application is limited to arrays no bigger than 128x128 (which is not a serious limitation), and that you get a fixed set of Toolboxes (a reasonable selection). It's compatible with Psychophysics Toolbox 2.35, so you can run all our demos, etc. (A few M files run afoul of the maximum array size, but they could easily be fixed to respect it.) The downside is that Matlab 5.0 was very buggy, and the Student version preserves these bugs, which are quite annoying. For serious work you'll want to buy Matlab 5.2.1. [Psychtoolbox 2.35 is compatible with Matlab 5.0 (including Student Matlab), but the latest versions of the Psychtoolbox are not fully compatible, because they are tested only with Matlab 5.2.1 and some files use new features of Matlab. We think it would be easy to work around the incompatibilities.]

For Windows, buy the Mathworks Student version for $99. (That's "version" not "edition".) It's not crippled at all, but, apparently it prints a "Student Matlab" footer on every page. A great deal, if you're eligible. As of 2/10/00 the Psychophysics Toolbox 2.41 for Windows seems to be incompatible with the Student version of Matlab. We plan to make it compatible by the end of 2000.

A2. There are educational discounts on regular Matlab. (Matlab is enough; you don't need to buy any extra toolboxes to use the Psychtoolbox. The only exception is four Psychtoolbox Psychometric fitting routines, which few people need, that use the Mathworks Optimization Toolbox.)

You ought to be able to buy Matlab for Mac directly from the Mathworks online store, but there doesn't appear to be a way to select the Macintosh version, so you may need to contact them directly.

Buy Matlab for Windows directly from the Mathworks online store.

A3. Even without buying any edition of Matlab, you might download the Psychophysics Toolbox (raw archive) and read the demo Matlab source files, which are called M files. This will give you some sense of what it feels like to write programs in Matlab. You can use any text editor to look at the M files. See MovieDemo.m



Compatibility with Matlab graphical user interface

Q. Is your code compatible with the purported ability of Matlab to generate graphical user interfaces?

A. We haven't used the Matlab user interface stuff. They might be compatible. Try it. So far we've found that we can do what we need to do with just Screen.



Playing sounds while doing other things

Q: How can I do something (like show a movie or measure reaction time) while my sound is playing?

A: Easy. Snd.mex is asynchronous. This means that it starts your sound playing and returns immediately, as the sound continues to play in the background. You have full control to do anything you like, just as if the sound were not playing. (Raising processor priority might interfere with sound playing; check and see.)



Keyboard input

Q. Matlab ignores keyboard input while my Screen window is open.

A. Matlab itself accepts input from the keyboard only while the Command window is in front. Here are a couple of possible solutions.



Measuring reaction time

Q. Can I use the Psychophysics Toolbox to measure reaction time?

A. Yes. You can't get 1 ms accuracy without extra hardware, but the 8 ms accuracy you can get from your off-the-shelf Mac is more than enough to measure human reaction times. Variability in observer responses will typically swamp the reaction time variance contributed by the Mac keyboard polling. The timing routine GetSecs is accurate to 20 ns on PowerMacs with Mac OS 8.6 or better.

The standard keyboard interface on the Mac keyboard is polled, not interrupt driven. Therefore there is an uncertain delay (up to 16 ms) between when a key is pressed and when the OS detects the event. It is nontrivial to get around this limit, although Dan Costin has written the KeMo package to get better (2 ms) performance by reading the ADB bus directly. We have not yet incorporated the KeMo software into the Psychophysics Toolbox, although it should be easy to do. You can read more about KeMo and get complete sources from our KeMo page. The KeMo archive also contains a more in-depth discussion of timing issues on the Mac in the context of RT experiments.

Our Keypress Tips page has more discussion. Another approach is to use custom hardware such as the CMU button box and Brian Stankiewicz's MEX file interface.

According to Tim Bates the ActiveWire device has sub-millisecond timing. Tim shows how the ActiveWire device can be connected to a subject response button. We provide a .dll extension for controlling the ActiveWire device from the Windows version of Matlab.



How to connect peripherals like relays and sensors?

You can attach external hardware to your computer through a serial, , FireWire port, or the ADB (keyboard) or SCSI interface. Or you could plug a card into the PCI bus. The Psychophysics Toolbox includes SERIAL.mex, which you can use to communicate to an external device through the serial port. Software support for other ports (, FireWire, ADB, SCSI) could easily be added since the hardware manufacturers usually supply C code for their devices. We'd be happy to fold this into the Psychtoolbox.

Here are some options for controlling digital and analog I/O ports from Matlab.

The ActiveWire device , which has 16 bi-directional digital I/O pins, can be controlled from within Matlab by using our ActiveWire extension included with the Psychtoolbox version 2.5 and greater.

Ben Singer provides AcquireDIO, AcquireAIO, IOCard functions for control of National Instruments cards.

Mathworks Data Acquisition Toolbox "provides a complete set of tools for analog input, analog output, and digital I/O from a variety of PC-compatible data acquisition hardware."

Cogent 2000 provides an interface for controlling the PC parallel port.

 

There are lots of leads to manufacturers on our Tips: How to and Tips: Analog pages.


Troubleshooting serial communications

Q. I just made a cable to connect my handy dandy new photometer (or other gadget) to my Mac's serial port, and nothing happens when I try to communicate using the Psychophysics Toolbox SERIAL.mex. What's wrong?

A. When making a custom cable to connect your serial port to another device, e.g. a photometer, it usually doesn't work until you get all the connections right. (Alas, there are certain lines that must be held high or low for anything to work.) Figuring out what's wrong is a bit tricky. Our Tips website has a section on serial ports that will lead you to several web pages that explain how to make a serial cable and two downloadable serial-port debugging utilities (Serial of Champions and Keyboard2Serial).



Hardware interfaces

Q. I'd like to use the Psychophysics Toolbox routines to control visual stimuli (bars, gratings, dots, noise) during intracellular and extracellular cortical neurophysiology experiments. My physiology is all set up to run on a computer running Windows. Can I use the Mac for stimulus generation?

A. We think this part should work fine. We presume you will put some sort of an i/o card in the Mac that will communicate with your data acquisition computer. We use a configuration like this for some hardware control (National Instruments Lab-NB card). It was no problem to write routines to talk to the hardware from inside of Matlab. We did this all on a 68K/NuBus Mac and have not yet ourselves tried dealing with hardware on a PPC/PCI Mac.

Mike Shadlen at the University of Washington has built a physiology setup using the Psychtoolbox for stimulus generation. He is using a PowerMac and communicates with his PC via a National Instruments card. Send him email if you'd like details.

Sometimes all that is necessary is to send a synch pulse to the data acquisition computer when the stimulus changes. This can be done using the CTS line on a Mac serial port. The routine CMETER has a CTS function that will set the state of the CTS line. If you are using a modern fast Mac this should work fine. On an older Mac, you may want to write a specialized MEX file that changes your stimulus and drives the CTS line in closer synchrony. A simple circuit can be used to buffer the CTS line so that it is TTL compatible.

See Tips for a discussion of hardware for acquiring analog voltages and spikes.



Examining MEX and DLL files

Q. How I can take a look at the content of MEX and DLL files?

A. The MEX and DLL files are binaries, so you'd need help from the CodeWarrior Debugger (for MEX) or Microsoft C compiler (for DLL) to peek at the underlying assembly or C code. The source code for the MEX and DLL files is included in the archive (download here). You can look at the source with Metrowerks CodeWarrior C or Microsoft C.



Unsigned-byte (uint8) images

Q. Can I pass uint8 images to Screen?

A. Yes, if you use Psychtoolbox version 2.3 or better.



Calibrate my monitor?

A. The Psychtoolbox PsychCal folder has a set of functions for display characterization, including IccProfile.mex, which reads ICC profiles. Try SimpleCalDemo. See our measurement page for commercial packages including a colorimeter and software to produce an ICC profile.



Strange text

Q. Why does my text look strange on one particular computer?

A. Try turning off text smoothing in the Appearances and Adobe Type Manager (~ATM) control panels. Formerly text was always drawn with one color, and some user-written programs depend on that fact. Smoothed text uses many colors and may look strange if you are making arbitrary changes to the color lookup table.



Showing graphics files as a movie

Q: Marc Joanisse asks how to read in graphics files and show them as a movie.
A:
1. First read in the images. Use Matlab's IMREAD command to read each file into a matrix. IMREAD accepts many file formats: BMP, HDF, JPEG, PCX, and TIFF. IMREAD can't read PICT files, but there are many applications (e.g. Adobe Photoshop, or the $35 shareware GraphicConverter ) that can convert PICT, etc. to a format that IMREAD can read. (Another way to get image data into Matlab is through the clipboard. See the Psychophysics Toolbox routines CopyImage, PasteImage, CopyCImage, PasteCImage.)
2. Then show them as a movie, using either Screen or Showtime from the Psychtoolbox.
2a. Use Screen to show as a movie. First use the Psychtoolbox's Screen 'OpenOffscreenWindow', 'PutImage', and 'CopyWindow' functions to copy each image (i.e. matrix) into its own offscreen window and then show the movie, as in MovieDemo.m.
2b. Use Showtime (formerly "QT") to make a movie file and show it. First use the Psychtoolbox's Showtime to create a movie file (which you can share with friends) and then show the movie, as in ShowtimeDemo.m. (The movie above was created by ShowtimeDemo.m and then compressed for the web. Type "help Showtime" in Matlab.)


Superimposing movies

Q. We have an experiment in which we superimpose two drifting gratings of different orientations and temporal and spatial frequencies to make a plaid. With the picasso, we did it by running at 200 Hz frame rate, and alternating the two gratings frame by frame. Can't do that with only a 120 Hz frame rate. One can make a movie, of course, which takes time.

A. Adding movies together in real time may be practical. Screen CopyWindow has an "addOverQuickly" option.

QuickTime allows multiple video tracks within a movie file, and, I suppose, may allow one to specify that they be added together for display. We could add support for that in Showtime.mex, if it seems likely to be really useful.

Consider precomputing your movie of superimposed gratings. A precomputed movie (or many short ones) requires a lot of memory, but memory is cheap ($0.25/MB). You can load up your Mac with 1 GB RAM for $256, which will give you room for a lot of offscreen windows (using Screen.mex) or a long QuickTime movie (using Showtime.mex). http://www.macresource.com/mrp/ramwatch.shtml

Another solution is to get a second graphics card and monitor and optically superimpose the two monitors with a half-silvered mirror. See Synchronizing two displays.



Why does my new display card put a tear in my movie?

Matteo Carandini wrote, "we have problems with a video board, it messes up our stimuli. When we run on the mac's own video board, instead, the stimuli look fine." Jeff Anderson says, "... it seemed like the screen refresh was not sweeping from top to bottom, but following a strange pattern. Peculiar V-shaped tearing lines were visible in most stimuli. This tearing completely disappeared when we changed the video card." To which Matteo replies, "THAT'S EXACTLY THE BUG WE HAVE!!!"

Tearing is a real artifact, but not a bug since it's a direct consequence of showing dynamic images without double buffering. Tearing is a general problem that must be addressed when using any card that doesn't support double-buffering. (Few do.) Try running the MovieTearDemo.m, and read the "help movieteardemo" text.

Typically, you can arrange for the tear to occur in a static part of the screen, making it innocuous. Where the tear occurs on your display depends on the card's hardware, your computer's bus speed (ie "CopyWindow" data rate from memory to card in MB/s, reported by ScreenTest), and any delay you introduce between blanking and your call to CopyWindow.

EXPLANATION OF TEARING (from MovieTearDemo.m)

You may see "tearing" any time you display dynamic stimuli. The tear is a horizontal break, perhaps a third of the way down from the top of the screen, jiggling up and down as the movie plays. This tear is normal and does not indicate anything wrong with your hardware or software. Tearing can occur in any display that isn't double buffered, and hardly any of the drivers for Macintosh video cards support double buffering. Even so, it's easy to avoid tearing once you understand why it happens.

The tear is a discontinuity in time. The movie above the tear is delayed by one frame relative to what's displayed below the tear. This is invisible if the movie is static, but produces a glaring break in a moving object. Your video card has enough video memory to store one frame. The reading of video memory is an autonomous free-running process that drives the intensity and position of the monitor's video beam in a raster scan that paints the screen from top to bottom. The tear is the result of the computer writing to the same video memory that the video beam is reading. The computer is racing with the video beam from the top to the bottom of your screen. The beam has a head start, but your computer is slightly faster. The tear occurs when your computer passes the beam. Below the tear you see the contents of the new frame, just written by your computer into the frame store. Above the tear you are seeing the contents of the previous frame.

You can eliminate the tear by pushing it up off the top of your movie. Anything that makes your computer proceed more quickly down the screen (e.g. making the movie narrower) will move the tear higher, as will moving your movie's window lower, i.e. giving your computer a head start in the race from top to bottom of the screen.

JIGGLING: The relatively stable vertical position of the tear is a consequence of the synchrony of the computer and monitor; if they weren't synchronized the tear would occur at a different height on each frame (which would make it much harder to get rid of). The jiggling up and down of the tear reveals the computer's varying latency, due to Mac OS and device driver interrupts. This allows you to directly observe the effect of using Rush to minimize interruptions.

DOUBLE BUFFERING: The hardware method of eliminating tearing is double buffering, explained below. The Mac OS defines driver-level calls to support multiple pages (double buffering) and most video cards have suitable chips and enough video memory to provide multiple pages, but hardly any video-card manufacturers have bothered to program their video drivers to support more than one page of video memory.


What are page flipping and double buffering?

Most video cards are capable of having enough memory to hold more than one screen-full (a page), and of using any section of memory (selecting a page), which would allow you to instantly select any of several "pages" in your video memory for writing or display. Unfortunately very few of the currently available Macintosh software drivers for video cards support more than one page. ScreenTest reports how many video pages you have access to.

Selecting a page on the fly is called page flipping. Flipping between two pages, writing to one while showing the other (to avoid the tearing artifact) is called double buffering.

We could add Matlab-level calls to do page flipping. Please send us a note (psychtoolbox@psych.nyu.edu) if you have a video device with more than one video page and you'd like to try page flipping. And have a look at Ben Singer's Page Flipping web page and software.


Using multiple monitors

Q. Can I use the Psychophysics Toolbox to drive more than one monitor?

A. On the Macintosh, Yes. The screenNumber argument to the windowPtr = Screen(screenNumber,'OpenWindow', ...) command is used to specify a monitor (0 for main screen, 1 for next, etc.) The returned windowPtr value is then passed to other Screen commands to determine where the action takes place. Thus you can alternately write the frame buffer and/or CLUT of two (or more) monitors to show movies on both.

See Synchronizing two displays.

There are some artifacts that can arise with two monitors that have nothing to do with the Psychophysics Toolbox or even the Mac. These can occur, for instance, because of crosstalk between the monitor cables. See Tips:Displays for more.

The Psychtoolbox for Windows is compatible with multi-display systems, but unlike the Mac version it will only control the main display.



Synchronizing two displays

Q. We want to use two monitors to create a stereo display, or simply to combine them with a half-silvered mirror to create a single display. Must we synchronize the two monitors? Can we?

A. You can optically superimpose two monitors with a half-silvered mirror. The mirror's not expensive and as long as you're working at low spatial frequencies relative to the pixel size, alignment isn't too hard. This is how we handled some detection on pedestal experiments here at ucsb, where the target and pedestal were temporally modulated gabors of different colors. A virtue of superimposing two monitors is that you gain an effective bit in contrast control for each.

Depending on the needs of your experiment, you may need to synchronize your two graphics cards. It might be possible to buy a dual graphics card that will drive two monitors, synchronously. We know that the ATI Radeon 7000 can drive two monitors, and suspect that all the Radeons can. Failing that, there are some subtleties in showing synchronized movies on two screens at once.

First, you would want to synchronize the video refresh on your two screens. This can usually be done, but there isn't a general solution. Synchronizing is pretty easy if you can vary the frame rate (a special feature of some video drivers) and also detect the time of a vertical blank (see Screen PeekBlanking). Then you can synchronize by setting the two monitors at slightly different rates, allowing them to drift until they are in synch, and then setting them to the same rate.

Second, you want the writes to take effect on the same retrace. Once you get your two-monitor experiment up and running, you can use a pair of photodiodes and an oscilloscope (or some other measurement method) to verify that the displays really are synchronized. Whether synchronization is critical depends on what you are measuring. For some experiments, 10 ms of asynchrony may not matter.

If you are blitting into the frame buffer, you'll want to think about how fast you can go and still keep up with both monitors. ScreenTest will tell you how fast you can blit data to each screen.

If you're using CLUT animation, you should figure out which (if any) of your video drivers wait for blanking when you try to write to the CLUT. ScreenTest will tell you.

Adventurous users may want to experiment with the new Screen ResolutionQuickly commands (in Psychtoolbox 2.5), as quickly switching between resolutions may be a practical way of delaying or advancing one screen relative to the other.

For more advice on this topic, see Tips:VideoSynch.



Stereo

Q. How do I do stereo?

A. For some purposes, it's enough to use the red and blue guns to generate the two eyes' images and use anaglyph (red/blue) 3d glasses.

With a bit more effort, you can optically superimpose two monitors with a half-silvered mirror, put polarizing filters on each display, and view through polarizing 3d glasses. For some purposes, you may want to synchronize the two displays.

The fanciest way is to view a single display through active glasses that allow each eye to view alternate frames.

Sources for all three kinds of glasses appear in Tips:Stereo.



Better than 8-bit DACs

Q. Quantization on 8-bit cards makes the intensity/contrast resolution too coarse for threshold experiments. Can I do better?

A. Yes.
Before we explain how, let's answer the common question, "Would a 24-bit graphics card help?" No. In fact the vast majority of video cards are like that. "24-bits" refers to the sum of the resolutions of the three DACs, 3x8=24, but you still have only 8-bits of resolution in each DAC.

One can achieve better-than-8-bit resolution either by buying a higher-resolution graphics card, or by combining multiple signals.

There are several ways to obtain finer contrast steps using 8-bit DACs, but none are trivial.



visitors since 20 March 2000.
David Brainard, Denis Pelli & Allen Ingling.
psychtoolbox@yahoogroups.com
26 June 2002