Psychophysics Toolbox with Linux

(if you really, really must)

Separate X desktops
Specific issues

June 2012

A quote from the Psychtoolbox wiki:

“Technically, in our experience, Linux is much more advanced, feature rich, robust and reliable in its operation than MS-Windows. It provides much more robust and precise timing behaviour, higher overall performance and it is much more flexible and customizable for applications with special needs. Unfortunately, most of our userbase consists of Windows users and the Linux userbase is very small. Therefore we can’t spend as many ressources on supporting and developing the Linux Psychtoolbox as we spend on maintaining the Windows Psychtoolbox for a larger userbase. This leads to the unfortunate situation that the Linux PTB lacks a few useful features wrt. the Windows Psychtoolbox, e.g., movie playback support, and that getting started with the Linux PTB likely involves a much steeper learning curve in the beginning. Therefore, we can not unconditionally recommend the current Linux Psychtoolbox over the Windows Psychtoolbox to beginners, but only to advanced power users, although this means that the majority of users will be locked to a technically far inferior operating system with many shortcomings. ”

I would second that, and add that as of 2012, I am not aware of any reason to use Linux over Windows. A couple of years ago, I couldn’t get high refresh rates under Windows, but recently I have been able to do so just fine. So I would personally recommend anyone to stay with Windows, unless you are a serious techie¬†who knows what you are doing under Linux in all its complicated incarnations. I score fairly highly on the geek scale (did a PhD writing Fortran code under Unix, thesis in LaTeX etc) but am STILL not techie enough to get anything out of Linux.

August 2010

I am preparing to run a set of experiments where I want excellent timing and excellent contrast control. For this reason, I am using two CRTs capable of up to 160Hz refresh rates, one for the experimenter and one for stimulus display. The stimulus CRT is connected via a DATAPixx box which gives it effectively 16-bit contrast (0-65536 graylevels, instead of 0-255 as usual).

I was having various timing issues with Windows 7, and for my proposed experiment timing was critical, so inspired by the quote above, I decided to try running it in Linux to see if that improved things. After all, all the code’s written in Matlab, so I’d just run it right away exactly as I would in Windows, only without the timing issues, right?

Well, it has indeed been quite a learning curve, so here are my random and incomplete notes for future reference. Thank you to all the people who put helpful stuff up on the web about all this!

 

General notes on Linux for a newbie

Thank goodness, I had our lovely computing officer, Sean Gray, to install Linux for me. Hence no notes on that process here.

General info

For information about what version of Linux you are running, try

uname -a

That isn’t very helpful to me; I find

cat /etc/*release

and

lsb_release -a

much more helpful.

Moving between command line and desktop

To move from the GUI X desktop to the command line, go to a terminal and type “init 3”. If you’re not logged in as root, you’ll have to do “su -“and give the root password first. To move back, you type “init 5” from the command line. Intuitive huh? And geeks wonder why normal people don’t use Linux!!!!
This does not always work, for some reason. You can get it into a muddled state where init 3/5 have no effect. Also try ctrl-alt-backspace to get to the command line from X, and startx to get to X from the command line. If all else fails, I just reboot…

Keyboard

To begin with, my keyboard was US and I kept hitting the wrong keys. I thought I could fix this by going to System->Preferences->Keyboards, Layouts, Add, and selecting UK, and then also changing the keyboard type from “generic international 105-key” to “generic 104 key”. Totally didn’t work. Eventually googling led me to

setxkbmap gb

Looks like the pretty GUI is a bit useless in Linux – you have to set everything from the command line if you want it to work (see below re Dual display).

Server

To connect to my files on the server, I needed to use Places->Connect to Server. The settings are “Service Type”=”Windows Square”, “Server”=”dendrite”, “Share”=”home3”, “Folder”=”readlab”, “Domain”=”campus”. That enables me to see files within the GUI, but not to change to that directory within Matlab. For that, I had to mount the network drives:

mount.cifs //dendrite/home2/njcar /home/njcar -o user=njcar
mount.cifs //dendrite/home3/readlab /home/Readlab -o user=njcar
having first created the directories njcar and Readlab using mkdir.

Dual display

This took me an age. I thought System->Administration->Display, “Dual Head”, “Use Dual Head” would have done it, but no, that just trashed the Gnome desktop. I had to restore a previous config from the command line.

I first installed the latest Nvidia drivers. Unlike Windows, they don’t seem to come in an executable which you run by double-clicking. I saved the file NVIDIA-Linux-x86_64-256.44.run to desktop, then opened a terminal, changed to that directory, and typed “sh NVIDIA-Linux-x86_64-256.44.run”. This didn’t make “Use dual head” function, though. I had to edit the xorg.conf file in /etc/X11.

Eventually with much help from the NVIDIA Accelerated Linux Graphics Driver README and Installation Guide, I managed to figure out a way to do this. In fact, two ways.

Twinview

First, I tried TwinView. This is where two monitors display a single X screen. I.e. as far as X is concerned, there’s just one big monitor, like “span mode” in Windows. This is not good for PTB, as it appears as a single screen, 0. Since one of the major advantages of having two monitors is to be able to display your experiment on one monitor and look at the code in the other, that’s not ideal.

My graphics card is an NVidia GeForce G210, with one VGA and one DVI output. If I just plug both CRTs into my graphics card (one with a DVI-to-VGA adaptor), then they are identified by the computer as CRT-0 and CRT-1. (You can find this and other useful information in /var/log/Xorg.0.log). If I plug one CRT into the DATAPixx, and then DATAPixx into the computer, that monitor is identified as DFP-0 (digital flat panel). Thus I found that I needed different versions of /etc/X11/xorg.conf with and without the DATAPixx attached. Here are versions of the file which work on my system under the two circumstances.

Copy contents as a plain text file, then paste it as /etc/X11/xorg.conf. Won’t work as-is on someone else’s system, but might provide a useful starting point.

So I then looked at the alternative. This configures the system to treat each monitor as a separate X screen, a bit like “dual display” in Windows. The difference is that you end up with two X desktops, one on each screen, each with its own menubar and taskbar. As far as I can tell, there isn’t a distinction between “primary monitor” and “secondary monitor”

I generated these files with the help of nvidia-settings. You can start this from the command line, make the changes you want, then hit “export to xorg.conf file” and it will automatically generate a suitable file.

You can use gtf to help you generate the right modeline. E.g. I know my CRTs support 800×600 at 160Hz and 1280×1024 at 110Hz.

1
2
3
4
5
6
7
8
9
10
gtf 800 600 160
 
# 800x600 @ 160.00 Hz (GTF) hsync: 105.44 kHz; pclk: 116.41 MHz
Modeline "800x600_160.00" 116.41 800 864 952 1104 600 601 604 659 -HSync +Vsync
 
and
gtf 1280 1024 110
 
# 1280x1024 @ 110.00 Hz (GTF) hsync: 120.01 kHz; pclk: 211.22 MHz
Modeline "1280x1024_110.00" 211.22 1280 1376 1520 1760 1024 1025 1028 1091 -HSync +Vsync

Then you can paste these into the monitor section of xorg.conf, as above.
In getting the xorg.conf file right, it’s helpful to have a look at /var/log/Xorg.0.log. E.g., I learn that the BusID of my graphics card is “PCI:1:0:0”.

1
2
3
4
5
6
7
8
9
10
11
12
13
(--) Aug 20 15:05:25 NVIDIA(0): Connected display device(s) on GeForce G210 at PCI:1:0:0:
(--) Aug 20 15:05:25 NVIDIA(0): COMPAQ P1100 (CRT-1)
(--) Aug 20 15:05:25 NVIDIA(0): HSD DATAPixx (DFP-0)
(--) Aug 20 15:05:25 NVIDIA(0): COMPAQ P1100 (CRT-1): 400.0 MHz maximum pixel clock (--) Aug 20 15:05:25 NVIDIA(0): HSD DATAPixx (DFP-0): 330.0 MHz maximum pixel clock
(--) Aug 20 15:05:25 NVIDIA(0): HSD DATAPixx (DFP-0): Internal Dual Link TMDS
(**) Aug 20 15:05:25 NVIDIA(0): TwinView enabled
(II) Aug 20 15:05:25 NVIDIA(0): Assigned Display Devices: CRT-1, DFP-0
(II) Aug 20 15:05:25 NVIDIA(0): Validated modes:
(II) Aug 20 15:05:25 NVIDIA(0): "1280x1024,1280x1024"
(II) Aug 20 15:05:25 NVIDIA(0): Virtual screen size determined to be 2560 x 1024
(--) Aug 20 15:05:25 NVIDIA(0): DPI set to (81, 86); computed from "UseEdidDpi" X config
(--) Aug 20 15:05:25 NVIDIA(0): option
(==) Aug 20 15:05:25 NVIDIA(0): Disabling 32-bit ARGB GLX visuals.

Reading EDID files

A monitor’s EDID file contains information about what video modes (resolutions and refresh rates) it can display. You can get a binary EDID file using nvidia-settings – there’s a button for exporting the monitor’s EDID. To read what’s in that, you need parse-edid, which you can find by googling if it’s not installed on your system.

Downloading Psychtoolbox in Linux

To download and install PTB, you first need Subversion. The PTB webpage contains links to download Subversion for Windows and Mac, but not Linux. I guess this is because there is no standard Linux; it depends on which of the several million versions you have installed. (And geeks wonder why normal people don’t use Linux.) Anyway, I found a helpful guide by Chris Hope for my particular distribution of Linux, Centos 5.5. Oh, by the way, “uname -a” and “rpm -q centos-release” were useful to me in figuring out what that was.

Chris says “First of all go to http://dag.wieers.com/rpm/packages/rpmforge-release/ to work out which package you need to install.” Download that to the desktop or somewhere, then get a terminal up, cd to where you put it, and (as root) type

rpm –install rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Then type

yum install subversion

Now with Subversion installed, fire Matlab up and install PTB using DownloadPsychtoolbox as described on the PTB wiki. NB PTB only works for 32-bit Matlab. I have a 64-bit machine, so to fire up 32-bit Matlab, I type

matlab -glnx86 &

in a terminal window.

Specific issues

Using the Centos 5.5 distribution of Linux with PTB version 3.08, I got the following error with BitsPlusImagingPipelineTest:

>>BitsPlusImagingPipelineTest(1)
??? Invalid MEX-file
‘/toolbox/Psychtoolbox/PsychOpenGL/MOGL/core/moglcore.mexglx’: libglut.so.3: cannot open shared object file: No such file or directory.
Error in ==> InitializeMatlabOpenGL at 160
moglcore(‘DEBUGLEVEL’, debuglevel);

Peter April of VPixx told me he does not get this error on Ubuntu Linux 9.10. It turned out I needed to install the freeglut library – thanks Sean! In the main “Applications” menu, select “Add/Remove software”, go to “Search”, click “all packages” and enter “freeglut”. This came up with 4 hits on my system, freeglut-2.4.0-7.1.e15.i386 and freeglut-devel-2.4.0-7.1.e15.i386 and two more ending in x86_64 instead of i386. I didn’t know which to install; tried x86_64 first of all and still got the error, so then installed the i386 as well and it worked!

5 thoughts on “Psychophysics Toolbox with Linux

  1. Dear Jenny,

    You seem to be using an ancient version of Linux, so it’s a bit like comparing Windows 7 with DOS… Try Ubuntu 10.04, rock solid and easy to use (later versions are less easy to use). All of the stuff you describe above can be done from the GUI. Software installation is done by a couple of mouse clicks in the Ubuntu software centre, NVIDIA-settings has a GUI that allows you to configure your display (writing to the Xorg.conf file is a very outdated way to do things). Keyboard settings also works perfectly from the standard GUI. And why on earth do you use ‘init 3’ to drop into a terminal? Just open a terminal window (again on Ubuntu or any modern GNOME it is trivial and done with a couple of mouse clicks from the desktop menu). PTB on Linux does have its limitations, but the problems you have described above are just due to using outdated software.

    Best of luck!

  2. Thanks Jonas! It’s very good to hear that insight. If I find myself needing to use Linux again, I will try Ubuntu 10.04 as you suggest. But dare I say it, that’s one of the problems with Linux for a non-expert – knowing these crucial details such as “10.04 is rock solid, later versions are less easy to use”. I looked at the PTB wiki and installed the version that seemed to be most widely recommended at the time.

    Re doing things from the GUI, again that’s great to hear but at the time I couldn’t figure out how. As I mention on the page, changing things on the GUI didn’t work whereas editing the xorg.conf file did. I wish I’d had you around to ask at the time!

    All the best,
    Jenny

  3. Actually, to get things to work properly on a dual screen I’ve had to write modlines. The Nvidia panel did not give me the option to run the resolution and refresh rate combination I know my CRT’s can run (probably because it can’t read the EDID through the DVI to VGA converter). The only way to fix that is by adding modlines.

    I am currently looking into using Xubuntu as a stereoscope machine, dual-booting with Windows. Python looks nice too. I’m hoping one day I’ll manage to get it to work, when I have the time! This was very useful information! Thank you!

  4. Hi Arthur,

    Thanks for that valuable input. I’m glad you found the page useful.

    Best,

    Jenny

Leave a Reply

Your email address will not be published. Required fields are marked *