Psychtoolbox-3 Differences between PTB-3 versions for OS/X, Windows and Linux


The implementations of Psychtoolbox-3 for Microsoft Windows and GNU/Linux are derived from the Mac OS/X implementation. As of October 2012, all versions are mostly compatible to each other and equally capable in core functionality. The different operating systems differ in their capabilities and limitations. You will have to take this into account if you want to write portable scripts. The following information should allow you to write scripts that are as portable as possible and to assess if PTB on a specific operating system is suitable for you.



The information on this page is periodically updated (i.e., at any point in time slightly outdated). It always refers to the state of the current beta flavor of PTB.




Status of different core features and how to handle differences:


Matlab M-File functions

All functions that are implemented as Matlab M-Files should work without any differences between system platforms, as long as they don't depend on system dependent MEX files. M-Files are tested with the Matlab 7.x series and the GNU/Octave 3.2.x series.

If you need to write scripts that have to behave differently on the different platforms, the following functions may be helpful:

- IsOSX returns 1 when the script is executed under Mac OS/X, 0 otherwise.
- IsWin returns 1 when the script is executed under Microsoft Windows, 0 otherwise.
- IsLinux returns 1 when the script is executed under GNU/Linux, 0 otherwise.
- IsLinux(1) returns 1 when the script is executed under GNU/Linux with a 64 bit version of Matlab or Octave, 0 otherwise.
-Is64Bit returns 1 when the script is executed in a 64-Bit version of Matlab or Octave, 0 otherwise.
- IsOctave returns 1 when the script is executed in GNU/Octave, 0 if the script is executed in Matlab.
- OSName returns the name of the operating system platform.
- AssertOpenGL aborts execution of your script if someone tries to execute it in PTB-2 instead of PTB-3.
- AssertOSX aborts execution of your script if someone tries to execute it on a operating system other than Mac OS/X.
- AssertGLSL aborts execution of your script if it is executed on graphics hardware that does not support the OpenGL Shading language GLSL.

Serial port access

Our IOPort driver provides high quality, flexible serial port support (also for USB serial ports) with high timing precision on all operating systems, so use of IOPort is strongly recommended over less optimal solutions like Matlabs serial command.

Joystick support

The OS-X and Linux versions support joysticks via the new GamePad function. We provide some simple joystick support for Windows via WinJoystickMex.


A functional implementation of the Eyelink toolbox is included in the Psychhardware folder of PTB for all operating systems. It is reported to work well, although it's not polished yet, e.g., the documentation and some of the demos are not yet updated and cleaned in all parts. You must install the runtime libraries from SR - Research on your system for this to work. They come bundled with your Eyelink and are also downloadable from their website. As of October 2012, there seems to be no support for Eyelink on 64-Bit Windows systems, ie., Eyelink will not work with 64-Bit Matlab. This limitation is imposed on us by SR-Research's lack of support.

Snd command for sound output

Sound output via the old and deprecated Snd command is currently implemented as a wrapper around the PsychPortAudio driver for decent cross-platform compatibility. However use of Snd is deprecated for all but the most simple use cases, e.g., providing simple auditory feedback to a subject. For research grade auditory stimulation, use PsychPortAudio directly, or you will be doomed! Click this link for more info about PsychPortAudio.

OpenGL for Matlab/Octave support MOGL

Support for OpenGL low level commands is identical for all systems. Well, almost: Support for specific functions depends on the capabilities of your graphics hardware and OpenGL implementation, so some of the most recent features of OpenGL may not be supported on old graphics hardware. The solution to this problem is simple: Upgrade your graphics drivers or your hardware. We currently support the OpenGL 2.1 API and earlier versions, including various extensions.

PsychHID and the DAQ toolbox

PsychHID for control of USB HID devices is implemented on all systems since the end of 2011. You may encounter differences in the information provided about connected HID devices when calling PsychHID('Devices') due to differences in the underlying operating systems. If you write code that uses device enumeration to detect your devices, make sure to test on different operating systems to take these differences into account.

GamePad

The GamePad function is only available on Mac OS/X and Linux for now.

Fonts

The Fonts command for flexible query and handling of character fonts only exists on Mac OS/X with no plans to ever implement it on Windows or Linux.

ListenChar, CharAvail, GetChar, FlushEvents

In Matlabs regular GUI mode, functions for character input are implemented as a Java class via Matlabs built-in Java virtual machine (JVM). Usage on all platforms is identical, no known principal differences, except that it doesn't work well on MS Windows Vista and Windows-7 (see the FAQ section about Vista problems for more info). Differences, if any, would be due to differences in the implementation of the JVM in different versions of Matlab. We need JVM version 1.4.2 or later. If Matlab is run without Java support or GUI (matlab -nojvm mode or matlab -nodesktop mode selected at startup), or if you are using Octave instead of Matlab, a different implementation is used, which works but is more limited in its capabilities. Read help GetChar and help ListenChar for more info. The GetKbChar function is often a viable and more robust replacement for GetChar.

KbCheck, KbWait, KbName

Usage, behaviour and timing of KbCheck, KbWait and KbName should be identical / similar on all systems - no known relevant differences.

The mapping of keyboard scancodes to key names used to be different in the Psychtoolboxes for OS 9, OS/X, Windows and Linux. E.g., the left arrow cursor control key used to be named 'left' on Windows, 'LeftArrow' on Mac OS/X and 'Left' on Linux. This is annoying if one wants to write portable scripts. When writing new code, you should add the command KbName('UnifyKeyNames'); at the top of your script. This will make sure that KbName accepts and returns identical keynames on all operating system platforms, allowing you to write portable code without extra effort. However, mapping of some special or exotic keys may be incomplete, so you should probably avoid those keys for portable scripts.

% Add this at top of new scripts for maximum portability due to unified names on all systems:
KbName('UnifyKeyNames');


SetMouse, GetMouse, ShowCursor, HideCursor, GetSecs

No known relevant differences in behaviour or quality, tell us if you find some! "GetSecs" timestamps are accurate at sub-millisecond level on all systems. The mouse and cursor handling functions on Linux allow to query and control multiple mice or mouse cursors individually. Only one mouse or mouse cursor is supported on OS/X and Windows, multiple mice are "merged" into one mouse input.

Priority and WaitSecs

The range of values accepted by the Priority command differs between OS-X, Windows and Linux. Priority(0) disables realtime scheduling on all operating systems. On Linux, the Priority command can utilize some special system facilities to make realtime mode more effective and robust than on the other operating systems. On Linux you can also optionally install a low-latency or hard-realtime operating system kernel and various other tweaks to the system configuration if you require especially precise or robust realtime behaviour. This is generally not needed for most experimental setups, but if you choose to do it, it can provide realtime behaviour and timing precision that is orders of magnitude better than what Windows or OSX can possibly achieve. See the Linux specific setup pages on the Wiki for more information.

Use the MaxPriority function to query maximum allowable priority levels for realtime scheduling (help MaxPriority) in order to keep your code portable.

% Select maximum allowable realtime priority for current operating system:
Priority(MaxPriority);


WaitSecs accepts values with microsecond precision. The robustness and accuracy of the real waiting time compared to the requested waiting time depends on the scheduling accuracy and timing jitter of the underlying operating system. My experience is that scheduling on a well configured Linux system or Mac OS/X Tiger / Leopard system is very accurate and robust, whereas Microsoft Windows systems are significantly worse on many tasks. For best possible precision, use a Linux system with low-latency or realtime kernel installed.

Screen

The implementation of Screen is mostly identical on all systems, providing the same capabilities and performance on all operating systems. The following differences are known to exist. These differences are mostly unavoidable and therefore unfixable due to different designs and limitations in the underlying operating systems.
In any case, you have to run your displays at a color depth of 32 bits per pixel - which is the default setting - to take full advantage of Psychtoolbox alpha blending functions.
In general, it is beneficial to use the stereo modes with the PTB imaging pipeline enabled. See ImagingStereoDemo for an example of use. On OS/X this is crucial for dual display stereo. On all operating systems if you use Anaglyph stereo presentation, it will allow for very flexible control over gains and other parameters via SetAnaglyphStereoParameter().
Most older graphics cards are restricted to 8 bits DAC precision and even the latest models from ATI or NVidia have at most 10 bits of DAC precision, so the 16 bit limit imposed by the operating systems is a theoretical limit, not a practical one!
On recent graphics hardware, the PsychImaging('AddTask','General','EnableCLUTMapping') function allows to restore clut animation in a portable and reliable way on all operating systems. This needs hardware with fragment shader support. This method of clut animation also allows for perfectly frame-accurate animation.
However, we consider clut animation mostly an obsolete, ancient feature - There are almost always better ways to create animated stimuli with all the new PTB drawing functions.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki