Regions & stimulus
The four cortical regions
Every neuron belongs to one of four regions, modeled as a Rust enum:
enum RegionKey { Visual, Auditory, Language, Attention }
These match the TypeScript RegionKey type so telemetry round-trips cleanly:
export type RegionKey = 'visual' | 'auditory' | 'language' | 'attention'
Region classification
Region is assigned at construction by classify_region, which normalizes a
neuron's position within the mesh bounding box and applies a set of spatial
rules:
fn classify_region(p: Vec3, min: Vec3, max: Vec3) -> RegionKey {
// nx, ny, nz are normalized 0..1; lateral is distance from the midline
if nz > 0.66 { return RegionKey::Visual; }
if lateral > 0.34 && ny > 0.28 && ny < 0.68 { return RegionKey::Auditory; }
if nx < 0.44 && nz > 0.34 && nz < 0.72 { return RegionKey::Language; }
if ny > 0.58 || nz < 0.28 { return RegionKey::Attention; }
if lateral > 0.24 { RegionKey::Auditory } else { RegionKey::Visual }
}
In rough anatomical terms: the back of the mesh (high Z) is visual, the lateral mid-band is auditory, the left-front is language, and the top or front is attention. The fall-through keeps every neuron assigned.
Injecting stimulus
The UI injects stimulus by calling Brain.injectStimulus, which forwards to the
WASM inject_stimulus:
injectStimulus(opts: { type?: string; intensity?: number; durationMs?: number } = {}): void {
this.world.inject_stimulus(opts)
}
On the Rust side, inject_stimulus:
- Records a
StimulusPulse(region, intensity, duration, expiry timestamp) into telemetry so the response curves can react. - Computes how many signals to release from the intensity:
releases = round(2.0 + intensity * 14.0), at least 1. - Releases those signals onto neurons in the targeted region (or spread across all regions if no region was specified), picking neurons from the region's neuron bucket.
let releases = (2.0 + parsed.intensity * 14.0).round().max(1.0) as usize;
So a higher intensity produces a larger burst of new signals, and the pulse
record drives the onset/sustained response telemetry while it is active. If the
target region is omitted, the burst is distributed round-robin across all four
regions.
See Telemetry for how pulses shape the response index.