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.
Programming related posts
In this category you will find posts that are related to programming and should be interesting for psychologists, cognitive scientists, and neuroscientists. Well, almost every researcher would probably find some of the information useful at some time!
Every research psychologist, cognitive scientist, and neuroscientist, should know how to program.. Knowing how to program and write scripts will make many of a researchers everyday tasks much easier. For instance, instead of going through line after line of raw data you can write a Python script that runs through each cell in each column. Furthermore, you get the possibility to use more advanced, and cutting edge, statistical techniques by using R statistical programming environment.
Another example might be to create experiments using PsychoPy (either by coding using Python or using the drag-and-drop interface) and the cheap and open-source Arduino microcontroller. Also, coding is fun and relaxing!
I have created a PsychoPy script for the Sustained Attention to Response Task (SART) and a Vigilance Task. Both of the tasks are very similar.…
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
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.
When working with questionnaires that use a Likert scale (e.g., strongly disagree, disagree, neutral, agree, strongly agree) we sometimes want to reverse the scoring. For instance, in a questionnaire subjective experiences of cognition some of the questions can be positively worded (e.g., “I find it easy to read while talking in the telephone at the same time”). However, we often have questions that are negatively worded (e.g., “When there is music in the room I find it hard to concentrate on reading”).
In the case of positively worded questions we can score them like this; strongly disagree with a score of 1, disagree= 2, neutral =3, agree = 4 and strongly disagree =5. However, the same scoring can’t be applied for the negatively worded questions. We now need to reverse the score of these questions. In the python example below, score 5 becomes 1, 4 becomes 2, 2 becomes 4 and 1 becomes 5. Three, on the other hand, (neutral) stays the same.
Python for Data Analysis
I bought the book ‘Python for Data Analysis‘ because I wanted to improve my Python skills. This review of the book is a brief summary of my impressions of it.
How to Install PsychoPy on Linux Mint
Installing PsychoPy on Linux Mint was not straight forward. This is a short guide on how to install PsychoPy on Linux Mint Debian edition. After some searching around on forums and such I found a solution and put it together in one place. PsychoPy is an application written in Python for creating experiments (e.g., for psychology or neuroscience). See my post PsychoPy – Free and Open Source Experiment builder written in Python for my thoughts on the software..
In this post you will find a Python script for randomizing conditions with constraints (i.e., never 2 consecutive trials of X). This script will in a later post be implemented in a cross-modal oddball task created in Psychopy.
I recently started to use Psychopy to build experiments. To build my experiments (mainly oddball tasks) I have, up until I found psychopy, used e-prime. In an oddball task one does not usually present several oddball (typically called “novel” or “deviant”) stimuli in succession. Without getting into detail; I was not able to solve this problem with e-primes scripting language “e-basic” so I made a python script instead. With this script I pre-generated .txt-files that I loaded into e-prime and got my constraints fulfilled.