2. Software Installation

We explain below how to install:

  • a code editor: Sublime text

  • a version control system: Git

  • the statistical programming language: R

  • its integrated development environment: RStudio

  • Python and several useful modules, including Expyriment,

  • the Psychtoolbox-3 for vision and neural sciences.

After the installation, `check`_ that everything works.

Warning

  • You will need to download several GB of software from the Internet. Therefore, make sure to have a decent connection.

  • Make sure that you have at least 5GB of free space on your hard drive to unpack the various software.

  • You will need to have administrator rights to install some of the software. If you are using a computer from an institution, check with the IT support team.

2.1. Instructions for Windows (WSL)

This is the simplest, and therefore recommended, method.

You need to install Ubuntu Linux on your Windows system, using the Windows Subsystem for Linux (aka WSL).

  • If you have Windows 11:

    1. Install the vGPU driver for your graphics card (Intel, AMD or Nvidia) 2 if it not already installed.

    2. Launch “Windows PowerShell” as administrator, and execute the command:

      wsl --install -d ubuntu
      
  • If you have Windows 10, follow these instructions. (You may have to enable Hyper-V)

This downloads the full Ubuntu Linux distribution which may take a while. Some versions of Windows may even ask you to reboot during the installation process. At some point during the install, a new Terminal window entitled “Ubuntu” will open and will require a new user name and password. You can type anything but it is crucial that you note down the password as it will be needed to install software under Ubuntu.

Note

Detailed information about the WSL is available at https://docs.microsoft.com/en-us/windows/wsl/ In particular, if anything goes wrong during the installation check the Troubleshoting WSL section.

When the WSL installation is finished, go to the linux section in order to install the required software.

2.2. Instructions for native Windows (without WSL)

This approach is not recommended because it has several pitfalls (if you do not carefully follow the instructions, many things will not work correclty). Yet, there are two reasons why one may want to follow this path:

  • WSL does not work on your machine (for example, your CPU does not allow virtualization).

  • You are concerned by potential overheads of the WSL (yet, read this).

2.2.1. R and Rstudio

R is a programming language specialized for statistical data analyses; Download and install it from https://cran.rstudio.com/bin/windows/base/

Rstudio is an Integrated Developpement Environment for R which greatly simplifies the use of RMarkdown. You can download and install the latest version of RStudio Desktop from https://www.rstudio.com/products/rstudio/download/.

2.2.2. SublimeText code editor

Download and install Sublime Text.

[Note: If you prefer to stick to opensource software, you can try Atom, but be aware that it is slower and more buggy than Sublime Text.]

2.2.3. Anaconda Python3 distribution

There exists various Python distributions. Under Windows, we recommend the Anaconda3 distribution as it already contains most of the packages needed for cognitive science.

  1. Go to <https://www.anaconda.com/products/individual>, click on Download and select the 64-bit installer for iWindows.

  2. Execute the Anaconda3 installer. During the installation.
    • If you are on a Mac, you can accept all the default for the proposed options.

    • If you are under Windows, pay close attention to the following options:

      • verify that you Install for Just Me (recommended), then click on Next

      • Accept the default Destination folder and click on Next

      • VERY IMPORTANT: Check the boxes in front Add Anaconda to my PATH (ignore the warning that this is not recommended) and Register Anaconda as my default Python and click on Install

      • upon completion, click on Next, then Finish

2.2.4. The Git version control system

Git is a version control tool for software development, an indispensable tool to do reproducible science.

Download the 64 bit version of Git for Windows and launch it.

  1. When the GNU Licence is displayed, press Next;

  2. Accept the default installation folder and press Next;

  3. Accept all the Components selected by default and press Next

  4. Accept the creation of a start menu folder named ‘Git’: press Next;

  5. VERY IMPORTANT: When proposed a default editor, select ‘Use the nano editor’ (unless you want to learn Vim)

  6. VERY IMPORTANT: When proposed to adjust the PATH environment variable, tick the box “Use Git and optional unix tools from the command line prompt”.

You can accept all other defaults.

Now, to finish the installation of git, start Git bash (use the “Search box”)

Then, type the following command lines, making sure to replace your_first_and_last_name_here and your_email_here by the relevant personal information:

git config --global user.name "your_first_and_last_names_here"
git config --global user.email your_email_here
git config --global core.editor nano

You can close the Terminal by typing the command exit or, faster, by pressing Ctrl-D, or by just closing its window.

2.2.5. The Pygame and Expyriment python modules

We will rely on the Pygame module to create stimuli and the Expyriment Python Library to program behavorial experiments.

Start Git bash and, in the openned Terminal, type:

pip install expyriment[all]

2.2.6. Learn to use Sublime Text and Git Bash Terminal to create Python scripts

Watch the video at https://www.youtube.com/watch?v=2yhcWvBt7ZE&t and try to perform the activities in it (the insturctions walso work for Mac or Linux: you just need to open a standard Terminal when in Windows you need to start ‘Gih Bash’). Note: the game scripts mentioned in the video are available at https://github.com/chrplr/PCBS/tree/master/games/games.zip

Now you should check if everything works, following the instructions in chapter Check your installation.

2.3. Instructions for MacOS X

2.3.1. SublimeText code editor

A code editor is a program that allows you to edit pure text files such as Python programs, Markdown or LaTeX documents, etc.

Unless you already use a code editor that you are familiar and happy with, we recommend that you download and install Sublime Text. Follow the instructions specific to MacOS.

2.3.2. The Git version control system

Download and install Xcode, either from the App store, or by using the command line xcode-select --install. This will provide git.

To finish the installation of git, open a Terminal window 1 and type the following command lines, making sure to replace your_first_and_last_name_here and your_email_here by the relevant personal information:

git config --global user.name "your_first_and_last_names_here"
git config --global user.email your_email_here
git config --global core.editor nano

2.3.3. The R statistical software

Download and install the latest version of R from https://cran.rstudio.com/bin/macosx/

2.3.4. Rstudio Desktop

Download and install the latest version of RStudio Desktop from https://www.rstudio.com/products/rstudio/download/. Make sure to select the MacOS version!

2.3.5. Python

Download and install Anaconda3 Python from https://www.anaconda.com/products/individual

2.3.6. The Pygame and Expyriment python modules

  1. Install XQuartz. Download the .dmg file from the official website and open it to install.

  2. Open a Terminal and type /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" to install Homebrew (which is needed to install SDL).

    • If you see “Password: “, this means the Terminal is prompting you to type your computer’s administrator account password. Type your password and press the return key to continue.

    • If you see an error message such as “Error: /usr/local/Cellar is not writable. You should change the ownership and permissions of /usr/local/Cellar back to your user account: sudo chown -R $(whoami) /usr/local/Cellar”, run in the Terminal the command that was suggested (here sudo chown -R $(whoami) /usr/local/Cellar), and then run the previous command to try installing Homebrew once again

  1. In the same Terminal, type brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf pkg-config to install SDL (which is needed to install expyriment). This may take a while.

  2. In the same Terminal, type pip install "expyriment[all]" to install expyriment.

  3. In the same Terminal, type pip install -U pygame to upgrade pygame (version >= 2.0 is required on recent versions of macOS, but this must be done after installing expyriment otherwise the install of expyriment will fail).

Now you should check if everything works, following the instructions in chapter Check your installation.

2.4. Instructions for Linux (Ubuntu 20.04)

Open a Terminal 1.

Then, for each software section below, copy and paste in the terminal the lines that are in the boxes and press Enter to execute them.

2.4.1. Python3

Python is the main programming language used in these courses. The following commands install various modules that will be needed.

sudo apt  install -y python3 ipython3 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

sudo pip install expyriment[all]

sudo apt-get install -y python3-dev libasound2-dev
sudo pip install simpleaudio

2.4.2. Git

Git is a free distributed version control system.

sudo apt install git -y

Now, type the following command lines, making sure to replace your_first_and_last_name_here and your_email_here by the relevant personal information:

git config --global user.name "your_first_and_last_names_here"
git config --global user.email your_email_here
git config --global core.editor nano

2.4.3. Sublime code editor

Sublime Text is a powerful text editor with a good Python mode. To install it:

wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-get install apt-transport-https -y
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text -y

(if this does not work, check the latest instructions from https://www.sublimetext.com/docs/linux_repositories.html)

Note

Atom or Visual Studio Code. are two fine code editors too. If you prefer to use one of these instead of Sublime Text, this is perfectly fine.

2.4.4. R language for statistics

R is a free software environment for statistical computing and graphics.

sudo apt update -qq
sudo apt install --no-install-recommends software-properties-common dirmngr -y
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
sudo apt install --no-install-recommends r-base -y
sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+

(in case of trouble, check the latest instructions at https://cran.rstudio.com/bin/linux/ubuntu/)

2.4.5. Rstudio Desktop

Rstudio is an Integrated Developpement Environment for R which greatly simplifies the use of RMarkdown. You can download and install the latest version of RStudio Desktop from https://www.rstudio.com/products/rstudio/download/. Make sure to select the ubuntu version!

wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-2022.02.1-461-amd64.deb
sudo apt install ./rstudio-2022.02.1-461-amd64.deb -y

2.4.6. Psychtoolbox

Psychtoolbox-3 is a set Octave functions which is very popular in vision and neuroscience research. This installation is optional as the Psychtoolbox is not used in this book.

First, add the [Neurodebian](https://neuro.debian.net/) repository.

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

Then activate the sources and install the required packages:

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

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

Download the psychtoolbox installation script:

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

mkdir ~/PTB3

Finally, start octave and, on Octave’s command line, type:

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

# test
DrawingSpeedTest()

Now you should check if everything works, following the instructions in chapter Check your installation.


1(1,2)

To open a Terminal:

  • Windows with the WSL: launch the “Ubuntu” app.

  • Windows with Git for Windows: launch “Git bash”.

  • Linux: Launch Terminal or press Ctrl-Alt-T (Gnome or Xfce) or Win-Return (i3).

  • MacOS: Type terminal in the Spotlight search field. Alternatively, you can open a Finder window and select the Application folder, then the Utilities folder, then double-click on the Terminal icon..

2

To determine which type of GPU (Intel, AMD, Nvidia) is installed on your computer, under Windows, open the Task Manager, e.g. with Ctrl-Alt-Del, and search for GPU under the Performance tab.