Saturday, August 18, 2012

Unix for Neuroimagers (Part 1): Fundamentals

As promised, we have begun a new series of tutorials aimed at the beginning neuroimager, who may think that he can get by without learning any computer science whatsoever. This is, unfortunately, not true, and those who wish to pursue a career in cognitive neuroscience need to at least learn the fundamentals; if not for constructing your own scripts, then at least for being able to understand and interpret what others have done. Those who refuse to go beyond their comfort zone and test the waters of what must seem to them a foreign and unfriendly language, will forever be relegated to pushing the Big Button that executes commands or scripts without really knowing what is going on. To enter this field without a working knowledge of programming is to be partially blind.

To that end, these first few screencasts will guide the beginner over the initial hurdles of navigating their computer environment solely through the command line interface. At the basic level of navigation and file manipulation, some simple analogies can be drawn between typing in commands such as cd and ls, and pointing and clicking within the standard Windows or Macintosh operating systems that most people are used to. However, at the more abstract levels involving if/else statements and for loops, there are no ready analogies I can think of, and at this point the Unix shell must be treated as any other foreign language; the only way to learn it is by doing, and by consistent repetition.

Usually I try to supplement the videos with some written commentary, but in this case, I believe that there is a very good introductory resource already out there, which can be found here. Walking through all of these tutorials will probably take less than an hour, but it is worth coming back to them from time to time to reinforce what you have learned.

For those of you who are new to neuroimaging or programming and may doubt whether it will ever really stick, let me assure you that it will, in time. Five years ago I was engaged in a research project the summer of my senior year; however, I knew nothing about computer programming. Nothing. I had taken a class of Java in high school, but barely managed to scrape by with a B-, and that was with copying all of the homeworks from one of the Asian kids in the class under threat of death. I was so useless, I didn't even know how to use Excel (no lie), and needed my advisor to hold my hand through doing the most basic analyses in SPSS. It was humiliating at first, because I knew that many of my colleagues were well versed in all of these tools which appeared as second nature to them, and I felt as though they looked down upon me as some hateful and nasty piece of filth clinging to the soles of their shoes.

However, over time I came to teach myself, more through necessity than anything else. My first job out of college required the use of Unix, the experience with which I greatly exaggerated to a ridiculous degree in my application (I had skimmed through a 1980 Unix textbook borrowed from the public library, and said that I had "experience" with Unix); and I set about to learn whatever I could and whatever I saw was most needed. What I found was that, out of the vast Pacific of commands and options present in Unix, only a minuscule fraction of them were required to successfully carry out the work that I needed to do. More important was molding my mind to accommodate the language and understand how to think through operations before translating my will into a series of typed commands. If I, who had virtually no programming background, a terrible memory, and the attention span of a bag full of puppies, could learn the basics within a year, then so can you. Persist.

This could be you!

There is no need to go it entirely alone. As with any skill, much of the fruits of your labors and lightning flashes of insight will only come through long and solitary hours of study and practice; however, it is as important to learn how to identify external resources, whether they float within the ether of the Internet or are made incarnate in the large, stinking, fleshy pile of humanity which sits next to you in your laboratory. One particularly useful resource I have found is, a message board related to all things Unix. More than once have I posted problems which I had been breaking my head against for many hours or days, only to have a complete solution posted within a matter of seconds. As long as you are willing to tolerate a little condescension and can put up with some invisible nerdling berating you for sloppy indentation, you should be able to solve most of your problems quite easily.

Good luck, comrade.

No comments:

Post a Comment