Fundamentals of data and coding for psychology

Welcome to this series of classes on the fundamentals of data and coding for psychology as part of the Research Internship (PSYC3361) course at UNSW Sydney.


Introduction

Research in psychology typically involves considerable involvement with symbolic representations of information: termed digital data, or just data. Such data is often essential to both conducting research and as the basis of the research outputs. Indeed, our daily lives also typically involve many interactions with data.

In these classes, we will consider data from the fundamental level. Along the way, you will learn some skills in computer programming (in a language called Python).

The ultimate aim is to increase your 'digital literacy'—not in the sense of being able to use digital platforms, but instead to see and think in terms of underlying digital representations.

The specific overall objectives of these classes are for you to be able to:

These classes are also intended to be a forum for discussing science and research with me and your peers, so please feel free to raise any questions you would like to discuss.

The material and class structure are also new this year, and there is scope for tailing the content to specific requests—let me know if there is a topic you are particularly interested in us covering.


Lessons

N.B. see Importing a notebook below for how to import these into your project.


Using the notebook platform

We will be using an online computing platform called Jupyter notebooks during these lessons. Notebooks are a way of combining prose with executable computer code and its output within a single document.

In particular, we will be using a service provided to UNSW called "Microsoft Azure Notebooks". Note however that everything we will be using is free software that you can download and run on your own computers—we are doing it this way to simplify the setup and get up and running as easily as possible.

Logging in

To login to the system:

  1. Visit Microsoft Azure Notebooks.
  2. Click Sign In in the top right corner.
  3. Enter your UNSW account information in the form of zXXXXXXX@ad.unsw.edu.au.
  4. Enter your usual UNSW password.

Creating your project

When you access the notebook interface for the first time, you will need to create a 'project' to hold the notebooks that you will be working on.

To create a project:

  1. Click on the … create one now? link that should be shown on your "My Profile" page.
  2. In the resulting dialog box, give your project a name such as internship.
  3. Untick the Public checkbox, if it is selected.
  4. Untick the Initialize this project with a README checkbox, if it is selected.
  5. Click Create.

This only needs to be done once—we will use this project to store all the lesson material.

Importing a notebook

To import a notebook:

  1. Right-click on the appropriate notebook link in the Lessons section of this site and select Copy link address.
  2. On your project page in Azure Notebooks, click on the Upload button and then select From URL.
  3. Paste from the clipboard (e.g., right-click and select Paste) into the File URL box.

Note that importing the notebook makes it 'yours'—the changes you make won't affect any other notebooks.

Received an error?

Sometimes it doesn't seem to like importing directly from a website. If you receive a message like Error while downloading notebook: Notebook does not exist at target URL, or target site has not given us permission to download it., you can instead:

  1. Again right-click on the appropriate notebook link in the Lessons section of this site, but this time select Save link as to save the file to your local computer.
  2. On your project page in Azure Notebooks, again click on the Upload button but now select the From Computer option.
  3. Click on the Choose files button and navigate to where you saved the notebook file in the first step.
  4. Click Upload

Creating a new notebook

To create a new (blank) notebook:

  1. From within your project in Azure Notebooks, click on the New button and then select Notebook.
  2. In the resulting window, give your notebook a name (which sets the name of the file) and select Python 3.6 as the "Language".
  3. Click New to create your notebook. It will then appear in the list of notebooks associated with your project, and you can click on it to open it up.

Exporting a notebook

It is useful to be able to export the contents of a notebook out of the Azure Notebooks platform. To do so:

  1. Ensure that all cells have been run and have produced the desired output.
  2. Inside your notebook, select FileDownload asHTML (.html).
  3. This will save it as a self-contained HTML file, which you can then view in a web browser or use—for example, you can include it in an attachment to a forum post or log entry.

Note that the interactive capacities of the notebook are not available in the exported file.


Resources of interest

Programming for psychology in Python
My other set of programming lessons.
Teaching programming in undergraduate psychology
Video of a talk I gave at a Python conference a few years ago.
Psych-DS; A technical specification for psychological datasets
Draft specification of a standard for the formatting of psychology datasets.
Every Psychologist Should Learn Programming
Blog post about programming in psychology.
Why every (psychology) student should learn to code
Blog post about coding for psychology students.
Why Jupyter is data scientists’ computational notebook of choice
Article about the 'notebooks' we are using in this class.
Best practices for scientific computing
Article about computing in research.
Good enough practices in scientific computing
Follow-up article to the previous listing, with more recommendations for beginners.
The Information: A History, a Theory, a Flood
Book about the history of 'information' and binary coding.
The Idea Factory: Bell Labs and the Great Age of American Innovation
Book about Bell Labs (an American telephone company) and their advances in digital coding.
Code: The Hidden Language of Computer Hardware and Software
Book about coding from the fundamental level—a similar but much deeper approach to what we have taken for these classes.
Turing's Cathedral: The Origins of the Digital Universe
Book about the history of digital coding.