Small Brain. Big Trades.
README.md
brain
A whole connectome running as a leaky integrate-and-fire network on the GPU.
Brain.load binds any connectome asset to the package's four lif_*
kernels and returns a network; the FruitFlyBrain component is the usual
owner, and anything holding the network can step, drive, cut, read out and
draw it.
Exports
M.load(connectomeRef, params?) -> Brain— allocate the network at rest.paramsoverrides any ofdtMs,vRest,vThresh,vReset,tauM,tauSyn,refracMs,delayMs,weightMv,gain,minSynapses,traceMs,maxSpikes,seed.brain:update(dt)— once a frame: queue the stepsdtcovers, issue and drain the counter readback.brain:step(n)— queuensteps outright.brain:select(sel) -> { index }— the neurons a selection names.brain:stimulate(sel, hz)/brain:clearStimulation()— Poisson drive.brain:silence(sel, on)— ablate or restore.brain:watch(name, sel)/brain:unwatch(name)/brain:rates()— read groups out as Hz per neuron.brain:activity()— network mean rate, total spikes, dropped spikes, simulated time.brain:info(i)— what one neuron is.brain:showCloud(opts)/brain:hideCloud()/brain:worldPosition(i)— the instanced neuron cloud.brain:setParams(patch),brain:setRunning(on),brain:setTimeScale(x),brain:reset(),brain:ready(),brain:destroy(),brain:describe().
Usage
local Brain = require("~.brain") -- from inside the package
local brain = Brain.load(asset.resolve("fruitFly.maleCNS", "connectome"), { gain = 0.6 })
brain:watch("MN9", { types = { "MN9" } })
brain:stimulate({ types = { "claw_tpGRN" } }, 100)
-- every frame:
brain:update(dt)
print(brain:rates().MN9)
A selection is { types?, typePrefix?, pattern?, classes?, superclasses?, sides?, excitatory?, indices?, limit? }; every given key must hold.
Notes
- The network is silent until something is driven; a spike always traces back to a stimulus.
- Every GPU buffer is named
brain.<id>.<name>;compute.observe()lists them.destroyreleases them all. - The kernels'
paramsare per shader, so two networks on one engine share the model constants the lastapplyParamswrote.