Community /

Moving from Matlab to Python

For any real data-hounds out there, you’ve probably noticed that I do most of my data analysis and plotting in Matlab.  It’s a computing and plotting package that I’ve been using for a long, long time (almost 20 years…yikes!).  As a result, I’m very comfortable with it, which makes it nearly effortless for me to use it to explore new data.  Unfortunately, Matlab is very expensive (thousands of dollars), so it’s unlikely that there are very many other hobbyists that are likely to have this tool.  As a result, while I have been sharing all of the Matlab EEG analysis code on my GitHub, it is a bit pointless since Matlab itself is so unavailable.

To make my EEG analysis code more usable for other folks, I’ve decided to put on my big boy pants and to try to learn something new.  I’m making the jump to Python.  Look out!

Developing Python Code in the Spyder IDE

The primary benefits of Python are that it’s free and that it has a huge community of developers.  As an added benefit to me, there are also a lot of former Matlab programmers who have made the jump to Python, which means that there is a lot of Matlab-reminiscent Python code out there for Matlab junkies like myself to use as a gateway drug to Python.

When getting started in Python, it’s helpful to use a pre-packaged Python distribution that includes a good selection of helpful packages along with the Python core.  Based on some guidance from my buddy Rob, I decided to use the “Anaconda” distribution because it includes tried-and-true packages numpy (numerical math routines and data structures), scipy (scientific computing routines, such as filtering), and matplotlib (a collection of Matlab-style plotting routines).  It’s a pretty sweet distribution.  You can download it for free from the Anaconda website.

As with any programming language, one’s first experience is highly dependent upon the quality of the development environment.  I’ve chosen to start with the Sypder IDE, which is shown in the screenshot above.  I don’t know if it is considered to be an especially good or especially bad IDE, but it seems to do the job.  If you’re a Matlab ninja turned Python super-hero, I’d love to hear what IDE you use.

So, moving forward, you should expect to see me share my Python code for my upcoming EEG Hacker posts.  While my Python style will be ugly (being a Python newbie, how can it be anything but ugly?), hopefully you can read it well enough to learn a few ideas (or to teach me a few ideas) on how to do some EEG processing.

Wish me luck…’cause I’m jumping in!