Skip to content

Instantly share code, notes, and snippets.

@chrplr
Last active June 20, 2022 08:26
Show Gist options
  • Save chrplr/61ec2de7f0e001ebf65aec89e6f6ddc9 to your computer and use it in GitHub Desktop.
Save chrplr/61ec2de7f0e001ebf65aec89e6f6ddc9 to your computer and use it in GitHub Desktop.
psychology-stimulation-software-on-linux

Installing a Linux workstation with psychtoolbox, psychopy, expyriment

Author: christophe@pallier.org

Date: 05 Nov 2021

Warning: These instructions work for Ubuntu 20.04 LTS focal (will probalby need some modifications for another Ubuntu distribution)

Install some basic packages

sudo apt update
sudo apt upgrade -y

cat >packages.txt <<EOF
build-essential
linux-lowlatency
vim
emacs
git
subversion
mc
tmux
openssh-server
htop
octave
ffmpeg
python3
python3-dev
python-is-python3
python3-future
python3-opengl
python3-pip
python3-ipython
python3-pygame
python3-numpy
python3-matplotlib
python3-skimage
python3-pandas
python3-scipy
python3-imageio
python3-ipython
libportaudio2
libportmidi-dev
libsdl-image1.2-dev
libsdl-mixer1.2-dev
libsdl-ttf2.0-dev
libsdl1.2-dev
libsmpeg-dev
libportmidi-dev
libswscale-dev
libavformat-dev
libavcodec-dev
libfreetype6-dev
libsdl2*
libsdl1.2*
libdc1394-22-dev
libfreenect*
libgstreamer1.0-dev
libgstreamer-plugins-*
libusb-1.0-0-dev
portaudio19-dev
libasound2-dev
EOF
                    
xargs -a packages.txt sudo apt install -y                     

Expyriment

Using the system's python3 (recommended)

pip install numpy pyopengl pygame future mediadecoder pyserial pyparallel swig
pip install expyriment[all]

With Anaconda Python

Download and install Anaconda Python

LATEST_ANACONDA=Anaconda3-2022.05-Linux-x86_64.sh
wget https://repo.anaconda.com/archive/${LATEST_ANACONDA}
chmod +x ${LATEST_ANACONDA}
./Anaconda3-2022.05-Linux-x86_64.sh 
conda update -n base -c defaults conda

Expyriment environment

conda create -n expyriment python=3.8
conda activate expyriment
conda install ipython numpy pyopengl
pip install mediadecoder
pip install sounddevice
pip install expyriment[all]

If pip install experiment[all] fails (typically because of problems while trying to compile pygame1.9.6), try:

mkdir ~/git
cd ~/git
git clone https://github.com/expyriment/expyriment.git
cd expyriment/
pip install .

Checking expyriment

conda activate expyriment # only if you used anaconda installation 
expyriment -T

Setup blocking on vertical synchro for AMD RADEON gpu

cd ~/git/PCBS/experiments/expyriment
python tearing-test.py
sudo apt install xvattr
echo "export vblank_mode=3" > /etc/profile.d/radeon.sh
cd ~/git/PCBS/experiments/expyriment
python tearing-test.py

Note: for nvidia GPU, see https://learn.foundry.com/hiero/current/content/timeline_environment/usingviewer/synching_vblank.html

Psychopy

sudo apt-get install libusb-1.0-0-dev portaudio19-dev libasound2-dev
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu bionic main universe'
sudo apt install -t bionic libwebkitgtk-1.0-0

# if you prefer to use the system's python3
pip install swig psychopy

# if you prefer to use anaconda python:

wget https://raw.githubusercontent.com/psychopy/psychopy/master/conda/psychopy-env.yml
conda env create -n psychopy -f psychopy-env.yml
conda activate psychopy
conda install ipython numpy

Test

psychopy

Psychtoolbox

Add Neurodebian repository

Select the neurodebian repository on Neurodebian, and copy the command lines, e.g., For Ubuntu 20.04:

wget -O- http://neuro.debian.net/lists/focal.de-m.full | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list
sudo apt-key adv --recv-keys --keyserver hkps://keyserver.ubuntu.com 0xA5D32F012649A5A9

activate sources and install required packages

sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt update

sudo apt build-dep octave-psychtoolbox-3
sudo apt install subversion libdc1394-22-dev libfreenect* libgstreamer1.0-dev libgstreamer-plugins-*

download psychtoolbox

wget https://raw.github.com/Psychtoolbox-3/Psychtoolbox-3/master/Psychtoolbox/DownloadPsychtoolbox.m.zip
unzip DownloadPsychtoolbox.m.zip 

mkdir ~/PTB3

octave
> DownloadPsychtoolbox('/home/neurostim/PTB3')
> PsychLinuxConfiguration()

> # test 
> DrawingSpeedTest()
@SophieHerbst
Copy link

@chrplr your recipe is saving me a lot of time, thanks!
Just a quick update: I encountered an error during the installation of psychopy, which I could fix by installing swig.
It also complained that some packages (numpy, pandas, chryptography, python-gitlab) were too old, so I updated them manually.

@chrplr
Copy link
Author

chrplr commented Jun 20, 2022 via email

@SophieHerbst
Copy link

Hi Christophe, the pip install swig did it for me without any problems!

@chrplr
Copy link
Author

chrplr commented Jun 20, 2022 via email

@SophieHerbst
Copy link

the system's

@chrplr
Copy link
Author

chrplr commented Jun 20, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment