📈 Responsive Neurostimulation Device Programming Simulator
This simulation allows users to program a responsive neurostimulation device for epilepsy management, adjusting settings based on seizure patterns and patient feedback.
Placing the RNS System — Cranial Neurostimulator and Seizure-Onset-Zone Leads
The RNS System (NeuroPace, FDA-approved 2013) is the first closed-loop, brain-responsive neurostimulator approved for epilepsy. Unlike open-loop devices such as vagus nerve stimulators, it is implanted directly at the seizure focus itself. A neurosurgeon fits a small titanium neurostimulator into a cranial recess milled into the skull, then tunnels one or two leads — depth electrodes for deep foci (e.g. mesial temporal) or cortical strip electrodes for neocortical foci — to the one or two zones identified during presurgical workup as the epileptogenic focus.
- 2013: FDA approval (NeuroPace RNS System)
- 1–2: Leads implanted (depth and/or cortical strip)
- 1–2: Target zones (mapped by phase-II video-EEG)
- 4–6 wks: Recovery window (before initial detection programming)
Candidate selection and surgical placement
RNS is reserved for drug-resistant focal epilepsy where the seizure onset zone has been localized to one or two regions, but those regions are not safely resectable — commonly bilateral mesial temporal foci, eloquent cortex overlap, or multifocal onset.
Presurgical workup: • Phase-II intracranial (stereo-EEG or subdural grid) monitoring pinpoints onset zone(s) • MRI, PET, and MEG corroborate structural/metabolic correlates • Neuropsychological and Wada testing assess eloquent-cortex risk
Implant procedure: • Craniotomy fits the neurostimulator into a custom-milled cranial recess, flush with the skull surface (cosmetically inconspicuous) • Depth leads (4 contacts) are stereotactically placed into deep structures like hippocampus/amygdala • Cortical strip leads (4 contacts) are laid over neocortical onset zones • Leads connect to the neurostimulator via a subgaleal connector; device is battery-powered (replaced surgically roughly every 4–8 years)
After a 4–6 week healing period, the clinician begins the initial ECoG-detection programming phase — the device does not deliver any stimulation until detection is validated against real seizure recordings.
Onboard ECoG Pattern Detection — Watching the Brain's Electrical Signature in Real Time
Once implanted, the neurostimulator continuously samples electrocorticographic activity from up to four bipolar channels (two per lead), 24 hours a day, entirely within the implant — there is no external recording station required for detection to function. A suite of low-power onboard detection tools scans this incoming signal in real time for the electrographic patterns that precede or accompany the patient's seizures.
- 4: ECoG channels (2 bipolar pairs per lead)
- 24/7: Monitoring (continuous, onboard)
- 4 types: Detector tools (half-wave, line-length, area, bandpass)
- thousands: Stored episodes (onboard flash memory)
Detection algorithms and onboard signal processing
The RNS neurostimulator runs up to two detectors per lead, each independently configurable, drawing from a small library of validated pattern-detection tools:
• Half-wave (spike) detector — flags rapid amplitude excursions consistent with epileptiform spikes • Line-length detector — sums the absolute point-to-point signal length over a moving window; sensitive to rhythmic, high-frequency ictal onset • Area detector — integrates rectified signal energy over a window; catches broader amplitude buildups • Bandpass detector — isolates a specific frequency band (e.g. low-gamma) associated with the patient's ictal rhythm
Each detector compares its running statistic against a programmed threshold; crossing the threshold for the programmed minimum duration counts as a "detection." Detections are timestamped, and a snippet of raw ECoG around each one is stored onboard (limited by flash memory to several thousand episodes) for later clinical review — this stored record is what makes iterative reprogramming possible.
Programming Detection Thresholds — Tuning Sensitivity Against False Positives
Raw detector output is useless without careful threshold programming. In clinic, the physician plays back stored ECoG episodes — including confirmed seizures captured during a diagnostic recording phase — and adjusts each detector's amplitude threshold, frequency band, and minimum duration until the device reliably flags true epileptiform activity while ignoring chewing artifact, eye movement, or ordinary sharp transients.
- ≤2: Detectors per lead (independently tunable)
- 3: Tuned parameters (amplitude, frequency band, duration)
- q1–3 mo: Typical programming visits (during initial optimization)
- max sens.: Goal (min false-positive stimulation)
The sensitivity / false-positive trade-off
Every detection threshold sits on a spectrum:
• Low threshold (high sensitivity): the device catches nearly every true epileptiform event, including subtle ones — but also triggers on benign transients, artifact, and normal variability, delivering stimulation the patient never needed. Frequent unnecessary stimulation can also accelerate battery depletion. • High threshold (low sensitivity): the device stimulates cleanly, almost exclusively on genuine events — but risks missing early, low-amplitude epileptiform activity, letting it evolve into a clinical seizure before the device reacts.
Programming is iterative: initial thresholds are set conservatively from the diagnostic recording, then progressively tightened over follow-up visits as more stored episodes reveal the patient's true pattern variability. The detection sensitivity and false-positive-rate metrics in this simulator move in opposite directions as the threshold slider changes, illustrating exactly this trade-off that clinicians navigate visit by visit.
Closed-Loop Response — Delivering Stimulation Before the Seizure Begins
The defining feature of the RNS System is speed: the instant a programmed detector crosses threshold, the device delivers a brief burst of charge-balanced, biphasic electrical current through the same leads that detected the abnormal activity — typically within about 100 milliseconds. The goal is to disrupt the abnormal network synchronization at its earliest, most localized stage, before it can recruit surrounding cortex and become a clinical seizure with observable symptoms.
- ~100 ms: Response latency (detection to stimulation onset)
- biphasic: Pulse waveform (charge-balanced, safety limit)
- 0.5–12 mA: Current range (device maximum; typically low-mA)
- usually none: Patient sensation (stimulation is imperceptible)
Stimulation parameters and the abortion mechanism
Stimulation is programmed as a burst: current amplitude, pulse frequency, pulse width, and burst duration are each independently set. Higher current amplitude generally increases the probability that a given detected event is successfully desynchronized before it propagates — but with diminishing returns, since network disruption depends on reaching enough of the local abnormal population without simply saturating the tissue response, and excessive current raises the (still generally low) risk of local discomfort or after-discharges.
Because a single detection can retrigger repeatedly during a sustained abnormal run, the device can deliver several sequential stimulation bursts in response to one evolving episode, escalating through programmed therapy tiers if the first burst does not resolve the pattern. Most patients report no sensation at all during therapeutic stimulation, since the leads are on/in cortex without conscious sensory representation, and current levels stay below any perceptual or afterdischarge threshold once properly programmed.
Because the electrical pulse is delivered locally, only through the leads already positioned at the onset zone, and lasts a fraction of a second, RNS stimulation is generally imperceptible to the patient and does not interrupt daily activity — a key practical difference from rescue medications or externally-triggered interventions.
Closing the Loop Over Months and Years — Data Review and Long-Term Optimization
Every detection and stimulation event is timestamped and stored onboard with an ECoG snippet. The patient periodically uploads this data via a home remote monitor and tablet; the clinician reviews detection accuracy, adjusts thresholds and stimulation settings, and tracks seizure diary correlation across successive quarterly (then increasingly spaced) visits. This slow, data-driven optimization loop is why RNS efficacy has been shown to keep improving for years after implantation, unlike a fixed-parameter therapy.
- ~44%: Median reduction, yr 1 (RNS pivotal trial)
- ~66%: Median reduction, yr 6 (long-term registry follow-up)
- ~75%: Median reduction, yr 9 (extended long-term follow-up)
- majority: Responder rate (≥50%) (of patients by later years)
The remote-monitoring and reprogramming cycle
Data pathway: • Patient places the wand-based remote monitor near the implant; stored ECoG episodes and event logs upload wirelessly • Data syncs to a secure web portal the clinical team reviews before each visit • Physician correlates device-detected episodes against the patient's seizure diary to check for both under- and over-detection
Reprogramming decisions made from this data: • If confirmed seizures were missed → lower threshold or add a detector tuned to the missed morphology • If false detections dominate → raise threshold, narrow frequency band, or lengthen minimum duration • If detections are accurate but seizures still break through → increase stimulation current, pulse count, or add escalating therapy tiers • If battery longevity is a concern with a very sensitive/high-output program → trim conservatively once efficacy is established
This cycle typically runs every 1–3 months during the first year, then stretches to twice-yearly or annual visits as the program stabilizes. Long-term, multi-year registry data from the RNS System has shown seizure frequency reductions that continue to deepen over time — a pattern attributed to this ongoing, individualized closed-loop tuning rather than any single fixed setting.
This simulation allows users to program a responsive neurostimulation device for epilepsy management, adjusting settings based on seizure patterns and patient feedback.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install