Press "Enter" to skip to content

Month: November 2015

Free & Useful Software – PsychoPy

PsychoPy

This post will describe why I prefer using PsychoPy before other software. When I started getting involved in research (i.e., when doing my Bachelor’s and Masters theses) I used the software that was accessible for me. That is, some of the most commonly used software at the department I was studying at. After starting my Ph.D. studies I got more and more annoyed with one of the software we used to build experimental tasks¬† in (i.e., E-prime).

First, I was not familiar with the scripting language (called ‘e-basic’) that was needed, for instance use, to solve pseudo-randomization, and for sending signals to a specially built device I was going to use in my experiments. Second, I prefer to use Linux systems and e-prime is limited to Windows. In fact, e-prime seemed to be working best Windows Vista or earlier but our lab computers were, and are, running Windows 7 (might have changed since back then). Some time into my Ph.D. studies I found PsychoPy which is written in Python, a programming language that I did know, and it seemed like a good alternative to e-prime, and other similar software, to create experiments in.

Another Python script for randomization with constraints

Here you will find a Python function for randomization with constrains. This was written, specifically, for a psychological experiment (a shifting/task-switching task) I was planning to conduct. For this experiment, I needed a list of stimuli names that were quasi-randomized.  Fifty percent of the items in the list are followed by a stimulus in the same colour and the remaining 50 % are followed by a stimulus in a different colour.

Python script

Collecting data with Scrapy

This rather long (counting the Python code) tutorial assumes that you are interested in scraping data off the web using Scrapy. It might also be limited to Linux.

Scrapy can be installed using pip:

pip install scrapy

To create a new Scrapy project open up a terminal and create a directory where you will store your Scrapy projects and change do that directory and run this (change ‘psysci’ to whatever your project will be named):


scrapy startproject psysci

 

Item

We start with the Item class and create an object to store our scraped data in. In my example I scrape the article title, type of article, the articles abstract, when the article was received and when it got accepted for publication, which year it was publicized (and month) and the articles keywords.