2014/08/08

Mathematica for the Neuroscientist (0): Introduction

We are facing another turning point in neuroscientific computing, where the ~10 year reign of MatLab is coming to a close. A large number of people with an eye to the future are moving towards Python.
MatLab was, for better or for worse, the first package which made basic data analysis relatively simple for many neuroscientists without a programming background. The loose syntax and ease of doing simple stuff, however, actually makes intermediate and advanced programming extremely difficult.
Here are some reasons for the recent shift away from MatLab:
  • the 1970's ish scripting syntax for MatLab is showing its age more than ever, and there are an increasing number of things that you just can't do effectively. Important paradigms such as parallel computing and pattern matching, and accepted modern programming practices such as unit testing are virtually impossible to do properly, given the loose syntax.  
  • the cost and pricing... nothing can beat free (i.e. Python)
  • There haven't been any fundamental advances in the MatLab package for the last 5 years, despite the price you pay---basically, there have only been bugfixes and incremental tweaks. (Indeed, this post from 5 years ago is still rather valid; MatLab's progress cannot even start to compare with progress in the standard Mathematica package, even with one version change.)



There are more than enough neuroscience Python fanboys on the web. Here, I'd like to provide an alternate counterpoint: Mathematica. I am a Mathematica fan, and have been since I started with it almost 2 decades ago. My opinions are based on a very solid amateur programming background, but they are colored by my decades-long excitment at the elegance of Mathematica. Furthermore, Mathematica has always allowed even relatively casual hobbists to stay at the forefront of modern data concepts (e.g. network analysis) and programming methods (e.g. parallel/distributed computing).

Of the languages I have experience with (LOGO, Pascal, C++, Java, Mathematica, Matlab, Labview, Scala) or have dabbled with (Python, JavaScript, Visual Basic, C, etc.), Mathematica offers a certain sweet spot for scientific computing in general. I predict that this situation will continue for at least another decade.

My overarching goal in this series, therefore, is to present why I as a neuroscientist and scientific programmer, favor Mathematica hands down. I will try to do this through concrete Neuroscience-related examples which show how Mathematica can help you to analyze your data, effectively and simply.



There are quite a few things that are really easy with the standard Mathematica package, and for this introductory post, I'll give you some examples which may or may not be directly relevant to neurophysiology:

Image Analysis

See this standard example on how you can create a function to discriminate handwritten digits, and then apply that image classifier function to new exemplars.
Untitled-1

There are quite a few GPU-accelerated functions for image analysis in the standard package (no add-ons necessary): everything from regular stuff like deconvolution, sharpening, etc, to cool stuff like face detection, and advanced functions like 3D image segmentation.

This is a good illustration of how powerful the standard Mathematica package is. Especially if you are used to the MatLab business model, you will be surpised that everything is available in the standard package! If you are used to the Python environment, you might be surprised that all of this functionality is curated in a coherent form by Wolfram Research, and you don't have to pick through a hodgepodge of different open-source packages of varying quality and different syntax.

You just do the analysis you want.


Network Analysis

Untitled-1
This is a good illustration of the simple/flexible data structures that are possible in Mathematica, and how it has allowed newer analysis methods to be incorporated seamlessly into the main language.


Curated Databases

Mathematica has had some pretty impressive curated databases. For example, chemistry...
Untitled-1
Or geography...
Untitled-1

While these aren't directly relevant for neurophysiology at all, they are occasionally very entertaining to play around with.


Other Examples

For more examples, see the Wolfram demonstrations project.



In the next post, I'll start with basics by discussing the notebook interface.