Python for Experimental Psychologists

Python for Experimental Psychologists is a book that is targeted at people in Experimental Psychology or Cognitive Neuroscience, who have no previous experience with Python or programming. It is suitable for students and staff, and aims to provide a basic working proficiency in Python. After working your way through the book, you will have the knowledge and skills required to script experiments and analyses. You can order the book from Routledge’s website.

Dalmaijer (2016) Python for Experimental Psychologists

Supporting materials

Occasionally, the book refers to files on a support website. You can find those below, organised per chapter. You can also download them in one big ZIP archive (those are files with a .zip extension).

If you’re unfamiliar with ZIP archives, here’s come background. Archives are essentially compressed folders that contain files. After downloading them from this website, you’ll need to extract them before you can use them. Fortunately, that’s not a difficult thing to do! On Mac OS X, double-clicking the archive will automatically extract the files. On most Linux distributions, you can right-click on the archive, and then select ‘Extract here‘. On Windows, you could also right-click on the archive, and select ‘Extract All…‘.

Alternatively, you can extract the files from an archive using a tool like 7-Zip. After installation, you can open archives in 7-Zip. You can also right-click on the .zip file, then select ‘7-Zip‘, and ‘Extract here‘.

WinPython PyGaze

If you’re a Windows user, you could use a completely portable version of Python. It doesn’t require any installation; just download the package, and then unzip it.

All-in-one

Download all files in one ZIP archive. After downloading the archive, make sure you extract it properly (for example with a tool like 7-Zip, which is explained above).

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Make Some Noise 1 (visual)

Make Some Noise 2 (sound)

Make Some Noise 3 (musical instrument)

Reference

  • Dalmaijer, E.S. (2016). Python for Experimental Psychologists. Abingdon, United Kingdom: Routledge (part of Taylor and Francis Group). More information, and ordering.

3 Comments:

  1. Hi Edwin,
    I’ve been reading your book to learn python (it is clear and interesting!) and bumping into problems.

    I followed instructions in the book to build the experiment, and it worked fine before ‘Logging values’. After adding codes in that section, Spyder crashed right after I entered the participant name and hit ‘Enter’. I tried to open the script with interpreter (Using WinPython interpreter) and it crashed too. Though I corrected every parts in my script, it did not work.
    The Whole_experiment_Pygaze script (answer in chapter 5) crashed in the same way. I’m really confused…
    Any ideas?

    I’m using Windows 10 and WinPython-PyGaze-0.5.1 downloaded here to program.

    Many thanks,
    Elliot

    • Hi Elliot,

      Thanks for buying the book! Sorry you’re running into troubles, but I’m sure we can solve them :)

      The code in the book has been tested very thoroughly, but just to make sure, I’ve downloaded the package and the scripts from here. When running them on Windows 7, everything runs smoothly. So I’m sure that the code is fine.

      Let’s start fixing your issues by going through the basic steps to run the whole experiment from Chapter 5 (PyGaze version):

      1. It’s never a good idea to run whole experiment scripts through Spyder’s console. As the book explains, it’s better to use the Command Prompt or a batch file.
      2. The WinPython Interpreter is a Python interpreter. You’re better of using the WinPython Command Prompt instead.
      3. Launch ‘WinPython Command Prompt.exe’
      4. Type the following command:
        python "PATH\experiment.py"
        Where PATH should be replaced by the actual path to your experiment.py file, for example: C:\Users\Elliot\Documents\PEP_Chapter_05_code2_Whole_experiment_PyGaze
      5. After hitting Enter, your experiment should run (starting with a prompt for the participant name, and then opening the experiment window).

      As I said, that all works on my Windows 7 machine here, just using the downloaded WinPython package and experiment scripts. If it doesn’t work for you, please include screen captures of error messages etc., as we will need those to diagnose the issue.

      Good luck!

      • Hi Edwin,

        Sorry for late response, the experiment runs as expected now!
        Thank you for the detailed explanation!

        Many thanks,
        Elliot

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="">