Join 3,551 readers in helping fund MetaFilter (Hide)


Resources for learning Matlab?
January 27, 2012 12:15 PM   Subscribe

I'm starting a new job soon where I will be using Matlab a whole lot. I've used Matlab (and Octave) before and know the basics, but I want to become an expert. What book should I buy, or what other resources should I look into?

If it matters, I will be working on images from an MRI study. I have reasonably extensive experience with scripting and compiled languages, but I need to learn what Matlab is particularly good at so I don't spend a lot of time reinventing the wheel.

So, if I could buy one book that would turn me into Matlab whiz, what would it be?

Other advice for brushing up on Matlab also welcome.
posted by no regrets, coyote to Computers & Internet (7 answers total) 3 users marked this as a favorite
 
I am a university MRI tech. I could be wrong, but I think you might be using Matlab for one of two things: doing relatively simple image analysis and running SPM.

SPM is a Matlab toolbox with its own GUI. Although it can, in principle, be scripted, MRI analysis is painstaking enough that there is little need to batch processes en masse. SPM comes with PDF documentation, which is readable. There is also a hardcover book (see website), but it primarily covers the statistical foundations of what SPM does.

As far as using Matlab qua Matlab, a working knowledge of the fundamentals should be sufficient. A book like Matlab for Neuroscientists will review basic syntax and take you through a variety of applications, some of which will be more relevant to your needs than others. Be familiar with matrix and vector operations, basic statistics, and elementary calculus concepts.
posted by Nomyte at 12:31 PM on January 27, 2012


Mathworks has a lot of useful stuff online.

I'd recommend taking a look at the demos and webinars they have posted for their image processing toolbox here.

That should at least give you an idea as to how things are done wrt image handling on Matlab.
posted by mr_roboto at 12:41 PM on January 27, 2012


Rule one of Matlab: If you're writing a loop, you're almost certainly doing something wrong.

Email me if you ever get stuck, I did my PhD in cognitive neuroscience and spent many years of my life in Matlab.
posted by dmd at 12:46 PM on January 27, 2012 [1 favorite]


dmd has the gist of what I would say: loops are the difference between a functional Matlab programmer and a great one. Learn to program with matrix/vector operations. When "for" loops are unavoidable (I use them over multiple subjects), parallelize.

It is very hard being the best/only Matlab programmer (or programmer in general) in your lab/whatever. It's great having someone more experienced to bounce ideas off of. Even if they don't know the answer, between the two of you, you can get from ten lines down to two.
posted by supercres at 3:48 PM on January 27, 2012


Although it can, in principle, be scripted, MRI analysis is painstaking enough that there is little need to batch processes en masse

Oh, we do this all the time. Part of my job entails taking the process that the scientists develop on a small subset of pilot data and making it run over the larger set. or well it did till we hired a grad student to do it. Now I manage 97 TB of fMRI data and keep the gerbils running in their wheels in the servers

I've got one batch going now that is over 600 subjects.

Some of it is pretty math extensive - getting all the brains into the same coordinate space, for example. We do some automated skull stripping using Matlab and AFNI, but the tools aren't that robust and often we have to fix up the data by hand. That sort of thing.

But to answer the question : Matlab is pretty powerful. I don't know anyone who is good at everything it is capable of, and it is turning into its own fully fledged programming language with every iteration.

One of the things Mathworks does on our campus is offer tutorials and seminars on various facets of it. Last week, I think, was the one on writing GUIs. Next month its grid computing. Those were pretty helpful, especially in finding where to find information. Also, I have this book sitting on my desk at work, and it's been a good resource. The campus library has a few others, but this one I liked enough to buy.

It's worth mentioning that depending on what particular task you are doing, there may be other tools that are better at doing it. Freesurfer, AFNI, FSL, and so on are all used quite a bit as well, and it is not unusual at all for me to take a sample, run it through FSL, then AFNI, then MATLAB, then FSL again.
posted by Pogo_Fuzzybutt at 3:51 PM on January 27, 2012


I don't have any suggestions for primary resources, as I spent the better part of the last decade learning Matlab via trial, error, and hitting F1. However, in addition to what everyone else is saying, I want to suggest you peruse the Matlab File Exchange. Basically, Matlab is great at some things (e.g. efficient matrix calculations) and rubbish at frustratingly many others (e.g. saving figures to pdf, bar graphs with error bars). Thankfully, enough of the rubbish parts are sufficiently common that other, more Matlab-savvy programmers have written tools for overcoming several of these issues and posted them to the File Exchange. If you're working with images, I particular recommend the export_fig.m function that has been on the front page for the last several months.
posted by Schismatic at 3:55 PM on January 27, 2012


Thanks folks, these are great answers.

My background is in a very different field than MRI research, so it's hard to be more specific about exactly what I'm going to be doing until I actually start doing it. But I think there's lots of get started with here, and I'll probably ask a more detailed question once I've got a better feel for my project.

Thanks again, and any more advice is of course welcome.
posted by no regrets, coyote at 5:07 PM on January 27, 2012


« Older How do I find contact informat...   |  Primary care doctor and hospit... Newer »
This thread is closed to new comments.