PyCharm vs Spyder: a quick comparison of two Python IDEs

In this post, PyCharm vs Spyder will be compared. If you have followed my blog you may have noticed that a lot of focus have been put on how to learn programming (particularly in Python). I have also written about Integrated Development Environments (IDEs). I think that an IDE may, in fact, be very useful when learning how to code. Of course, when it comes to Python IDEs it may be hard to choose the best one (e.g., PyCharm vs Spyder?).

Spyder is one of my long-time favorite IDEs, and I am mainly using Spyder when I have to write code in Windows environments. However, in one of my blog posts PyCharm was suggested in one comment (see the comments on this post: Why Spyder is the Best Python IDE for Science) that I should test PyCharm.

After testing out PyCharm I started to like this IDE. In this post you will find my views on the two IDEs. E.g., I intend to answer the question; which is the best Python IDE; PyCharm or Spyder?

Continue reading

Step-by-step guide for solving the Pyvttbl Float and NoneType error

In this short post I will show you a quick fix for the error “unsupported operand type(s) for +: ‘float’ and ‘NoneType’” with Pyvttbl. In earlier posts I have showed how to carry out ANOVA using Pyvttbl (among other packages. See posts 1, 2, 3, and 4 for ANOVA using pyvttbl).

However,  Pyvttbl is not compatible with Python versions greater 1.11 (e.g., 1.12.0, that I am running). This may, of course, be due to that Pyvttbl have not been updated in quite some time.

My solution to this problem involves setting up a Python virtual environment (the set up of the virtual environment it is based on the Hitchikers Guide to Python). You will learn how to set up the virtual environment in Linux and Windows.

Continue reading

OpenSesame Tutorial – How to Create a Flanker Task

In this post you are going to learn how to create a simple experiment using the free experiment building software OpenSesame. As I have previously written about, OpenSesame, is an application, based on Python, for creating Psychology, Neuroscience, and Economics experiments. It offers a nice and easy to use interface.  In this interface you can drag-and-drop different objects. This means that you don’t have to know any Python programming at all to create an experiment.

How to create a psychology exeriment using OpenSesame

Continue reading

How to do Descriptive Statistics in Python using Numpy

In this short post we are going to revisit the topic on how to carry out summary/descriptive statistics in Python. In the previous post, I used Pandas (but also SciPy and Numpy, see Descriptive Statistics Using Python) but now we are only going to use Numpy. The descriptive statistics we are going to calculate are the central tendency (in this case only the mean),  standard deviation, percentiles (25 and 75), min, and max.

Continue reading

How to use Python to create an iCalendar file from a Word table

One of the great things with programming is that you can automate things that is boring. As a student I often get schedules in the form of Word documents.

I prefer to have all my activities in a calendar and used to manually put every time in a course into my calendar. Today I got a new schedule and thought: I could probably do this using Python.

After some searching around on the Internet I found the Python packages python-docx and iCalendar. In this post I will show you how to use these to packages to create an iCalender file that can be loaded in to a lot of available calendars.

Continue reading

Python Video Tutorial: Creating a Flanker Task using Expyriment

In this video you learn how to create a Flanker task using the Python package Expyriment. If you don’t know Expyriment it is an open-source library. You can program your experiments and run on Linux, Windows, and OS-x computers as well as on Android devices.

In the tutorial you will get familiar with Expyriment and get to create a commonly used task in Psychology – the Flanker task. In this task, you are to respond on the direction of an arrow surrounded by distractors (arrows pointing in either the same or the other direction). It shows how hard it can be to ignore irrelevant information (arrows pointing in the wrong direction).

Exploring response time distributions using Python

Inspired by my post for the JEPS Bulletin (Python programming in Psychology), where I try to show how Python can be used from collecting to analyzing and visualizing data, I have started to learn more data exploring techniques for Psychology experiments (e.g., response time and accuracy). Here are some methods, using Python, for visualization of distributed data that I have learned; kernel density estimation, cumulative distribution functions, delta plots, and conditional accuracy functions. These graphing methods let you explore your data in a way just looking at averages will not (e.g., Balota & Yap, 2011).

Kernel density estimation, Cumulative distribution functions, Delta plots, and Conditional Accuracy Functions
Kernel density estimation, Cumulative distribution functions, Delta plots, and Conditional Accuracy Functions

Required Python packages

I used the following Python packages; Pandas for data storing/manipulation, NumPy for some calculations, Seaborn for most of the plotting, and Matplotlib for some tweaking of the plots. Any script using these functions should import them:

Continue reading

Best Python libraries for Psychology researchers

python-logo-master-v3-TM

Python is gaining popularity in many fields of science. This means that there also are many applications and libraries specifically for use in Psychological research. For instance, there are packages for collecting data & analysing brain imaging data. In this post, I have collected some useful Python packages for researchers within the field of Psychology and Neuroscience. I have used and tested some of them but others I have yet to try.

Continue reading

E-prime how-to: save data to csv-file using InLine scripts

In this post I will describe, shortly, how to use InLine scripts in E-prime to save your data in comma-separated values (CSV) files. For those who are not familiar with E-prime it is an experiment generating software based on visual basic (i.e., it has its own scripting language called e-basic). Its main purpose is to make building experiment easy/easier. It offers a drag-and-drop graphical user interface (GUI) which is fairly easy to use (although I prefer OpenSesame and PsychoPy – which both offers drag-and-drop GUIs). See the Wikipedia article if you want to know more about e-prime.

This guide will assume that you have worked with e-prime before. That is, you should already have a, more or less, ready experiment that you can add the scripts to.  In the guide I use a Simon task created in e-prime as an example.

Continue reading

PsychoPy video tutorials

PsychoPy, as I have previously written about (e.g., Free and Useful Software and PsychoPy tutorial) is really a great Python tool for creating Psychology experiments. You can write Python code by either using  “code view” or import the package in your favourite IDE.  Furthermore, you can use the builder mode and just drag and drop different items and PsychoPy will create a Python Script for you. If needed inline scripts (in Python, of course) can be inserted. That is, you can combine drag-and-drop building with some coding. In this post I have collected some tutorial videos that can be useful for someone unfamiliar with PsychoPy.

I created a playlist with 4 youtube tutorials. In the first video you will learn how to create a classical psychology experiment; the stroop task. The second is more into psycholinguistics and you will learn how to create a language experiment using PsychoPy. In the third you get to know how to create text input fields in PsychoPy. In this tutorial inline Python coding is used so you will also get to know how you may use programming. In the forth video you will get acquainted with using video stimuli in PsychoPy.

 

Programming for Psychology & Vision Science Tutorial series

Recently I found the following playlist on youtube  and it is amazing. In this series of tutorial videos you will learn how to use PsychoPy as a Python package. For instance,  it is starting at a very basic level; importing the visual module to create windows. In this video he uses my favourite Python IDE Spyder. The videos are actually screencasts from the course Programming for Psychology & Vision Science and contains 10 videos. The first 5 videos covers drawing stimuli on the screen (i.e., drawing to a video, gratings, shapes, images, dots). Watching these videos you will also learn how to collect responses, providing input, and saving your data.

 

That was all for now. If you know more good video tutorial for PsychoPy please leave a comment. Preferably the tutorials should cover coding but just building experiments with the builder mode is also fine.  I may update my playlist with more PsychoPy tutorials (the first playlist).