How does a cognitive science researcher end up using Python?
In cognitive science we often create experiments that put participants through a specific sequence of events. Then we look at how they respond to these events and draw conclusions about the thought process.
For example in my current research project I am looking at how hue color memory changes over time. To do this I need to precisely control the amount of time between when an image is shown to the participant and when memory for it is tested. I also want to randomize when particular images are shown in the experiment. This is where programming comes in handy.
What do you mean? Couldn’t you just use an existing software to do this?
Yes. Experiment building software allows me to do simple control/randomizing tests, but for more complicated tests it isn’t very helpful.
Python allowed me to create complex, randomized lists of tasks to suit my own experiments and needs.
Why use Codecademy to learn Python?
In order to use Python I needed to learn the data structures and understand how the basics of the language work.
Taking a traditional computer science course focuses too much on how a language works under the hood for my purposes. I just need to know enough to program a solution to my current problem, not to find the most efficient solution. Codecademy helped me to internalize the data structures and logic of Python so I could sit down and create what my research project needed to be scientifically rigorous quickly.
What are the first steps you’d recommend for a researcher who’s interested in learning to apply programming in their work?
As far as I can tell the best way to use programming in research is to just get started.
Don’t wait for a formal class to get started next semester. Picking up theory and best practices as you go along is helpful but not necessary to get started: in research we often need our programs to work, not to work most efficiently.
One ‘best practice’ to keep in mind is commenting: you are going to want to be able to understand what your program is doing at some point down the road when you are expanding your work or writing it up and need to put details to paper. Don’t skimp on commenting!
How have others in your workplace reacted to you coding up your own experiments?
The reaction to learning to code is overwhelmingly positive. The faculty in my program are all proponents of harnessing technology to study the human mind effectively; coding opens up many new avenues to accomplish that goal. My program has a grad course where the main mission was to expose us to many languages and techniques quickly so we know what tools are out there and would help make our research better.
In my case, it meant investing time in learning Python to have full control over my experiment flow. I not only have an experiment that does exactly what I want but I also have a very versatile tool in my toolbox which will allow me to be more productive in the future by investing the time now.
Additionally, with the current movement toward open science (open access, open source, etc.), I will have non-proprietary experiment scripts to share with other researchers. This is a movement that my peers and I all support.
I already have some basic skills in R an open source statistical programming language and can share my data analysis scripts. Now I will be able to make even more of my scientific process transparent.
What are your own plans next with regards to Python?
I plan to continue to program my experiments in PsychoPy. As for expansions, I will see where the science takes me.
Down the road I plan to make a computer model of the cognitive processes I am investigating experimentally. Programming will allow me to make simulations to predict how a proposed cognitive mechanism behaves formalizing my scientific theory and suggesting new experiments to conduct with human participants. I will use whatever programming language is most suited, but my work with Python has allowed me to wrap my mind around the programming process, taking me one step closer to the modeling goal.
My next Python project will be to extract a corpus of text from the internet to bring with me to an exploratory data mining course I am taking this summer. By automating the process I will be able to collect large quantities of data for mining.
I also don’t plan to just stop at Python! I have heard great things about HTML5 and I plan on tackling the basics of HTML next.
Ready to try out Python? Get started. Or if you have a story to share, let us know.