Why every neuroscientist should learn to code (and why every ML engineer should learn some neuroscience)

Here is a fact about your brain that most machine learning engineers have never heard, and most neuroscientists have never checked for themselves with code. Load a recording of 734 neurons from a mouse brain, count how often each one fires, and you find that the typical neuron produces about two spikes per second. A third of them fire less than once a second. The network that produces thought, movement and memory is, most of the time, nearly silent.

import numpy as np

data = np.load("steinmetz_session.npz", allow_pickle=True)
spike_times = data["spike_times"]          # 734 neurons, 45 minutes, one mouse

duration = max(st.max() for st in spike_times)
rates = np.array([len(st) / duration for st in spike_times])

print(f"median firing rate: {np.median(rates):.1f} spikes per second")
print(f"neurons below 1 Hz: {np.mean(rates < 1):.0%}")
# median firing rate: 1.9 spikes per second
# neurons below 1 Hz: 33%

Eight lines. Real data, freely available, from a paper published in Nature. Compare that with an artificial neural network, where every unit in every layer is computed on every forward pass, whether it has anything to say or not. The brain runs on roughly the power of a dim light bulb. A large language model needs a building full of hardware. The difference is not a detail. It is one of the central open problems in computing, and you can see the first clue to it in eight lines of Python.

That is what this site is about.

Two tribes that should be one

Modern AI began as an attempt to copy the brain. The perceptron, the neural network, the convolutional layer inspired by the visual cortex, reinforcement learning built on the dopamine literature: the lineage is direct. Then the two fields drifted apart. Machine learning became an engineering discipline organised around benchmarks and GPUs. Neuroscience became a data science organised around ever larger recordings, without always having the people to analyse them.

The result is two groups of very smart people who rarely read each other’s papers. Most ML engineers have never looked at a spike train. Many neuroscientists still hand their data to a collaborator, or to a graduate student who learned Python last month, because writing the analysis themselves feels like someone else’s job.

I have worked on both sides of this line. I currently work on precision medicine, brain-computer interfaces and semantic search, which means I spend my days translating between the two tribes. This site is the translation guide I wish had existed when I started.

This is not a new struggle. Every generation of scientists has been limited by the cognitive workload of its own tools. Johannes Kepler spent years of hand arithmetic wrestling the orbit of Mars into an ellipse, and later called it his war with Mars. For most of the last two centuries, the word computer meant a person: rooms of people, very often women, grinding through calculations for astronomers, engineers and, eventually, the first neuroscientists.

The clearest example in our own field is from 1952. Alan Hodgkin and Andrew Huxley had worked out the equations that describe how a nerve impulse travels along an axon, work that later won them a Nobel Prize. The Cambridge computer was out of service, so Huxley solved the equations by hand on a mechanical desk calculator. Computing a single propagated action potential took him about three weeks. On the laptop I am writing this on, the same calculation takes a few milliseconds.

The lesson is not that we are smarter than Huxley. It is that the bottleneck of science has always been computation, and the people who could do the computation decided what got discovered. Learning to program is how you stop being on the wrong side of that bottleneck.

Why every neuroscientist should learn to code

The data outgrew the spreadsheet a decade ago

A single Neuropixels probe records from hundreds of neurons at thirty thousand samples per second. A modern imaging session produces terabytes. An EEG study has dozens of channels, hundreds of trials, tens of participants. You cannot look at this data. You can only compute on it. The person who can write the computation controls what questions get asked.

Reproducibility is a property of code, not of intentions

A result that lives in a chain of clicks in a GUI cannot be repeated exactly, not even by you, six months later. A result that lives in a script can be re-run, reviewed, shared, and corrected. The reproducibility crisis in the life sciences has many causes, but one of the fixable ones is that analysis is still often done by hand.

The models are code

Every serious theory of how neurons compute is now expressed as a simulation. Hodgkin and Huxley wrote their model as differential equations in 1952 and solved them by hand-cranked calculator. Today the same model is thirty lines of Python. If you cannot read those lines, you cannot really engage with the theory. If you can write them, you can test it against your own data.

Why every ML engineer should learn some neuroscience

The brain is an existence proof

Every time someone claims that intelligence needs a trillion parameters, or a datacentre, or a training set of the entire internet, the brain quietly disagrees. It learns language from a few million words, not a few trillion. It learns to recognise an object from a handful of examples. It does this on twenty watts. We do not know how, and that is exactly the point: the gap between what brains do and what our models do is a map of the ideas we have not had yet.

Sparsity, timing and learning without backpropagation

Those nearly silent neurons at the top of this article are sparse coding in action. Real neurons also communicate with precisely timed events, not continuous activations, which is why neuromorphic chips exist. And no one has found backpropagation in the brain. Synapses change based on information that is local to them, in time and in space. Predictive coding, Hebbian learning, and dendritic computation are all attempts to explain how a network can learn without a global error signal. Any of them could be the next big idea in machine learning. Some of them already are.

Neuroscience is where the interesting problems are

Decoding intention from motor cortex to drive a prosthetic arm. Predicting a seizure minutes before it happens. Restoring speech from neural activity. Finding which patients will respond to which treatment from a brain scan. These are machine learning problems with unusual data, brutal constraints and enormous stakes. They are also where a working engineer can still make a first-author contribution, because the field needs builders.

What this site is

A learning path, not a link collection. Every article uses real neural data and real code, and each track builds on the one before it:

  1. Foundations. Python for people who have never programmed, taught entirely through neuroscience examples. Your first program plots a real spike train.
  2. Signals. What EEG, spikes and fMRI actually measure, and the signal processing that turns raw voltage into something meaningful.
  3. Data. The open datasets and file standards of the field, and how to load, clean and share neural data reproducibly.
  4. Models. From a single leaky neuron to Hodgkin-Huxley to small spiking networks, each one built from scratch in code.
  5. Decoding and brain-computer interfaces. Classifying intention from neural signals, ending in a minimal working BCI loop.
  6. Neuroscience meets AI. Where the two fields overlap today: deep networks as models of cortex, predictive coding, neuromorphic hardware, and what language models do and do not tell us about the brain.
  7. Precision medicine. Neural biomarkers, clinical machine learning, and the many ways a good model can fail in a hospital.

You do not need a neuroscience degree. You do not need to know how to program. You need Python installed, or a browser tab open to a free notebook service, and about an hour a week.

Start here

The first lesson takes you from a downloaded file to a working model of a neuron in about thirty lines of Python, using the same recording as the eight lines above. It is the most important article on this site, because after it you will know whether this path is for you.

Lesson 1: Your first neuron in Python.

Santiago Ramón y Cajal, whose drawings of neurons gave neuroscience its founding image, spent his mornings at the microscope and his afternoons at the drawing board, because the only way to truly see the structure was to render it himself. He told young scientists that anyone can become the sculptor of their own brain. That is the spirit here. The drawing board is now a text editor, and rendering the brain yourself means writing the code.

If something on this site helps you, or if you find a mistake, I would like to hear about it. You can reach me on Twitter at @thinquanaut.