Project A: Neurons from the equations up
Hodgkin–Huxley in Python from the four equations, then leaky integrate-and-fire, then Izhikevich, then a spiking network in Brian2. You heard a spike in Phase 1; now you make one.
On this pageTwo weekends
In 1952 Hodgkin and Huxley wrote down four differential equations for the squid axonA quantitative description of membrane current and its application to conduction and excitation in nerveThe four equations behind every spiking model in Phase 4, still readable in the original. and integrated them by hand on a mechanical calculator, and out came the action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. Related: Membrane potentialMembrane potential The voltage across a cell's membrane, about −70 millivolts at rest, set by ion concentrations and which channels are open. , Ion channelIon channel A protein pore in the membrane that lets specific ions through, often only when the voltage or a chemical tells it to open. , SpikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry you heard from a cockroach leg. You can integrate them in twenty lines of Python and watch the same thing happen. Then you simplify them twice, to the models that networks are actually built from, and run a thousand neurons at once. The equations stop being symbols when you have watched them fire.
- Press the brief pulse. One spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry, then rest. Look at the gates: m rises fast, h falls, n rises slowly.
- Raise the sustained current slowly. Below about 6 µA/cm² nothing; above it, a train of spikesSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry appears at a nonzero rate straight away. That jump is a property of this model.
- Raise it further. The rate rises, then the spikesSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry shrink, then they stop. Too much current holds the sodium channels inactivated.
Hodgkin–Huxley
Four state variables: the membrane voltage V and three gating variables m, h, n between 0 and 1, which are the fraction of sodium activation gates open, sodium inactivation gates open, and potassium gates open.
The current balance, with the membrane capacitance, the injected current, and one leak term:
Each gate relaxes toward a voltage-dependent open fraction:
with and the voltage-dependent opening and closing rates that Hodgkin and Huxley fit to their data. Each gate has a steady value and a time constant worth knowing when checking an implementation:
The squid parameters: , , ; , , ; . The rate functions are in every textbook and in the site’s widget source.
import numpy as np
def hh(I_ext, T=100.0, dt=0.01):
gNa, gK, gL, ENa, EK, EL, C = 120., 36., 0.3, 50., -77., -54.4, 1.
an = lambda v: 0.01*(v+55)/(1-np.exp(-(v+55)/10)); bn = lambda v: 0.125*np.exp(-(v+65)/80)
am = lambda v: 0.1*(v+40)/(1-np.exp(-(v+40)/10)); bm = lambda v: 4*np.exp(-(v+65)/18)
ah = lambda v: 0.07*np.exp(-(v+65)/20); bh = lambda v: 1/(1+np.exp(-(v+35)/10))
n_steps = int(T/dt); V = np.empty(n_steps)
v, m, h, n = -65., 0.05, 0.6, 0.32
for i in range(n_steps):
I = I_ext(i*dt)
dv = (I - gNa*m**3*h*(v-ENa) - gK*n**4*(v-EK) - gL*(v-EL)) / C
m += dt*(am(v)*(1-m) - bm(v)*m); h += dt*(ah(v)*(1-h) - bh(v)*h); n += dt*(an(v)*(1-n) - bn(v)*n)
v += dt*dv; V[i] = v
return V
Forward Euler with a 0.01 ms step is fine here. Plot V for a 2 ms pulse of 30 µA/cm²: one spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry. Plot the gates alongside and you have reproduced Figure 1.
Then the classic experiments. Sweep the sustained current and count spikesSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry per second: the frequency-current curve, with its jump at threshold. Deliver two pulses with a variable gap and find the shortest gap that produces a second spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry: the refractory periodRefractory period The millisecond or so after a spike during which the neuron cannot fire again because its sodium channels are inactivated; it caps firing rates at a few hundred per second. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Ion channelIon channel A protein pore in the membrane that lets specific ions through, often only when the voltage or a chemical tells it to open. . Glossary entry. Block the potassium channels (set g_K to zero) and watch the spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry fail to repolarize. Each is an afternoon and each is a figure for the build log.
Leaky integrate-and-fire
Throw away the gates. The membrane is a leaky capacitor:
When crosses a threshold, record a spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry and reset . Two lines of dynamics. It cannot produce a spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry shape, but it captures when spikesSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry happen, which for networks is what matters, and it runs ten thousand times faster. Reproduce the f-I curve and compare its shape to HHHodgkin–Huxley model The 1952 set of four differential equations for the squid axon that reproduces the action potential from voltage-dependent sodium and potassium channels. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Leaky integrate-and-fire neuronLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold. . Glossary entry’s: the LIFLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold. Related: Hodgkin–Huxley modelHodgkin–Huxley model The 1952 set of four differential equations for the squid axon that reproduces the action potential from voltage-dependent sodium and potassium channels., Izhikevich modelIzhikevich model A two-equation neuron model that reproduces most known firing patterns at a tiny fraction of Hodgkin–Huxley's cost.. Glossary entry curve rises smoothly from zero, the HHHodgkin–Huxley model The 1952 set of four differential equations for the squid axon that reproduces the action potential from voltage-dependent sodium and potassium channels. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Leaky integrate-and-fire neuronLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold. . Glossary entry curve jumps.
Izhikevich
Two equations with four parameters that, by choosing the parameters, reproduce twenty different firing patterns real neurons show: regular spiking, bursting, chattering, fast spiking.
On spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry, and . With , , , it is a regular-spiking cortical neuron. Change to 2 and to −55 and it bursts. Reproduce the figure from the 2003 paper with all twenty patterns; it is the single most educational plot in computational neuroscience.
A network in Brian2
Brian2Brian2 A Python simulator for spiking neural networks in which you write the equations directly. Related: Leaky integrate-and-fire neuronLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold.. Glossary entry lets you write the equations as strings and simulate thousands of neurons connected by synapsesSynapse The junction where one neuron signals to another, usually by releasing a chemical that opens channels on the next cell. Related: Synaptic plasticitySynaptic plasticity The strengthening or weakening of synapses with use, the physical basis of learning. , NeurotransmitterNeurotransmitter A chemical released at a synapse that changes the next neuron's membrane potential. . Glossary entry. The classic first network: 4000 LIFLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold. Related: Hodgkin–Huxley modelHodgkin–Huxley model The 1952 set of four differential equations for the squid axon that reproduces the action potential from voltage-dependent sodium and potassium channels. , Izhikevich modelIzhikevich model A two-equation neuron model that reproduces most known firing patterns at a tiny fraction of Hodgkin–Huxley's cost. . Glossary entry neurons, 80 percent excitatory and 20 percent inhibitory, randomly connected, driven by noise. Depending on the balance of excitation and inhibition it sits quietly, fires asynchronously, or falls into synchronized oscillations, and you can see population rhythms emerge from cells that individually have none. That emergence is where the oscillations explainer picks up.
from brian2 import *
eqs = 'dv/dt = (-(v - El) + I)/tau : volt (unless refractory)\nI : volt'
G = NeuronGroup(4000, eqs, threshold='v > -50*mV', reset='v = -65*mV', refractory=2*ms, method='euler')
- Implement HHHodgkin–Huxley model The 1952 set of four differential equations for the squid axon that reproduces the action potential from voltage-dependent sodium and potassium channels. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Leaky integrate-and-fire neuronLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold. . Glossary entry and reproduce a single spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry with gates. Save the figure.
- Sweep current for the f-I curve. Find the threshold current and the refractory periodRefractory period The millisecond or so after a spike during which the neuron cannot fire again because its sodium channels are inactivated; it caps firing rates at a few hundred per second. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Ion channelIon channel A protein pore in the membrane that lets specific ions through, often only when the voltage or a chemical tells it to open. . Glossary entry.
- Implement LIFLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold. Related: Hodgkin–Huxley modelHodgkin–Huxley model The 1952 set of four differential equations for the squid axon that reproduces the action potential from voltage-dependent sodium and potassium channels. , Izhikevich modelIzhikevich model A two-equation neuron model that reproduces most known firing patterns at a tiny fraction of Hodgkin–Huxley's cost. . Glossary entry. Overlay its f-I curve on HHHodgkin–Huxley model The 1952 set of four differential equations for the squid axon that reproduces the action potential from voltage-dependent sodium and potassium channels. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Leaky integrate-and-fire neuronLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold. . Glossary entry’s.
- Implement Izhikevich and reproduce at least eight of the twenty firing patterns.
- Install Brian2Brian2 A Python simulator for spiking neural networks in which you write the equations directly. Related: Leaky integrate-and-fire neuronLeaky integrate-and-fire neuron The simplest useful neuron model: a leaky capacitor that fires and resets when it reaches a threshold. . Glossary entry and run the balanced random network. Vary the inhibitory weight and plot the population rate’s spectrumSpectrum A plot of how much of a signal lives at each frequency. Related: Fast Fourier transform (FFT)Fast Fourier transform (FFT) The algorithm that breaks a stretch of signal into the sinusoids that would add up to it, giving amplitude and phase at each frequency. , Power spectral density (PSD)Power spectral density (PSD) The spectrum expressed as power per hertz, the standard way to quantify how strong alpha is. . Glossary entry; find the setting where an oscillation appears.
- Write the build log with all five figures.