If Coding == True: Research

Although many people picture a PhD position as an eternal chase after participants, protocols, experiments and new technologies, most of the time we sit behind a screen trying to survive the university bureaucracy, develop new experiments or analyses. And that is where I am right now. At the moment I am trying to find the best sequence to present in an EEG (electroencephalography) experiment, which means balancing the number of times each stimulus is presented and making its sequence as random as possible while respecting multiple conditions (e.g. not having the same stimulus twice in a row). It’s not something I can achieve by trial and error, writing on a piece of paper. That means diving into Python, a programming language, to create a simple script (a set of instructions) made of numerous “If”, “elif”, ”else” and “while” and let the code work for me.

And that made me think…

I am amazed at how much programming has begun to influence my academic life. When I started my bachelor's degree I would have never imagined that such a large part of psychology was based on the coding skills of the researchers. At that time, my knowledge of programming and this “mysteriously logical” world was 0. I knew that some people somewhere and somehow were constantly typing on their keyboard developing games and programs but I didn’t understand the connection between that universe, so far from me, and the complexity of the human mind. Later in my bachelor’s, I started my internship in the Affiliative Behaviour and Physiology Lab, and there I had my first confrontation with programming. I was trying to analyze some physiological data using R, and it was at that moment that I began to see how useful and versatile programming could be for psychologists. From designing and developing an experimental protocol, passing through data collection, to data analysis, programming shapes every aspect of Psychology research. For instance, by using simple scripts you can automate things such as extracting or storing information from/in your Excel files, renaming large batches of files or reorganizing your messy folders in just a few seconds. All these boring tasks, that we are forced to face every day, can be translated in an efficient and fun way to a few steps of logic expressed through code. We can transform the tediousness of “everyday bureaucracy” into a challenge between us and the kernel… how could we manage without it?!?! Of course, there are more serious and research related reasons to learn to program. Data Collection for example. Although nowadays many graphical interfaces allow us to easily create complex designs, using a programming language lets us have more direct control of the several variables that we should consider and allow us to fix the many errors that INEVITABLY will occur. Moreover, there is an emerging interest in doing psychology research on social media and our interactions through them. The flexibility of programming languages is opening doors to research projects that cannot be achieved with more basic statistical software. What programming is most important for, obviously, is data analysis. Even here we can find numerous kinds of software: spreadsheets like Excel, batch-oriented procedure-based systems like SAS, GUI-based systems like SPSS, or Statistica, but choosing a programming language offers greater flexibility. By writing scripts we can easily document our progress, automate sequences of tasks and we can adapt or reuse our code for similar data, saving a lot of time and effort.
It’s not always easy to learn to program, especially when you don’t attend specific classes or courses and you have to learn it on your own. Still, it’s worth it. The approach that I used to develop my Python skills (very limited!!) on my own was to consider it as a game. A game between me and “him” that I had to win. A game composed of rebus and specific commands that have to be given in a specific way. In other words, you should have fun coding both if you’re using it for fun or work. Everything will become easier even if you only have some basic knowledge. It is not something related to the specific programming language we use, but to how we address problems and decompose them in sub-steps.

To conclude my rambling, I just want to say: try to code as much as possible! It’s fun (and useful)!!!!