culture-sim: why this exists

this repo builds a simulated dish of brain cells, and then checks that the simulation actually behaves like a real one.

if none of that means anything yet, start here.

People are growing neurons on chips

you can take stem cells, turn them into neurons, and grow them on a chip covered in tiny metal electrodes. the chip is called a microelectrode array, or MEA. every electrode listens for the small voltage blips neurons produce when they fire. on stimulation-capable arrays some electrodes can also inject a pulse of current to make nearby neurons fire. this means that its usually far fewer than can record, and plenty of MEAs are record-only.

so you have a two-way interface to a few hundred thousand living cells. you can write to them and read from them.

in 2022 a group at cortical labs grew on the order of a million cultured cells on an array and had them play pong [1]. ball position was encoded as stimulation on 8 electrodes: which electrode fired told the cells where the ball was vertically, and the stimulation rate ramped from 4 Hz to 40 Hz as the ball got closer to the paddle [1]. the cells' own firing was read back and used to move the paddle. when the paddle hit the ball the system delivered a predictable stimulus; when it missed, random noise [1].

over a twenty minute session the rallies got longer. the paper calls this apparent learning, and it's worth knowing that a large group of researchers publicly disputed the interpretation. they argue the control conditions don't support the claims that were made [3]. i take the setup seriously and the framing with a pinch of salt.

that's the field. cortical labs now sells a machine called the CL1. a swiss company, finalspark, rents remote access to 16 human brain organoids over a python api for around $500 a month per user, free for some research projects [4]. a bunch of academic groups do the same work without the branding. uc santa cruz's braingeneers, the takahashi lab in tokyo, sandvig and nichele at ntnu.

The constraint that shapes everything

the pong setup pushed all its sensory input through 8 electrodes [1].

eight. and that number wasn't the chip's limit. the array carried 26,400 electrodes, could read 1,024 of them at once, but had only 32 stimulation units, and in practice the team couldn't route more than 8 of those independently [1][2].

that asymmetry is the real constraint. you can listen to a thousand sites and talk back through a handful. artifact, charge injection limits and crosstalk are what make dense independent stimulation hard, not the electrode count. every problem i have noticed in this field comes back to that gap between how much you can read and how little you can write. the substrate is enormous and the input is a straw.

another noticeable issue is that these cultures are alive, so they change. they develop, they drift, cells die [5]. finalspark's organoids last around 100 days on average [4]. whatever mapping you worked out between your stimulation and their response on monday is probably a different mapping by friday, and a very different one three weeks later.

i want to be honest that this last bit is a hypothesis, not a measured fact. i haven't found a published curve showing an in vitro decoder degrading over days the way the brain-computer interface literature has measured for implants. quantifying it is one of the things this repo is for.

i am willing to take a shot at these problems from an engineer's perspective.

The problem i actually hit

i don't really have a wet lab. and i don't know if remote access will be consistently available. so i did the obvious thing and built a simulated culture in brian2, a python library for spiking neural network simulation. a thousand neurons, 80% excitatory and 20% inhibitory, connected randomly, with spike-timing-dependent plasticity, which is a rule that strengthens a connection when the input fires just before the output, and weakens it when the order reverses [6].

the 80/20 split is the standard ratio for cortex in a living animal. dissociated and ipsc-derived cultures don't necessarily match it, and the ratio moves with protocol and age. i used it because it's the default, not because i measured it.

my first version spiked and settled into stable activity, but it would not burst the way a real culture does. and then i hit the question that stops the whole thing: how do i know it behaves anything like a real dish?

i don't. i had no evidence either way. i wrote plausible equations and got plausible-looking output, which is not the same as being right about anything. any result i produce on top of it. "feedback delay of 30ms breaks learning," "this drift correction works" are claims about my simulation, not about neurons. that's worth very little.

the specific failure was bursting. real cultures do something distinctive: long silence, then a sudden burst where most electrodes fire at once, then silence again, with gaps measured between 1 and 300 seconds across 58 cultures in the first five weeks after plating [5]. my network either fired steadily forever or ran away into a seizure. nothing in my equations could stop a burst once it started.

what fixed it was short-term synaptic depression, the tsodyks-markram model, where a synapse that fires repeatedly temporarily runs out of resources and weakens, then recovers over a few hundred milliseconds to a second or so. that terminates the burst, and the recovery time sets the gap before the next one.

i want to be careful here, because my first instinct was to write that depression is the only way to get bursting. that's wrong. a network needs some slow negative feedback to end a burst, but depression is only one candidate. spike-frequency adaptation alone is sufficient to produce network bursting, and short-term plasticity is not required to reproduce the characteristic timescales [7]. inhibitory recruitment and extracellular ion dynamics are also published mechanisms. depression is what worked in my model. it isn't the only thing that could have.

that's still the shape of the problem: a model that looks fine and is quietly incapable of the thing you care about.

What "calibrated" means, and what it doesn't

a note on counting first, because the numbers above are inconsistent otherwise. "cells" means everything on the array, neurons and glia together. that's what the million figure counts. "neurons" means the neuronal subset, which is smaller, and it's the number the 80/20 ratio refers to.

the goal is not a copy. a real culture has around a hundred thousand neurons of a dozen types, plus glia, plus dendrites doing their own computation, and it's physically rearranging itself while you watch. my model has a thousand simplified point neurons. so the gap is permanent.

the goal is narrower: the model is allowed to be wrong in ways that don't matter for the questions i'm asking.

i'm going to ask questions about closed-loop timing and about drift. for those, the model needs to produce data with the right statistical texture; burst timing, the spread of firing rates across electrodes, how the input-output mapping shifts over days.

it does not need explicit dendrites or gene expression. that's not because those don't matter. gene expression sets ion channel densities, which shape the exact firing statistics i'm fitting. it's that their effects get absorbed into the fitted parameters rather than modelled directly. i capture them phenomenologically. that's a limitation, not a claim they're irrelevant.

so calibration means picking a list of measurable properties, computing them on real recordings, and searching parameter space until my simulation reproduces them. then stating plainly which properties i matched and which i didn't.

What the repo actually does

5 pieces, in order.

the network model. a thousand leaky integrate-and-fire neurons in brian2, with short-term depression on every synapse and spike-frequency adaptation on every neuron. eight parameters are left free to be fitted; everything else is fixed at values from published papers, with a citation in the code comment for each one.

the virtual MEA. in a real experiment you record from 60 electrodes on a classic array, or up to about 1,024 simultaneous channels on a high-density array that carries 26,400 electrodes in total [2]. the dish holds a hundred thousand neurons. you're seeing a tiny, biased sample.

i put the simulation through the same bottleneck. i place virtual electrodes on a grid, compute a signal amplitude for each neuron's spike that falls off steeply with distance, add recording noise at the measured noise floor of the array i'm imitating, and only count a spike when it crosses the detection threshold. some electrodes are marked dead, because real arrays always have inactive channels. every statistic is then computed on that observed data, never on the full network.

this matters more than it sounds. subsampling doesn't just add noise, it biases estimates. a network with a true branching ratio of 0.99 reads as 0.37 when you sample 100 units, and 0.02 when you sample one [8]. the number you get depends on how many electrodes you have, so two labs with different chips get different answers from identical biology.

the statistics. a fixed list: firing rate distribution across electrodes, burst rate and duration and participation, the full spread of inter-burst intervals, avalanche size and duration distributions, a subsampling-corrected branching ratio [8], and functional connectivity between electrodes.

on avalanches: power-law distributed avalanche sizes are a classic signature of a network sitting near criticality, but whether cultures are genuinely critical is contested, since power laws can come out of processes that aren't. i treat these as descriptive statistics to match, not as evidence of criticality.

cortical labs ships an analysis module with their sdk that computes network bursts and avalanche statistics, so i call theirs rather than writing my own, for comparability. i haven't confirmed it does connectivity. the parts i do write are the bias-corrected branching estimator [8], and a scaling relation between the avalanche exponents that's a more stringent test than any single exponent. albeit even that can be satisfied by some non-critical processes.

the fitting. coarse grid search first, to confirm the model can produce bursting at all and to find the rough neighbourhood. then simulation-based inference: run a few thousand simulations with parameters drawn from a prior, train a network to learn which parameters produce which statistics, then condition on the real data. the output is a distribution over parameters, not a single best guess.

a tight distribution means the data pins that parameter down. a flat one usually means the data can't see it. but it can also mean two parameters are trading off against each other, or that the density estimator is undertrained, so the pairwise posteriors need checking before i conclude anything.

the validation. three tests. fit on burst statistics only, then check whether avalanche statistics come out right without having been fitted. fit two different cultures separately and check the parameters land near each other. then the one that actually matters: fit on spontaneous activity only, and check whether the model predicts the response to stimulation. most closed-loop work stimulates the culture, so a model that only matches resting behaviour is not fit for purpose.

what i'm not doing

no glia, no dendrites, no ion channels, no 3D geometry, no modelling of the culture physically growing. this is a 2D dissociated culture model and it stops at the level where my questions stop.

that 2D scope is a real constraint on what i can calibrate against. finalspark and cortical labs both work with 3D tissue, and organoids and dissociated cultures are measurably different. structured firing sequences have been reported in organoids but not in dissociated primary cultures. i'm fitting against 2D dissociated recordings. i shouldn't and won't claim the fitted model describes an organoid.

i'm also not building an interface layer. cortical labs describe their sdk simulator as a drop-in replacement for their hardware, which is their claim and a fair one for what it's built to do. worth knowing what it isn't, though: its default data source replays a recording or emits poisson spikes. there's no network in it and it doesn't respond to stimulation. it's an api mock, not a model of a culture.

where this sits relative to existing work

people have simulated neuronal cultures before, including with virtual MEAs, and compared the output to real recordings qualitatively. what i haven't found is the end-to-end version: a fixed battery of statistics, parameters fitted by simulation-based inference with a reported posterior, then held-out, cross-culture and stimulation-response tests. the pieces exist separately. i'm claiming the combination, not the idea.

the parts i'm least sure about

the perturbation test is the one i expect to fail first. fitting spontaneous activity and then predicting evoked responses is a real extrapolation, and there's no strong reason to assume eight free parameters can cover both. if it fails, the honest outcome is a model that's useful for drift work and not for stimulation work, and i'd rather say that than quietly drop the test.

and the whole approach rests on an assumption i can't verify from here: that matching these particular statistics is enough for the questions i want to ask. i've picked them because they're the ones the field measures and the ones my downstream work touches.


references

[1] kagan, b.j. et al. (2022). in vitro neurons learn and exhibit sentience when embodied in a simulated game-world. neuron 110(23):3952–3969.e8. doi:10.1016/j.neuron.2022.09.001

[2] müller, j. et al. (2015). high-resolution cmos mea platform to study neurons at subcellular, cellular, and network levels. lab on a chip 15:2767–2780. doi:10.1039/C5LC00133A

[3] balci, f. et al. (2023). a response to claims of emergent intelligence and sentience in a dish. neuron 111(5):604–605. doi:10.1016/j.neuron.2023.02.009

[4] jordan, f.d. et al. (2024). open and remotely accessible neuroplatform for research in wetware computing. frontiers in artificial intelligence 7:1376042. doi:10.3389/frai.2024.1376042

[5] wagenaar, d.a., pine, j. & potter, s.m. (2006). an extremely rich repertoire of bursting patterns during the development of cortical cultures. bmc neuroscience 7:11. doi:10.1186/1471-2202-7-11

[6] bi, g.q. & poo, m.m. (1998). synaptic modifications in cultured hippocampal neurons: dependence on spike timing, synaptic strength, and postsynaptic cell type. journal of neuroscience 18(24):10464–10472. doi:10.1523/JNEUROSCI.18-24-10464.1998

[7] fardet, t. et al. (2018). understanding the generation of network bursts by adaptive oscillatory neurons. frontiers in neuroscience 12:41. doi:10.3389/fnins.2018.00041

[8] wilting, j. & priesemann, v. (2018). inferring collective dynamical states from widely unobserved systems. nature communications 9:2325. doi:10.1038/s41467-018-04725-4