Tuesday, August 10, 2010

The Code for Success

Three weeks ago I set myself the goal of learning how to program experiments and run data analyses using MATLAB. Up until now I've been working with a program called Presentation Neuro-Behavioural Systems which uses a language loosely based on C and Basic. Although the capabilities of Presentation meet my programming needs at the present, a number of my colleagues currently work with or are switching to MATLAB and I feel I should follow suit. On top of this MATLAB is just a far more powerful software package than Presentation, capable of performing complex data analyses that presentation can not.

So how much progress have I made over the last three weeks? Conceptually very little sadly, though I have manage to successfully write my first MATLAB based program which displays a series of Harry Potter images. It's always a bonus when you can mix work with pleasure :)

Learning a new programming language is tough and it doesn't come naturally, at least not to me. I find programming is very much a love hate relationship, especially when you're starting out. I seem to spend a lot of time cursing profusely at the computer and flailing my arms around, frustrated that MatLab won't display or do what I want it to.

In fact I find it much like trying to learn a musical instrument. You know the sound you want to produce, it's all there in your head, yet when you try to play it it just sounds like white noise. The same goes when I'm learning to program. I know exactly what I want my experiment to look like and I just wish I knew all the MatLab commands to make it happen instantly. Instead my efforts are met with countless errors telling me that my script reads like nonsense.

Perseverance is the key though because the upside is worth it. Finally getting a line of code to work or even better an entire program is incredibly satisfying! It's like a shot of adrenaline and when it happens make sure you've got a beer on hand cause you're going to want to ride the high...seriously. Victories can be short lived so make them count.

So if you’re considering research in the field of psychology, particularly cognitive psychology, it can be extremely beneficial if you have some programming ability. Possessing even just basic programming skills affords you the freedom to tweak and optimise your experimental parameters and conditions such that you maximise your chances of finding the effects you're after. And we all know how fickle some of our effects can be sometimes.

Going into honours I'd had zero experience programming and my supervisor told me I'd have to learn a programming language in order to program my experiment. Suffice to say I felt like I was up sh*t creek without paddle. It was hard work and a lot of hours at the computer for not much immediate reward. It certainly paid off in the long run though and I'm very thankful I was forced to learn it. So my advice for any prospective honours or post-grad students, if you get the opportunity to dabble in some programming, jump at it. Being able to program has certainly opened up a lot of opportunities in research for me.

Happy programming

James


3 comments:

  1. In the context of cognition/perception at least, I'd almost go one step further and say that the research questions you can answer are limited by your programming ability.

    ReplyDelete
  2. As a practising software engineer turned human factors researcher, I wholeheartedly agree with this post. In fact, I'd even go one step further and say that *any* researcher who deals with quantitative data should have the following programming skills:

    * Shell scripting to automate repetitive manual tasks
    * Regular expressions to search and manipulate patterns (related to above)
    * Functional languages (eg Haskell) to understand how to convert "this is what I want" to "this is how you do it" (or how to write better Excel macros)

    By the way, for any psychologists interested in finding out how programming actually "works" without being overwhelmed by pages of boring code, I highly recommend checking out MIT's Scratch: http://scratch.mit.edu/

    ReplyDelete
  3. nice blog.. have a view of my blog when free.. http://www.lonelyreload.blogspot.com .. do leave me some comment / guide if can.. if interested can follow my blog...

    ReplyDelete