Labs|

Syllabus

The brain is a dynamic, physical system computing over time. This syllabus bridges descriptive neuroscience and high-level artificial intelligence by constructing the biological engine from the ground up — moving from physics, to single-cell logic, to network emergence.

Part 1

The Foundations

Input & Integration

Establishing how a biological system processes the raw physics of its environment.

01

Signal Integration

Open Lab →
The Concept

A neuron receives thousands of inputs across its dendritic tree. This is fundamentally a geometric problem of spatial summation.

The Analogy

The Corporate Boardroom. A CEO (soma) takes a vote. Not all board members (inputs) have the same equity. The CEO calculates the dot product: multiplying each member's vote by their specific voting power (dendritic weight) and summing it to reach a consensus.

The Math

The membrane voltage response at the soma is the linear combination of inputs xx and synaptic weights ww.

y=i=1Nwixi=wTxy = \sum_{i=1}^{N} w_i x_i = \mathbf{w}^T \mathbf{x}
Implementation

Use NumPy dot products. Create an input vector x (binary spike presence: 0 or 1) and a weight matrix W. This lab proves that a single biological layer is mathematically equivalent to a linear perceptron.

02

Membrane Dynamics

Open Lab →
The Concept

Biology is not instantaneous. The lipid bilayer of the cell acts as an insulator (capacitor), while ion channels act as resistors.

The Analogy

The Leaky Bucket. You pour water (current) into a bucket with a small hole. To raise the water level (voltage), you must pour water in faster than it can escape.

The Math

Modeled as an RC circuit. The rate of change of voltage VV depends on the membrane time constant τm=RmCm\tau_m = R_m C_m.

τmdVdt=(VEL)+RmIe(t)\tau_m \frac{dV}{dt} = -(V - E_L) + R_m I_e(t)

Where ELE_L is the resting leak potential (usually 70mV-70\text{mV}), and IeI_e is the external current.

Implementation

Use Euler's Method to solve the ODE numerically. Update V at each discrete time step dt: V(t+dt) = V(t) + (dt/τ_m)[−(V(t)−E_L) + R_m·I_e(t)]

03

Neural Stochasticity

Open Lab →
The Concept

The brain is noisy. Neurotransmitter vesicle release is probabilistic.

The Analogy

The Crowded Party. Listening to a friend in a loud room. Background "chatter" actually keeps the neuron hovering close to its threshold, making it highly reactive to sudden signals (Stochastic Resonance).

The Math

Spike trains are modeled as a Homogeneous Poisson Process. The probability of observing kk spikes in a time interval is:

P(k)=(λT)keλTk!P(k) = \frac{(\lambda T)^k e^{-\lambda T}}{k!}

Where λ\lambda is the mean firing rate.

Implementation

Generate Poisson spike trains using random number generators. Compare the Fano Factor (variance/mean) of your generated spikes to real cortical data (which is usually around 1.0).

Part 2

The Action Potential

Spike Generation

Transitioning from passive linear summation to active, non-linear computation.

04

LIF Synthesis

Open Lab →
The Concept

The Leaky Integrate-and-Fire (LIF) model introduces a hard threshold to Lab 2.

The Analogy

The Flushing Toilet. Water accumulates until a mechanical tipping point. The flush is an all-or-nothing event (the spike), followed by a mandatory refilling phase where it cannot flush again (refractory period).

The Math

We use the ODE from Lab 2, but inject a discontinuous logical rule:

If V(t)Vth, then V(t)Vreset\text{If } V(t) \ge V_{th}, \text{ then } V(t) \to V_{reset}
Implementation

Track the voltage. When V > −55mV, record a spike at time t, instantly set V = −65mV, and force V to stay at −65mV for 2ms (the refractory constraint).

05

Phase Space Biophysics

Open Lab →
The Concept

To truly understand stability, we map the system's geometry using a 2D Phase Plane rather than a 1D time-series.

The Analogy

The Topographic Map. Instead of hiking blindly, you look at a map from above. The nullclines are the ridges and valleys. You can predict exactly where a state variable will roll.

The Math

We reduce the neuron to two variables: Voltage (VV) and a slow recovery variable (ww). We plot the Nullclines (where dVdt=0\frac{dV}{dt} = 0 and dwdt=0\frac{dw}{dt} = 0).

Implementation

Plot V on the X-axis and w on the Y-axis. Calculate the vector field using np.meshgrid. You will visually identify the “Fixed Points” (resting state) and the “Limit Cycle” (continuous spiking trajectory).

06

The Hodgkin-Huxley Engine

Open Lab →
The Concept

Removing the manual LIF reset. We simulate the actual voltage-gated ion channels that physically generate the action potential.

The Analogy

Pressure-Sensitive Floodgates. A dam where gates open automatically under pressure. Sodium gates burst open causing a flood (depolarization), which physically triggers Potassium gates to open, draining the excess (repolarization).

The Math

The membrane acts as a parallel circuit with variable conductances (gg).

CmdVdt=IeINaIKILC_m \frac{dV}{dt} = I_e - I_{Na} - I_K - I_L
INa=gNam3h(VENa)I_{Na} = g_{Na}m^3h(V - E_{Na})
IK=gKn4(VEK)I_K = g_K n^4(V - E_K)

Where m,h,nm, h, n are gating variables (probabilities between 0 and 1) governed by their own differential equations.

Implementation

This requires solving a system of four coupled non-linear ODEs simultaneously.

Part 3

Connectivity & Plasticity

Learning

How the architecture mathematically alters its own weights based on temporal experience.

07

Synaptic Mechanics

Open Lab →
The Concept

Spikes are electrical, but synapses are chemical. The binary spike must be converted into a continuous, decaying conductance change in the postsynaptic neuron.

The Analogy

The Chemical Ferry. You drive a car (electrical spike) to a river (synaptic cleft). You must load cargo onto a ferry (neurotransmitters), which drifts across to unlock gates on the other side.

The Math

Modeled using an "Alpha Function" to simulate the rise and exponential decay of synaptic conductance (gsyng_{syn}).

gsyn(t)=gˉsyntτsyne1tτsyng_{syn}(t) = \bar{g}_{syn} \frac{t}{\tau_{syn}} e^{1 - \frac{t}{\tau_{syn}}}
Implementation

When the presynaptic neuron fires, trigger this function to temporarily increase the conductance in the postsynaptic neuron's differential equation, altering its voltage.

08

STDP & Hebbian Learning

Open Lab →
The Concept

Spike-Timing-Dependent Plasticity (STDP). The precise millisecond timing of pre- and post-synaptic spikes dictates whether a weight increases (LTP) or decreases (LTD).

The Analogy

The Perfect High-Five. If Neuron A reaches out and Neuron B meets it at the exact same millisecond, there is a perfect connection (LTP). If A swings too early or too late, it's awkward, and the connection weakens (LTD).

The Math

Weight changes (Δw\Delta w) are an exponential function of the time difference (Δt=tposttpre\Delta t = t_{post} - t_{pre}).

Δw={A+eΔt/τ+if Δt>0AeΔt/τif Δt<0\Delta w = \begin{cases} A_+ e^{-\Delta t / \tau_+} & \text{if } \Delta t > 0 \\ -A_- e^{\Delta t / \tau_-} & \text{if } \Delta t < 0 \end{cases}
Implementation

Track the spike times of two connected LIF neurons. Continuously update the synaptic weight matrix W based on the Δt window.

Part 4

Systems & Populations

Emergent Behavior

Scaling up: Thoughts, rhythms, and computations only appear in network dynamics.

09

Population Feedback

Open Lab →
The Concept

Brains require Excitatory (E) and Inhibitory (I) balance. Without inhibition, networks suffer from runaway excitation (seizures).

The Analogy

The Predator-Prey Ecosystem. Excitatory neurons are rabbits; Inhibitory are wolves. If rabbits multiply, wolves eat them, driving activity down, allowing rabbits to recover. This creates stable brain waves (oscillations).

The Math

The Wilson-Cowan equations use Mean-Field Theory to model the firing rates of populations.

τEdEdt=E+f(wEEEwEII+Iext)\tau_E \frac{dE}{dt} = -E + f(w_{EE}E - w_{EI}I + I_{ext})
τIdIdt=I+f(wIEEwIII)\tau_I \frac{dI}{dt} = -I + f(w_{IE}E - w_{II}I)

Where f(x)f(x) is a non-linear sigmoid activation function.

Implementation

Build a network of 800 Excitatory and 200 Inhibitory LIF neurons. Tune the W_EI and W_IE weights until the entire population shows synchronous, rhythmic bursting.

10

Neural Decoding

Open Lab →
The Concept

Reverse-engineering the spike code. If a network receives a stimulus, how mathematically certain can we be about what the network "saw"?

The Analogy

The Expert Detective. You only have the tapped-out Morse code from informants (spike trains). By analyzing the frequency of the taps, you mathematically reconstruct the suspect's face.

The Math

Calculating Shannon Entropy (HH) and Mutual Information to quantify how many "bits" of data the spike train contains about the stimulus.

H(X)=P(x)log2P(x)H(X) = -\sum P(x) \log_2 P(x)
Implementation

Feed your network different stimulus angles (e.g., 0° to 180°). Plot a Tuning Curve (Firing Rate vs. Stimulus Angle). Use Maximum Likelihood Estimation (MLE) to predict which angle caused the spikes.