Web Simulation 

 

 

 

 

Leaky Integrate-and-Fire Neuron Tutorial 

This interactive simulation demonstrates the Leaky Integrate-and-Fire (LIF) Neuron Model, one of the most important simplified models in computational neuroscience. The LIF model captures the essential dynamics of how biological neurons process and transmit information.

What is the LIF Neuron Model?

The LIF model describes a neuron as an electrical circuit consisting of a capacitor (cell membrane) and resistor (ion channels) in parallel. When input current flows into the neuron:

  • The membrane potential (voltage) integrates the input over time
  • The voltage leaks back toward resting potential through the resistance
  • When voltage reaches a threshold, the neuron fires (generates a spike)
  • After firing, the voltage resets to a baseline value

The Governing Equation

The LIF neuron is described by this first-order linear differential equation:

τ · dV/dt = -(V - Vrest) + R · I

Where:

  • V = Membrane potential (voltage)
  • τ = R × C = Time constant (determines how fast the neuron responds)
  • R = Membrane resistance (how easily current flows out)
  • C = Membrane capacitance (how much charge the membrane stores)
  • I = Input current (external stimulation)
  • Vrest = Resting potential (equilibrium voltage)

The Spike-and-Reset Mechanism

When the membrane potential V reaches the threshold voltage Vth:

Spike Condition: If V ≥ Vth, then:
  1. Generate an action potential (spike)
  2. Reset V → Vreset
  3. (Optional) Enter a refractory period

How Does a Linear Equation Produce Non-Linear Spikes?

A common question: The differential equation τ·dV/dt = -(V - Vrest) + R·I is purely linear. How can it produce highly non-linear spike behavior?

Key Insight: The linear ODE does NOT produce the spikes! The spikes come from an additional threshold rule that creates a discontinuity.

The LIF model is actually a hybrid dynamical system with two components:

Component Type What It Does
Differential Equation
τ·dV/dt = -(V-Vrest) + R·I
Linear, Continuous Smooth voltage evolution (charging and leaking)
Threshold + Reset Rule
if V ≥ Vth: V → Vreset
Non-linear, Discrete Instantaneous jump (discontinuity in V)

The differential equation alone would just cause voltage to smoothly approach a steady-state. The threshold rule is what creates the "spike" - an instantaneous reset that produces the sawtooth waveform:

V

V_th |----•----•----•----   ← Threshold triggers reset
     |   /|   /|   /|
     |  / |  / |  / |      Linear ODE governs
     | /  | /  | /  |      this smooth rise
     |/   |/   |/   |
V_reset ──────────────────   ← Reset snaps V back
     └──────────────────→ t
       Spike! Spike! Spike!

Why This Design? Real neurons use complex non-linear ion channel dynamics (Hodgkin-Huxley model with 4+ differential equations) to generate the ~1ms spike waveform. The LIF model abstracts away this complexity, replacing it with a simple rule while preserving the essential input-output behavior. This makes LIF computationally efficient while still capturing the essence of neural firing.

The Beauty of LIF: It demonstrates that complexity can emerge from simplicity - a linear ODE plus a threshold rule creates rich, non-linear spike train dynamics!

The Leaky Bucket Metaphor

The LIF neuron can be understood intuitively as a leaky bucket:

Bucket Component Neuron Equivalent Mathematical Term
Water Level Membrane Potential V (voltage)
Water Input (Tap) Input Current (synaptic input) I (current in nA)
Leak (Hole at Bottom) Ion channel leakage -(V - Vrest)/τ
Overflow Line Threshold for firing Vth
Bucket Dumping Spike + Reset V → Vreset

Numerical Integration: Euler Method

The simulation solves the differential equation using the Euler method:

Euler Update Rule:

Vnew = Vold + Δt · (dV/dt)

Vnew = Vold + (Δt/τ) · [-(Vold - Vrest) + R · I]

This discrete approximation is computed at each time step to evolve the voltage forward in time.

Key Parameters and Their Effects

Parameter ↑ Increase Effect ↓ Decrease Effect
Input Current (I) Faster voltage rise, higher firing rate Slower/no firing, may not reach threshold
Resistance (R) Higher steady-state voltage, slower leak Lower voltage, faster leak to rest
Capacitance (C) Slower response, more temporal integration Faster response, less integration
Threshold (Vth) Fewer spikes, requires stronger input More spikes, fires more easily

The Time Constant τ

The time constant τ = R × C is crucial - it determines how quickly the neuron responds:

  • Small τ (fast neuron): Quick response, short memory, sensitive to fast inputs
  • Large τ (slow neuron): Sluggish response, integrates inputs over longer time, smooths out noise

Biologically Realistic Parameter Ranges

This simulation uses values calibrated to real neuron measurements:

Parameter Simulation Range Biological Basis
R (Resistance) 5-100 MΩ Membrane input resistance of cortical neurons
C (Capacitance) 0.5-5 nF Total membrane capacitance (~1 µF/cm² × surface area)
I (Input Current) 0-2 nA Typical rheobase and suprathreshold currents
Vth (Threshold) 10-30 mV ~20 mV above resting potential
τ (Time Constant) 10-50 ms τ = R × C (default: 20 ms)

Note: Units are chosen so that R(MΩ) × C(nF) = τ(ms) directly.

Applications of the LIF Model

Field Application
Computational Neuroscience Modeling neural circuits, studying network dynamics
Machine Learning Spiking Neural Networks (SNNs), neuromorphic computing
Robotics Bio-inspired sensory processing, motor control
Brain-Computer Interfaces Decoding neural signals, neural prosthetics
Hardware Design Neuromorphic chips (Intel Loihi, IBM TrueNorth)
τ · dV/dt = -(V - Vrest) + R · I   |   If V ≥ Vth → Spike! → Reset

Parameters

Input Current (I) 2.00nA
Resistance (R) 12
Capacitance (C) 2.0nF
Threshold (Vth) 20mV
Time Constant τ = R × C
24 ms

📊 Input Pattern

Neuron Type Preset

📈 Statistics

Voltage 0.0 mV
Spikes 0
Rate (Hz) 0.0
Time 0.0 s
Membrane Potential vs Time
⚡ SPIKE!
Leaky Bucket Metaphor
Voltage V(t)
Threshold Vth
Action Potential (Spike)
Water = Voltage

Usage Instructions

  1. Adjust Parameters:
    • Input Current (I): Increase to make the neuron fire. Start at 0 and slowly increase.
    • Resistance (R): Higher R means higher steady-state voltage for same current.
    • Capacitance (C): Higher C means slower response (larger time constant).
    • Threshold (Vth): Lower threshold = easier to trigger spikes.
  2. Try Input Patterns:
    • Constant: Steady input - observe tonic firing
    • Pulse Train: Rhythmic on/off - see response to transients
    • Sinusoidal: Oscillating input - observe phase locking
    • Step: Sudden onset - see adaptation dynamics
    • Ramp: Gradual increase - find firing threshold
    • Noisy: Random fluctuations - realistic synaptic input
  3. Select Neuron Type: Use the dropdown to load realistic parameters for different neuron types.
  4. Observe the Visualizations:
    • Top Graph: Shows voltage over time with threshold line and spikes
    • Bottom Bucket: Intuitive metaphor - water level = voltage

Key Experiments to Try

Experiment Setup What to Observe
Find Rheobase Start I=0, slowly increase until first spike The minimum current needed to fire (rheobase current)
F-I Curve Increase I from 0 to 5, note firing rate at each level Firing rate increases with current (approximately linear)
Time Constant Effect Use Pulse input, compare Fast vs Slow presets Fast neurons respond quickly, slow neurons integrate over time
Threshold Effect Set I=3, vary threshold from 10 to 25 Lower threshold = more spikes, higher threshold = fewer spikes
Subthreshold Dynamics Set I just below threshold, watch voltage approach but not reach Vth Voltage reaches steady state: Vss = Vrest + R×I
Resonance Use Sine input with different τ values Neuron responds best to inputs matching its time constant

Neuron Type Presets

The dropdown includes realistic parameter sets based on different neuron types:

Neuron Type I (nA) R (MΩ) C (nF) τ (ms) Characteristics
Basic States
🔇 Silent 0 12 2 24 No input, voltage decays to rest
📉 Subthreshold 1 15 2 30 V_ss = 15 mV < V_th, no spikes
Cortical Neurons
�  Pyramidal Cell 2 12 2 24 Regular spiking, most common cortical neuron
⚡ Fast-Spiking Interneuron 2 15 0.5 7.5 Very fast, high firing rate, GABAergic
✦ Stellate Cell 1.5 20 1.5 30 Delayed spiking, layer 4 cortex
Other Brain Regions
🌳 Purkinje Cell 0.8 30 4 120 Cerebellum, very slow τ, complex spikes
• Granule Cell 1.5 50 0.5 25 Very small cell, high input resistance
🔄 Thalamic Relay 1.8 15 1.5 22.5 Relay mode, passes sensory info to cortex
🐴 Hippocampal CA1 1.5 18 1.5 27 Memory formation, place cells
Peripheral Neurons
💪 Spinal Motor Neuron 2 8 5 40 Large cell body, drives muscles
👁 Sensory Neuron 2 20 0.5 10 Fast response to stimuli

Note: Parameters are approximations for educational purposes. Real neurons show significant variability within each type.

Understanding the Leaky Bucket

The bucket visualization makes the math intuitive:

  • Tap On: Water (voltage) rises - just like current charging the membrane
  • Leak: Water drains proportional to level - higher voltage = faster leak (ohmic)
  • Equilibrium: When input = leak, water level stabilizes (steady-state voltage)
  • Overflow: When water hits threshold → bucket dumps → spike!

The Spike-and-Reset Mechanism

When water (voltage) hits the threshold, the "draining" is instantaneous and complete - like a toilet flush or tipping bucket rain gauge:

Bucket State What Happens
Water rising Voltage integrating input current
Hits threshold Triggers a "flush" mechanism
Instant dump All water released at once (V → Vreset)
Starts refilling Cycle repeats if current continues

In real neurons, the action potential involves rapid depolarization (+40mV spike) then repolarization (~1-2ms). The LIF model simplifies this by skipping the spike waveform and just recording "spike happened, reset voltage."

Why Higher Resistance (R) Leads to FASTER Threshold Crossing

This seems counterintuitive! The key insight: R is resistance to LEAKING, not to INPUT.

R = Membrane Resistance controls how easily charge leaks OUT, not how easily current flows IN.
High R (small leak hole) Low R (big leak hole)
Charge stays inside Charge escapes quickly
Voltage builds up Voltage drains away
Reaches threshold FASTER May never reach threshold

The Math: Steady-state voltage Vss = Vrest + R × I

  • R = 5 MΩ, I = 1.5 nA → Vss = 7.5 mV (below 20mV threshold - no spikes!)
  • R = 15 MΩ, I = 1.5 nA → Vss = 22.5 mV (above threshold - spikes!)
  • R = 30 MΩ, I = 1.5 nA → Vss = 45 mV (well above threshold - fast spikes!)

Think of it as Ohm's Law: V = I × R. Same current, higher R → more voltage!

Why Higher Capacitance (C) SLOWS DOWN Threshold Crossing

Capacitance (C) determines how much charge is needed to raise the voltage by 1 unit - like the width/size of the bucket.

High C (wide bucket) Low C (narrow bucket)
Needs lots of water to fill Fills quickly with little water
Voltage rises slowly Voltage rises quickly
More temporal integration Quick, responsive

The Math: Rate of voltage change: dV/dt = I / C

  • High C → slow dV/dt (voltage changes slowly)
  • Low C → fast dV/dt (voltage changes quickly)

Physical Analogy: Same water flow into a wide tank fills slowly; same flow into a narrow tank fills quickly.

Summary: R vs C Effects

Parameter What it Controls ↑ Increase Effect
R (Resistance) Leak rate (exit resistance) Less leak → FASTER to threshold
C (Capacitance) Storage capacity (tank size) More to fill → SLOWER to threshold
τ = R × C Time constant Slower overall response

Key insight: Fast neurons have high R, low C. Slow integrating neurons have low R, high C.

Mathematical Details

Steady-State Voltage (no spiking):
  Vss = Vrest + R × I

Time to reach threshold (from rest):
  tspike = τ × ln[R×I / (R×I - Vth + Vrest)]

Firing rate (for constant superthreshold input):
  f ≈ 1 / tspike

Minimum current to fire (rheobase):
  Irheo = (Vth - Vrest) / R

Comparison with Real Neurons

Aspect LIF Model Real Neuron
Spike Shape Instantaneous (simplified) ~1ms duration, specific waveform
Refractory Period Can be added (optional) 1-2ms absolute, longer relative
Adaptation Not included (in basic model) Firing rate decreases over time
Ion Channels Single passive leak Multiple active conductances
Computational Cost Very low (one ODE) High (Hodgkin-Huxley: 4 ODEs+)

Extensions of the LIF Model

  • LIF with Refractory Period: Add a fixed time after spike where neuron cannot fire
  • Adaptive LIF: Threshold increases after each spike (adaptation)
  • Exponential IF (EIF): Adds exponential spike onset for more realistic dynamics
  • Izhikevich Model: 2D model capturing many spiking patterns
  • Hodgkin-Huxley: Full biophysical model with ion channel dynamics

Implementation Notes

Euler Integration (used in this simulation):
  V[n+1] = V[n] + (dt/τ) × [-(V[n] - V_rest) + R × I]

Spike Detection:
  if V[n+1] >= V_th:
    record_spike()
    V[n+1] = V_reset

Time Step:
  dt = 0.5 ms (must be << τ for stability)