PyBrain workshop

This page is for those attending the Python Introduction (2 and 3 November) as part of the PyBrain workshop at the MRC Cognition and Brain Sciences Unit. Thanks to Johan Carlin for organising this series of virtual training sessions!

The Python Introduction will be a virtual event, using online tools to run Python code. Specifically, we’ll use Jupyter Notebooks through the fabulous MyBinder website. This means that attendees do not have to install anything locally.

However, if you’d like to run things on your own computer, this is possible too! It would entail installing the Anaconda distribution of Python, and copying bits of code from our workbooks into your own Python interpreter.

Python installation

  1. Download and install Anaconda. This is a Python distribution. Please select the version for your operating system (Windows and macOS are supported; Linux users already have Python versions installed). Also make sure you grab version 3.8, 64-bit.
  2. When prompted, make sure you ask the installer to make this your default Python installation. (NOTE: This is assuming you do not already have a Python installation up and running. If you do, you don’t have to install Anaconda!)
  3. Open a command prompt or terminal. See below for OS-specific instructions.
    1. Windows: Go to the folder where you installed Anaconda, for example C:\Anaconda27, and double-click on the programme called “Anaconda Command Prompt”.
    2. Linux: Open a Terminal.
    3. macOS: Type “Terminal” in the spotlight search, and hit Enter.
  4. If you didn’t install Anaconda, but instead used a distribution that was already on your computer, make sure you install the following packages too by running the following command in your command prompt/terminal:
    pip install numpy
    pip install scipy
    pip install matplotlib
  5. Install pygame by running the following command in your command prompt/terminal:
    pip install pygame
  6. Install PsychoPy by running the following commands in your command prompt/terminal:
    pip install pyglet
    pip install json_tricks
    pip install future
    pip install psychopy
  7. Install PyGaze by running the following commands in your command prompt/terminal:
    pip install python-pygaze

Where next?

If you liked the taste of Python, there are a few options to continue learning.

A Byte Of Python is a free eBook that has an extensive overview of the language. Learn Python The Hard Way is a similar resource. A lot of the concepts these books introduce are not necessarily relevant for an experimental psychologist or cognitive neuroscientist, so feel free to be somewhat particular about which sections you read.

A more targeted resource is the book Python For Experimental Psychologists. It was written specifically with cognitive experiments in mind, and is therefore a good start for any researcher in experimental psychology or cognitive neuroscience. Note that this version is for Python 2.7; an updated edition is expected next year.

Another great resource is the book Python Machine Learning. It has a more advanced scope, and you should definitely already be familiar with Python before sinking your teeth in it.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">