Inspiration

The human brain has about 86 billion neurons, and you cannot freely experiment on a living one. We kept asking one question: what if you could build a safe, virtual copy of a brain state and then play with it?

Neuroscience is hard to see. Students memorise "dopamine = reward" but never watch what happens when it changes. Researchers need expensive scanners to study a single condition. We wanted a lab where anyone can turn a knob (drop GABA, raise dopamine, lesion a circuit) and watch the brain, and six different scans, respond in real time.

What it does

Virtual NeuroLab is an educational digital-twin lab that runs entirely in the browser.

  • Build your own brain-state twin. A short battery measures you: heart rate, webcam eye-blink rate (MediaPipe Face Mesh), reaction time, digit-span memory, finger-tapping speed and four self-ratings. These feed six neuromodulator estimates (dopamine, glutamate, GABA, norepinephrine, serotonin, acetylcholine) and six circuit levels.
  • A real spiking-neuron engine. 1,200 Izhikevich neurons in 6 populations (reward, visual, cerebellar, executive, default-mode, stress), 80% excitatory / 20% inhibitory, with long-range projections and dopamine-gated plasticity. Neurochemical sliders change currents and synaptic gains inside the network.
  • A reinforcement-learning task. A 60-trial probabilistic reversal task. We fit a Q-learning model to your choices, report your learning rate $\alpha$ and consistency $\beta$ with 95% confidence intervals, and send every reward as a dopamine pulse into the simulated circuit.
  • Fourteen regions, six scans. Region activations from the simulation drive a colour-coded sagittal MRI-style brain and six synchronised scan panels: EEG (forward model to 13 scalp channels, topomap, spectrum), 7T fMRI BOLD, PET, structural MRI, fNIRS and OPM-MEG.
  • Experiments you could never run safely. Lesion a circuit, stimulate it, block inhibition (a GABA-A antagonist), simulate acute stress or meditation, and watch every panel respond.
  • Radical honesty. A badge always shows whether numbers come from the spiking simulation or a heuristic formula, and every proxy is labelled as a proxy.

How we built it

Front end. Pure HTML/CSS/JavaScript, Canvas 2D for the MRI-style brain and scan panels, MediaPipe Face Mesh for blink detection (eye aspect ratio), no server required.

Neuron model. Each neuron follows the Izhikevich equations:

$$\frac{dv}{dt}=0.04v^2+5v+140-u+I,\qquad \frac{du}{dt}=a\,(bv-u)$$

with the reset rule: if $v\ge 30$ mV then $v\leftarrow c,\; u\leftarrow u+d$. A handful of templates (regular-spiking, bursting, chattering, fast-spiking inhibitory) are cloned with small random jitter in $(c,d)$, which is how we get a large heterogeneous network from a few cell types.

Neuromodulation. Glutamate scales excitatory synaptic weights, GABA scales inhibitory ones, dopamine and acetylcholine add tonic drive to the executive, reward and visual populations, norepinephrine raises gain and noise, serotonin lowers stress and default-mode drive.

Learning. Inter-population excitatory synapses use a three-factor rule: spike-timing eligibility traces $e_{ij}$ are converted into weight change only when a dopamine signal $M(t)$ arrives,

$$\Delta w_{ij}=\eta\,M(t)\,e_{ij}(t).$$

Behavioural fitting. From a person's choices we fit

$$Q_{t+1}(c_t)=Q_t(c_t)+\alpha\,(r_t-Q_t(c_t)),\qquad P(c_t=1)=\frac{1}{1+e^{-\beta\,(Q_t(1)-Q_t(0))}}$$

by maximum likelihood on a grid, and obtain 95% confidence intervals by profile likelihood: all parameter values with $2(\ell_{\max}-\ell)<3.84$.

EEG forward model. 11 dipole sources (frontal, parietal, temporal, occipital, thalamus, hippocampus) are projected through a simple lead field to 13 10-20 channels; spectra come from an FFT and the alpha peak shifts with arousal.

Activation mapping. Population firing rates $r$ are converted to regional activation with a saturating function $A=100\,(1-e^{-r/18})$.

Challenges we ran into

  • Runaway excitation. Our first network exploded to hundreds of Hz. We had to retune recurrent weights until the network was stable and still sensitive to GABA and glutamate changes (verified headlessly in Node).
  • Honesty about proxies. Blink rate to dopamine, reaction time to glutamate: these links are weak or debated. We refused to hide that, so the interface labels them as proxies and shows data provenance.
  • Cloning does not scale compute. Copying 6 neuron types is easy; simulating 86 billion of them is not, and identical clones with random wiring do not think. We learned that function lives in connectivity and plasticity, so we modelled circuits rather than pretending to model a whole brain.
  • Making it feel alive. Rendering a smooth, activation-driven false-colour brain at 30 fps in the browser required per-pixel region weighting and a custom colour map.

Accomplishments that we're proud of

  • A working, mechanistic spiking network that responds correctly in direction to GABA, glutamate and dopamine manipulations.
  • A person-specific behavioural parameter ($\alpha$, with confidence interval) flowing end-to-end into the simulation.
  • A dashboard where every number is traceable to a task, a formula or a simulation, and honestly labelled.

What we learned

  • Biological realism is a ladder, not a switch: single circuits first, then regions, then whole brains.
  • Validity comes from falsifiable models. Hand-written formulas cannot be wrong; a spiking model can, which is exactly why it is more scientific.
  • Good science communication means showing uncertainty (confidence intervals, provenance badges) instead of hiding it.

What's next

  1. Upload real EEG (EDF/CSV) and fit the simulation to the individual's recording (alpha peak, band power) for a verifiable personal twin.
  2. Calibrate synaptic parameters against published cortical data and validate against open EEG/fNIRS datasets.
  3. Add structural connectome priors (diffusion MRI) for individual wiring.
  4. Ethics-approved pilot studies with consent and privacy-first, local-only data handling.

Responsible use

NeuroLab is an educational and research-prototype tool. It is not a diagnostic device, and it must not be used for clinical decisions. All behaviour-to-neurochemical mappings are proxies, and the spiking model is a small circuit-scale simplification, not a whole human brain.

Built With

  • analysis
  • artificial
  • biomedical
  • computing
  • css
  • data
  • html
  • intelligence
  • javascript
  • jupyter
  • learning
  • machine
  • neuroscience
  • notebook
  • numpy
  • plotly
  • psychology
  • python
  • research
  • science
  • scientific
  • scipy
  • statistical
  • streamlit
  • visualization
Share this project:

Updates

Submission history