Wiring the Hopeful Brain in Lisp: Modeling 3D White-Matter Tractography and Deep Brain Stimulation in Coni
In neurosurgery, two millimeters is the distance between a life reclaimed and two years of silence.
For over two decades, Subcallosal Cingulate Deep Brain Stimulation (SCC-DBS)—pioneered by Dr. Helen Mayberg, Dr. Andres Lozano, Dr. Patricio Riva-Posse, Dr. Ki Sueng Choi, and colleagues—has offered a lifeline to patients living with severe, intractable Treatment-Resistant Depression (TRD). By implanting hair-thin four-contact electrodes into Brodmann Area 25 (BA25) and delivering continuous 130 Hz electrical pulses, clinicians watched patients who had failed every medication, psychotherapy, and electroconvulsive protocol experience a sudden lifting of visceral dread—and go on to achieve sustained, multi-year remission.
Yet a haunting puzzle stalked the field.
In single-center cohorts guided by individualized diffusion MRI (dMRI) tractography, 2-year response rates climbed past 70–80%. Meanwhile, in the earlier multi-center BROADEN randomized controlled trial—where surgeons relied on standard T1/T2 anatomical landmarks—nearly half of the implanted patients failed to respond. Even more mysteriously, two patients could have electrodes implanted within 2 millimeters of each other in standard MNI brain space: one would recover completely, and the other would feel nothing at all.
Why?
In the October 2026 issue of the American Journal of Psychiatry, a landmark multi-center study led by Ha Neul Song, Ki Sueng Choi, Brian H. Kopell, Martijn Figee, Patricio Riva-Posse, Andres M. Lozano, and Helen S. Mayberg answered that question across 131 TRD patients pooled from three historic cohorts:
Connectomic Determinants of Subcallosal Cingulate Deep Brain Stimulation for Depression
Ha Neul Song, Ki Sueng Choi, Brian H. Kopell, Martijn Figee, Jip de Bruin, Jungho Cha, Patricio Riva-Posse, Alexandre Boutet, Gavin Elias, Jurgen Germann, Sidney H. Kennedy, Lyndahl Himes, Robert E. Gross, Andres M. Lozano, Binith Cheeran & Helen S. Mayberg
American Journal of Psychiatry (October 2026), Vol. 183, Issue 10, p. 764
DOI:10.1176/appi.ajp.20250449| ScienceDaily: Scientists uncover 3 key brain pathways linked to lasting depression relief
When we read the paper, we knew immediately what we had to build.
We opened Coni and built scc-connectome: a complete, zero-dependency 3D MNI152 white-matter tractography generator, anisotropic Poisson electric-field solver, N = 131 longitudinal clinical trial simulator, stereotactic reprogramming optimizer, native ARGB PNG atlas renderer, and Model Context Protocol (MCP) server—all in pure, lint-clean Lisp.

Here is the neuroscience behind those three white-matter highways, and how we modeled the biophysics of depression recovery in 1,100 lines of functional Coni.
1. The Neuroscience: It’s Not the Gray Matter Hub—It’s the White-Matter Crossroads
Early psychiatric neurosurgery treated Brodmann Area 25 like a focal “sadness switch” that needed to be turned down. What Song, Choi, Mayberg et al. (2026) proved across 131 patients is that lasting recovery (≥ 50% drop in the 17-item Hamilton Depression Rating Scale, HAM-D₁₇, at 24 months) is not determined by local gray-matter stimulation alone.
Instead, the Subcallosal Cingulate (MNI [±6.2, +24.5, -9.8] mm) sits at a microscopic four-way white-matter intersection. To pull a brain out of severe depression and keep it well for two years, the electrode’s Volume of Tissue Activated (VTA) must simultaneously capture three primary white-matter fiber bundles (plus an auxiliary subcortical loop):
And what about the patients who failed to improve after two years?
Across every clinical center—Mount Sinai/Emory, the BROADEN RCT, and the University of Toronto—2-year non-responders shared one unmistakable anatomical fingerprint: they missed the Left Cingulum Bundle (CB) and Left Medial Uncinate (UF-VAF). Because the dorsal arching fibers of the left Cingulum Bundle sweep tightly along the superior-medial border of BA25, a mere 1.5 to 2.4 mm ventral or lateral offset (common when targeting by anatomical T1/T2 landmarks without patient-specific dMRI tractography) drops Left Cingulum engagement from 100% to 3%.
2. Modeling 3D MNI152 White-Matter Tractography in src/atlas.coni
To simulate this in scc-connectome, we didn’t want mocked lookup tables. We wanted genuine 3D stereotactic geometry in millimeter MNI152 coordinates.
In src/atlas.coni, each pathway in pathway-catalog carries its empirical fractional anisotropy (:mean-fa), myelinated axon diameter in micrometers (:axon-diameter-um), minimum therapeutic engagement threshold, and clinical metadata:
(def pathway-catalog
[{:id :cingulum-bundle
:short "CB"
:name "Cingulum Bundle"
:rgb [255 215 40]
:primary-three? true
:therapeutic-weight 0.42
:left-dominance-bonus 0.16
:min-effective-engagement 0.68
:axon-diameter-um 3.2
:mean-fa 0.58
:origin "Subcallosal Cingulate (BA25)"
:terminations ["Rostral Anterior Cingulate (BA24)"
"Dorsal Anterior Cingulate (BA32)"
"Posterior Cingulate / Default Mode Hub"]
:clinical-role "Regulates cognitive-emotional integration, dorsal executive attention, and self-referential rumination."
:non-responder-signature "CRITICAL: Across study sites, patients who failed to respond after 2 years consistently lacked stimulation engagement of the LEFT Cingulum Bundle."}
;; ... Forceps Minor (:forceps-minor), Medial Uncinate (:uncinate-amygdalofugal), Subcortical (:subcortical-striatal)
])
How do we generate realistic 3D white-matter fiber bundles that converge through the [±6.2, +24.5, -9.8] mm BA25 confluence hub and then fan out to the anterior cingulate, frontopolar cortex (BA10), and amygdala?
We built a pass-through 3D spline generator (bezier3) that guarantees every fiber streamline passes directly through its individualized confluence waypoint at t = 0.5 without quadratic Bézier overshoot, computes the unit tangent vector t̂ at the confluence node, and assigns fiber-specific Fractional Anisotropy (FA):
(defn spline-1d
"Interpolates 1D coordinate from a through waypoint b (at t=0.5) to c without overshoot."
[a b c t]
(if (<= t 0.5)
(lerp a b (* t 2.0))
(lerp b c (* (- t 0.5) 2.0))))
(defn bezier3
"Evaluates a 3D pass-through trajectory at t in [0, 1] that starts at p0,
passes directly through confluence waypoint p1 at t=0.5, and terminates at p2."
[p0 p1 p2 t]
[(spline-1d (nth p0 0) (nth p1 0) (nth p2 0) t)
(spline-1d (nth p0 1) (nth p1 1) (nth p2 1) t)
(spline-1d (nth p0 2) (nth p1 2) (nth p2 2) t)])
(defn make-streamline-record
"Packages a sampled 3D Bezier fiber streamline with its tangent and Fractional Anisotropy."
[spec]
(let [pts (sample-curve-points (:p0 spec) (:p1 spec) (:p2 spec) (:n-pts spec))
hub-idx (:hub-idx spec)
tangent (vec3-normalize (vec3-sub (nth pts (+ hub-idx 2)) (nth pts (- hub-idx 2))))
hemi (:hemi spec)]
{:id (str (name hemi) "-" (:prefix spec) "-" (:idx spec))
:pathway (:pathway spec)
:hemisphere hemi
:points pts
:confluence-node (nth pts hub-idx)
:tangent tangent
:fa (:fa spec)
:axon-diameter-um (:axon-um spec)}))
Calling (atlas/generate-connectome {:mode :patient-dmri :fibers-per-tract 16}) synthesizes 112 bilateral 3D streamlines (1,984 3D MNI coordinates) with patient-specific anatomical warp vectors in a few milliseconds.
3. Anisotropic VTA Biophysics, Axonal Chronaxie & Shannon Charge Safety (src/biophysics.coni)
White matter is not an isotropic salt-water bath. Myelin sheaths insulate axons transversely while allowing current to propagate preferentially along the longitudinal axis of the fiber bundle, scaled by local Fractional Anisotropy (FA) and the cosine alignment |r̂ · t̂| between the electric field vector and the axon tangent.
In src/biophysics.coni, we model:
- 4-Contact DBS Lead Geometry (
C0–C3): Standard1.27 mmdiameter leads with1.5 mmcontact height and1.5 mmcenter-to-center spacing along the stereotactic trajectory vector[-0.12, 0.08, 0.99]. - FDA / Shannon Charge Density Safety: Checking that charge per phase
Q = I × PWdivided by electrode contact surface area stays strictly within the ≤ 30 µC/cm²/phase tissue-safety ceiling. - Strength-Duration Axonal Activation Threshold: Larger-diameter myelinated fibers (like Forceps Minor at
3.6 µmand Cingulum at3.2 µm) have lower rheobase thresholds than thinner limbic fibers (2.6–2.8 µm), governed by chronaxie (τc = 115 µs):
(defn axonal-activation-threshold-v-mm
"Computes electric field activation threshold (V/mm) using strength-duration curve
modulated by myelinated axon diameter (um)."
[pulse-width-us axon-diameter-um]
(let [chronaxie-us 115.0
base-rheobase 0.165
diam-scale (/ 3.2 (max 1.5 (float axon-diameter-um)))
sd-mult (+ 1.0 (/ chronaxie-us (max 20.0 (float pulse-width-us))))]
(* base-rheobase diam-scale (/ sd-mult 2.28))))
(defn point-electric-field-v-mm
"Computes electric field magnitude (V/mm) at point-mni generated by active contact at contact-mni."
[point-mni contact-mni fiber-tangent amplitude-ma fa]
(let [diff (atlas/vec3-sub point-mni contact-mni)
dist (max 0.35 (atlas/vec3-norm diff))
unit-r (atlas/vec3-normalize diff)
dot-align (math/abs (+ (* (nth unit-r 0) (nth fiber-tangent 0))
(* (nth unit-r 1) (nth fiber-tangent 1))
(* (nth unit-r 2) (nth fiber-tangent 2))))
aniso-boost (+ 0.90 (* 0.55 (float fa) (+ 0.40 (* 0.60 dot-align))))]
(/ (* 0.135 (float amplitude-ma) aniso-boost)
(+ (* 0.42 dist dist) 0.18))))
From the streamline recruitment probabilities across all four bundles, compute-raw-cei and compute-connectomic-index calculate the Connectomic Engagement Index (CEI)—explicitly applying the AJP 2026 Left Cingulum Bundle and Left Uncinate deficit penalty:
(defn compute-raw-cei
"Computes weighted 4-pathway engagement minus Left-CB and Left-UF deficit penalties."
[cb fm uf sst]
(let [w-sum (+ (* 0.38 (:bilateral-engagement cb)) (* 0.30 (:bilateral-engagement fm))
(* 0.24 (:bilateral-engagement uf)) (* 0.08 (:bilateral-engagement sst)))
l-pen (+ (* (max 0.0 (- 0.72 (:left-engagement cb))) 0.55)
(* (max 0.0 (- 0.62 (:left-engagement uf))) 0.30))]
(math/clamp (- w-sum l-pen) 0.0 1.0)))
We also link structural connectome engagement to the electrophysiological biomarkers discovered by Mayberg’s team (Nature, 2023): suppression of pathological BA25 theta/alpha (4–12 Hz) power (-9.4 dB at 24 months in responders) and restoration of prefrontal gamma (35–80 Hz) coherence (0.82).
When we run ../coni-lang/coni main.coni on Case A (an optimal dMRI-guided responder at Contact C1, 4.5 mA) versus Case B (a 2-year non-responder whose left lead sits 2.4 mm ventrolaterally off-target), the terminal tables make the mechanism crystal clear:
┌──────────────────────────────────────────────────────────────────────────────┐
│ CASE A: OPTIMAL CONNECTOME-GUIDED RESPONDER (Contact C1 @ 4.5 mA, 90 us)
├────────────────────────────┬──────────┬──────────┬──────────┬────────────────┤
│ White-Matter Pathway │ Left │ Right │ Min Req │ Engagement │
├────────────────────────────┼──────────┼──────────┼──────────┼────────────────┤
│ CB - Cingulum Bundle │ 100% │ 100% │ 68% │ ██████████ OK │
│ FM - Forceps Minor │ 100% │ 100% │ 62% │ ██████████ OK │
│ UF-VAF - Medial Uncinate Fasci │ 100% │ 100% │ 58% │ ██████████ OK │
│ SST - Subcortical Fronto-St │ 100% │ 100% │ 45% │ ██████████ OK │
├────────────────────────────┴──────────┴──────────┴──────────┴────────────────┤
│ Connectomic Engagement Index (CEI): 100% | 24m Response Prob: 96% | HAM-D Drop: 73%
│ BA25 Theta/Alpha Suppression: -9.4 dB | PFC Gamma Coherence: 0.82 (sustained-recovery-state)
│ Diagnosis: OPTIMAL: All 3 key white-matter pathways (CB + FM + UF-VAF) robustly engaged bilaterally.
└──────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────┐
│ CASE B: 2-YEAR NON-RESPONDER (2.4mm Ventral/Lateral Offset, Left-CB Missed)
├────────────────────────────┬──────────┬──────────┬──────────┬────────────────┤
│ White-Matter Pathway │ Left │ Right │ Min Req │ Engagement │
├────────────────────────────┼──────────┼──────────┼──────────┼────────────────┤
│ CB - Cingulum Bundle │ 3% │ 79% │ 68% │ ████░░░░░░ LOW│
│ FM - Forceps Minor │ 4% │ 94% │ 62% │ █████░░░░░ LOW│
│ UF-VAF - Medial Uncinate Fasci │ 54% │ 98% │ 58% │ ████████░░ LOW│
│ SST - Subcortical Fronto-St │ 3% │ 100% │ 45% │ █████░░░░░ LOW│
├────────────────────────────┴──────────┴──────────┴──────────┴────────────────┤
│ Connectomic Engagement Index (CEI): 12% | 24m Response Prob: 1% | HAM-D Drop: 6%
│ BA25 Theta/Alpha Suppression: -1.2 dB | PFC Gamma Coherence: 0.35 (persistent-depressive-state)
│ Diagnosis: CRITICAL: Insufficient Left Cingulum Bundle & Left Medial Uncinate engagement (classic 2-year non-responder pattern).
└──────────────────────────────────────────────────────────────────────────────┘
Look at Case B: even though the right hemisphere electrode is hitting 79% of the Right Cingulum, 94% of Right Forceps Minor, and 98% of Right Uncinate, the 2.4 mm ventral-lateral slip on the left lead starves the Left Cingulum Bundle (3%) and Left Forceps Minor (4%), collapsing the Connectomic Engagement Index to 12%.
4. Simulating All 131 Patients Across 3 Clinical Cohorts + Abbott TRANSCEND (src/cohorts.coni)
One of the most compelling parts of Song et al. (2026) is how their connectomic model reconciles the historical outcomes of three very different clinical datasets—and lays the blueprint for the ongoing Abbott TRANSCEND multi-center trial.
In src/cohorts.coni, we simulate all 131 AJP patients plus 30 prospective TRANSCEND patients, generating an individualized 3D warped connectome, lead placement, VTA electric field, and 24-month HAM-D₁₇ trajectory (Baseline ➔ 6m ➔ 12m ➔ 24m) for every single patient:
| Clinical Cohort | Patients (N) | Surgical Targeting Method | 24m Response Rate | 24m Remission Rate | 3-Pathway Hit Rate | Left-CB Deficit Rate | Mean 24m HAM-D₁₇ Drop |
|---|---|---|---|---|---|---|---|
| 1. Mount Sinai / Emory Cohort | 42 |
Individualized dMRI Tractography + Connectome Blueprint | 74% | 74% | 74% | 26% | -61% |
| 2. BROADEN Multi-Center RCT | 54 |
Standard Anatomical Landmark Targeting (Pre-Connectomic) | 44% | 26% | 26% | 56% | -44% |
| 3. Univ. of Toronto Founding Cohort | 35 |
Stereotactic T1/T2 Anatomical BA25 Targeting | 43% | 23% | 23% | 57% | -46% |
| Prospective: Abbott TRANSCEND | 30 |
High-Res Individualized 4-Bundle dMRI + VTA Steering | 87% | 87% | 87% | 13% | -67% |
And when we partition all 131 AJP patients into Sustained Responders (n = 70) versus 2-Year Non-Responders (n = 61):
- Sustained Responders (n = 70): Mean Left-CB engagement is 97%, Forceps Minor is 89%, Left-Uncinate is 90%, Left-CB Deficit Rate is 0%, and mean 24-month HAM-D₁₇ reduction is 68%.
- 2-Year Non-Responders (n = 61): Mean Forceps Minor (
76%) and Uncinate (80%) are often partially engaged, but Mean Left-CB engagement plummets to 26% (100%Left-CB Deficit Rate), capping mean HAM-D₁₇ improvement at 28%.
5. Rescuing Non-Responders Without Brain Surgery (src/optimizer.coni)
Here is where computational neuroscience directly transforms patient care.
Suppose a patient underwent SCC-DBS surgery two years ago using anatomical landmarks. Their left lead tip landed slightly too ventral (MNI [-6.8, +23.4, -12.6] mm), and with stimulation delivered at the bottom contact (C0 @ 3.8 mA, 90 µs), their CEI is stuck at 21% (a non-responder with only an 11% HAM-D₁₇ drop).
Does that patient automatically need a second neurosurgery to explant and re-implant the lead?
Not necessarily! Because a DBS lead has four contacts (C0, C1, C2, C3) spaced 1.5 mm apart along a dorsal-angled trajectory, switching the active cathode upward from C0 to C1 or C2 and tuning the current/pulse-width within the FDA Shannon safety limit (≤ 30 µC/cm²) can shift the electric field dorsally right into the Left Cingulum Bundle!
In src/optimizer.coni, optimize-postop-reprogramming sweeps all 14 clinical contact/amplitude/pulse-width combinations (C0–C3, 3.5–6.4 mA, 90–130 µs), checks Shannon charge safety, and either finds a non-invasive reprogramming rescue or flags leads that are > 2.8 mm off-hub as requiring surgical revision:
(defn score-dbs-candidate
"Computes a clinical optimization score balancing CEI, Left Cingulum Bundle engagement,
3-pathway coverage, and minimal current/charge density."
[sim]
(let [out (:outcome sim)
safe? (:safe? (:safety sim))
cei (:connectomic-engagement-index out)
cb (bio/find-pathway-row (:pathway-engagement sim) :cingulum-bundle)
three-bonus (if (:three-key-pathways-engaged? out) 0.18 0.0)
left-cb-bonus (if (:left-sufficient? cb) 0.14 -0.25)
power-cost (* 0.018 (:amplitude-ma (:settings sim)))]
(if (not safe?)
-999.0
(- (+ cei three-bonus left-cb-bonus) power-cost))))
When we run ../coni-lang/coni main.coni optimize, watch how the engine rescues the non-responder in a single pass:
── 3. SURGICAL PLANNING & POST-OPERATIVE REPROGRAMMING ENGINE ───────────────
[Pre-Op dMRI Planner] Optimal Left Lead Tip MNI: [-6.02 24.38 -11.285]
-> Active C1 at [-6.20 24.50 -9.80] (Predicted HAM-D Drop: 73%)
[Post-Op Non-Responder Rescue] Baseline (C0 @ 3.8 mA): CEI 21%, HAM-D Drop 11%
-> RESCUED BY REPROGRAMMING: Switch active cathode to C1 at 5.2 mA / 90 us
to capture dorsal Left Cingulum Bundle fibers without lead revision.
-> Post-Rescue Left-CB: 96% | FM: 100% | Left-UF: 100% | Predicted 24m HAM-D Drop: 72%
By moving the active cathode 1.5 mm dorsally along the existing lead shaft from C0 to C1 and increasing current from 3.8 mA to 5.2 mA (7.8 µC/cm², well below the 30 µC/cm² Shannon limit), Left Cingulum engagement jumps from sub-threshold to 96%, and predicted 24-month HAM-D₁₇ reduction leaps from 11% to 72%.
6. Radical Homogeneity: Native PNG Rendering, MCP Introspection & Zero-Warning Linting
In keeping with The Philosophy of Coni, scc-connectome is architected around four structural invariants:
- Native Stereotactic Visualization (
src/visualizer.coni): Using Coni’s built-in:imageraster engine,render-comparison-atlas-pngprojects all 1,984 3D MNI coordinates onto a960×480coronal slice aty = +25 mm, color-coding recruited vs. unrecruited white-matter streamlines and drawing the active VTA bounding box to producecoronal_vta_comparison.pngin pure Lisp. - Single-Atom State & Unified Command Catalog (
src/mcp_server.coni): All application state lives in a single(def *app-state* (atom ...)), and every capability—:paper-info,:simulate,:reprogram,:cohorts,:render—is registered in a unifiedcommandsmap shared between the CLI and the Model Context Protocol (MCP) server:Any MCP-capable AI agent can call# Launch the HTTP/SSE MCP server on port 8095 for AI agent introspection: ../coni-lang/coni main.coni mcp 8095tool-simulate-dbs-placementortool-optimize-non-responderto run live 3D biophysical simulations and clinical reprogramming sweeps. - Zero-Warning Semantic AST Linting: Every file across
src/,main.coni, andtests/passes Coni’s strict semantic AST linter (../coni-lang/coni lint inspect src main.coni tests) with 0 warnings and 0 errors, and all 14 assertions intests/connectome_test.conipass out of the box.
Try It Yourself
The full source code is available on Gitea at coni-lang/scc-connectome:
git clone https://gitea.hellonico.info/coni-lang/scc-connectome.git
cd scc-connectome
# 1. Run full clinical report, N=131 multi-cohort study, reprogramming rescue & PNG generation
../coni-lang/coni main.coni
# 2. Run the automated test suite & semantic AST linter
../coni-lang/coni test tests/
../coni-lang/coni lint inspect src main.coni tests
From S-expressions and quadratic 3D Bézier splines to the white-matter highways that bring light back to the human brain—here is to precision connectomics, Dr. Mayberg and Dr. Choi’s remarkable team, and building scientific software that fits in the palm of your hand.