How to Make a Human Brain in Python

An early hit from this week’s PyCon 2015.

Python already has a reputation as a classy do-anything programming language—or programming cult, depending on who you ask—with an emphasis on easily readable or at least pretty code and intuitive syntax and behavior. Anecdotally, it's probably the most frequent "favorite" language I encounter. I think xkcd sums it up well enough:

Image:  ​xkcd.com

Anyhow, the annual Python conference PyCon is underway this week in Montreal and you can find the full schedule here—it is indeed full, with sessions ranging from "Data Science in Advertising: Or a future when we love ads" to "The Ethical Consequences Of Our Collective Activities" to "'Words, words, words': Reading Shakespeare with Python." I'm excited and, as a diehard fan of the archaic and pointlessly tedious (also: curly braces), I don't even really use Python—though that resistance is crumbling fast.

Here's one PyCom session worth sharing (of many), and it illustrates a couple of important things simultaneously: one, simulating a brain is really hard and probably impossible given any conceivable technology and, two, Python rules and its simplicity/intuitiveness do well in unraveling neurocomplexity. With a half-dozen lines of code, you or I could make and observe a neuron—yes, our very own neuron—as it monitors incoming currents and sends impulses.

The talk comes courtesy of Trevor Bekolay, a computational neuroscientist at the University of Waterloo. Bekolay introduces several Python tools that enable the simulation of neurons, such as Brian and an adaptation of the classic Neuron simulator software, but, mostly, the Nenga Neural Simulator project, which Bekolay is a developer on. The key difference with Nengo is that it allows a natural and intuitive scaling up of neurological processes.

"At the University of Waterloo, we have been working on a new approach to scaling up brain simulations, and a new Python package to support that approach," Bekolay writes in the presentation's abstract. "Instead of focusing on biologically accurate neurons, we focus on how to connect neurons together such that they can compute interesting functions."

From a computer science perspective, the Nenga approach is pretty interesting. It follows something like the code-compiler-machine instruction process that allows programming languages, even elegant high-level languages like Python, to be translated into the gritty not-so-elegant assembly and machine instructions that actually tell computer hardware what to do.

Nenga offers a set of functional (corresponding to functions of the brain) constructions that can be called simply via Python and which correspond to the holy mess that is actual neurology, which might look a bit like a tangle of machine instructions.

And so it becomes possible to put together simple-seeming commands and objects in interesting, hopefully relevant ways. As Bekolay notes, this is a potentially powerful tool in the development of new forms of artificial intelligence.