Learning Python for Computational Neuroscience
I started my career as a computational neuroscientist when I chose to model a small network of basal ganglia neurons involved in the feeding mechanism of a pond snail as a final year project for my neuroscience degree. I did pretty well (it got a prize for being the best final year project that year) considering I had never coded seriously before and I had only dealt with neuroscience from a purely biological standpoint. Of course I had great help. My supervisor was (probably still is) a computational neuroscientist and a good one at that and he taught me how to code.
I dare say I’ve improved since then. A lot. Throughout my career in academia I’ve used Matlab with the occasional foray into something else. C/C++ I always found uninteresting and lacking in artistry. I had similar feelings for other languages mainly because I demanded things that they couldn’t give me. Occasionally, I fell in love with other, elegant and powerful languages like Lisp/Scheme, although I couldn’t really make them do what I wanted to do, probably due to lack of experience. That was until I met Python.
Python does what I want it to do because it can do whatever you want it to do. It’s supported and grows with the open source movement. It is supported and worked on by a growing subgroup of computational neuroscientists and a growing number of neuroscientific tools have been and are being developed using it. It’s perfect for an independent scientist like me.
So I am slowly making the transition from full Matlab code to full Python code. I’m learning really quickly and I’m slowly reconstructing all of the work I did for my PhD in Python. I will put it up bit by bit for various reasons. I want it to be accessible by everyone. This way anyone can use it and instead of being a sterile piece of code on my hard drive it can be alive. This will also help me. People that read my code can point out mistakes or ways to improve it and maybe save me time and trouble (oh, how much time I’ve wasted discovering mistakes later than I should have). Also, I want the code out there because it’s not mine. I write it and work on it but I did not create it in a vacuum, it belongs to me as much as it belongs to everyone.
So without further ado, here is the first piece of code that I wrote in Python that will help me in some of my future work. It makes my life a little easier especially when it comes to generating a network architecture on the fly without caring what it looks like exactly or when you need to generate a few hundred (or more) networks and study their average behaviour. It may have other uses of which I haven’t thought of yet, so go ahead and give it a try. If you have any comment on it please let me know, I really do care and I want to become better at coding in Python.