Page tree
Skip to end of metadata
Go to start of metadata


In our lab, Python is sometimes used for creating behavioral tasks in OpenSesame as well as data processing in Jupyter. Below is some basic stuff regarding python.

Learn Python Basics

If you want to learn the basics of python, and you have no experience programming, you should read the online book Automate the Boring Stuff with Python. The book also has a series of YouTube videos as well, you can find those here.
Before messing with code in OpenSesame programs or a data processing stream, you should at least know these three things:

  1. what are variables (strings, numbers, lists, dictionaries) and how do you use them
  2. what is flow control (if statements, for loops, etc) and how do you use it
  3. what are functions and how do you write a new function and later call it

Reading the first few chapters of the book linked above can teach you those things. If you need to use python outside of OpenSesame you will also need to know how to create a python file and how to run that file (also covered in the book).

Installing Python

You do not need to install python for programming in OpenSesame, but if you need to use Python for a data processing flow, then it needs to be installed. Specifically, we will install Python using the Anaconda distribution - this package basically installs Python along with some useful tools you will need for data processing.

Chances are Anaconda is already installed on the lab computer. To check if it is, open the command prompt by pressing the windows button + R. Then type in cmd and press enter. Now that the command prompt is open, type in conda info then press enter. If you see 'conda' is not recognized as an internal or external command, then Anaconda is not installed. Otherwise, you should see a block of text describing the version of Anaconda installed, and you do not need to do anything.

To install Anaconda, go to this website and follow the instructions: Important note: there are currently two main versions of Python, 2.x and 3.x. When you go to the download page, make sure you download the 3.x version - the 2.x will soon be outdated. As of February 2017, the current 3.x version is 3.6.

Jupyter Notebooks

Jupyter is an application that allows programming interactively with Python and other languages. You may also see it called IPython (interactive python). If you successfully installed Anaconda (see above), then you can now run Jupyter.

Starting Jupyter

To launch Jupyter, open the command prompt (windows key + R then type in cmd). In the command prompt simply type jupyter notebook and it will open up Jupyter in a new tab in your default web browser. Once open, you should see a list of files and folders. You can open the folders by clicking on them. If there is a notebook file in that directory, you can click on it and Jupyter will open the notebook in a new tab (a notebook is just an interactive version of a python script). You can also create a new notebook in the current directory by clicking on the button "New" then selecting Python from the dropdown.

When you are done using Jupyter, it's important to stop running the application. You do this by opening the command prompt that is running, and the pressing ctrl + C. That's it.

If there is a specific directory you want Jupyter to display, you need to do a few other things. First, stop running Jupyter if it is already open. Then you need to change the working directory to the one you want in the command prompt. This website does a good job explaining how to change the directory as well as the drive: Once you have changed the directory to the one you want, launch Jupyter like before by typing in jupyter notebook and it will open displaying the folders and files of that directory.

Data Processing

intro to python:
link to a notebook where I show operations I use for processing

No files shared here yet.

  • No labels