PSYC770: Python for Experimental Psychologists
Fall 2022
Last updated 12/4/2022

Session

   Description

Assignment
8/23-25 Overview of the course and the Python ecosystem for behavioral research
Installation of PsychoPy standalone software (Windows 64-bit) with Python 3
Peirce Chap. 1
     
 

Introduction to PsychoPy Development

PsychoPy Tech Manual
[12 MB]
8/30 Using the Builder graphical interface to specify a simple experiment (Stroop paradigm) Peirce Chap. 2
9/1 Building a simple experiment using images as stimuli (Glasgow Face Matching Test) Peirce Chap. 3
9/6 Implementing visual stimulus presentations with video-frame accuracy and precision (Posner Cueing paradigm) Peirce Chap.4
9/8 Dynamic animation of stimulus size, location and color (as a function of Routine-level clock time) Peirce Chap. 5
9/13 Using GUI-based ratings scales and programmable response buttons ('Big 5' Personality Inventory) Peirce Chap. 7
sliders.zip colorWheel.zip
9/15 Mouse-based input and selection (Visual search paradigm) Peirce Chap. 9
9/20 Block randomization and counter-balancing methods Peirce Chap. 8
  Multimedia: Sound clips and movies movie.zip   sounds.zip
9/22 Using Python code extensions to provide trial-by-trial response feedback Peirce Chap. 6
     
 

Introduction to Python Programming

Manual: A Byte of Python
[338 KB]
9/29 Exploring PsychoPy's Coder interface window and the Python3 IDLE interpreter Video Intro to Python
10/4 Python 4 - Basics:
Variables, data types, objects, and code blocking via indentation
 
10/6 Python 5 - Operations:
Math operators, order of operations and logical operators
 
10/11 Python 6 - Control Flow
If...elif blocks, while blocks and for...loops [with a preview of 'iterators']
Homework Assignment 1
10/13 Python 7 - Functions
Subroutines, input arguements and return values
 
10/13 Python 8 - Modules and Python 14 - Python Standard Library:
Importing external functions/libraries that extend the Python language and functionality
function_examples
numpy_examples
... Python 9 - Data Structures:
Lists, Tuples, Dictionaries and Sequences
list_comprehensions
10/18 Python 12 - File Input/Output      csv_writer   csv_reader   CSV Module Documentation   pickling read_stroopConditions
csv_read_stroopConditions
stroopConditions.csv
    Homework Assignment 2
  Python Instrumentation Interfacing  
10/27 Digital I/O: Legacy parallel port (LPT:) interfacing parallel_test.py
LPT Output Benchmark
LPT Benchmark Data
plot_lpt_output_latency.py
LPT Benchmark Results
11/1-11/8 USB-based digital I/O (using the UM245R serial-to-parallel interface)             trigger_circuit
Benchmarks: usb-input-latency.py   usb-output-latency.py   input results   output results
Note: Copy UM245R.py to the C:\Program Files\PsychoPy\Lib\site-packages folder
UM245R
UM245R.py
test_UM245R.py
11/8 USB-based legacy serial communications (COM1:) interface (reading the Minola CS100A colorimeter/photometer)  
11/10 TCP/IP communication between computers:  UDP client-server and TCP client-server applications UDP Data Transfer Client
UDP Data Transfer Server
11/10 Python analog data acquisition (Labjack ADC/DAC applications; electrophysiological data acquisition)
  Simple Python GUI example   dialog.py  
     
  Benchmarking Temporal Accuracy and Precision
Using Microcontroller-based Systems
 
11/15 The problem: MS-Windows, macOS and Linux are NOT real-time operating systems
How microcontrollers solve the time management dilema.
 
11/15 Arduino Uno microconroller system and programming development environment (ATMega32U4) Arduino Pro Micro
11/17 Developing and uploading Arduino programming  
  Measuring the latency of parallel port and USB-based digital I/O lines  
11/29 Measuring PsychoPy stimulus display timing using the Arduino and a simple light-sensitive sensor
         Display Duration Python        Display Duration Arduino
Display Benchmark Setup
Oscilloscope Timing
Display Latency Python
Display Latency Arduino
12/1 Characterizing the temporal latency of USB-based keyboard input (generalizable to USB mouse and joysticks)   Circuit Keyboard Latency Python
Keyboard Latency Arduino
12/6 Measuring the temporal latency of PsychoPy sound stimuli          Benchmark Circuit Sound Latency Python
Sound Latency Arduino
  How to Read Putty Benchmark Logs and Compute/Plot Results
Arduino-to-Python Serial Data Transfer Demo
How to Send a Serial Command Character from Python to Arduino
Arduino Random Number Generation
 

Notes
Companion website for PSYC770 can be found at http://moundtop.com/psyc770/
The latest version of this syllabus is available at http://moundtop.com/psyc770/psyc770-syllabus.html

Deliverables
Select homework exercises will require completed work to be submitted to the instructor.
Each student must develop a plan for an experimental project and successfully implement PsychoPy/Python code that implements the project.  The proposal for this project must be approved by the instructor prior to initiating work.  Project proposals are due November 8, 2022.  Final projects are due by the last day of class.

Grading
50% Homework Assignments; 50% Final Project

Required Texts:

Peirce, J. & MacAskill, M. (2018). Building experiments in PsychoPy. Thousand Oaks, CA: Sage Publishing.
ISBN: 978-1-4739-91393-2
 

Swaroop, C.H. (2005). A byte of Python.
A free Internet-based tutorial introduction to the Python programming language.
(See the appropriate link listed above to access this document)