Why this project exists: building a working, non-invasive brain-computer interface — one that reads a whole human brain without surgery or electrodes — is blocked by 10 specific missing-link inventions (mapped out in BCI v2). v3 is the engine built to invent those 10 missing links: for each blocker it proposes concrete, buildable designs and — crucially — grades every one against the hard laws of biophysics, physics, and electronics, so we keep only what could physically work.
How it works: a local-LLM invention engine paired with a law-based simulator. Pick one of the 10 missing-link innovations, add a prompt (constrained to non-invasive / biomolecular approaches by default — no electrodes), and the engine proposes a design that the simulator then grades. Invention proposes; only the physics can move the score — so a persuasive idea that violates a law still fails.
🌐 Live site: sanjaydoc.github.io/Brain-Computer-Interface-v3 · 🕹 Cockpit: /app/
Author: Dr. Sanjay Anbu
The cockpit (
docs/app/) — v1's theme and floating-card cockpit view. Pick a topic + a creative lens + a prompt, hit Invent + Simulate, and the law simulator grades the design live: the verdict card (pass/fail + limiting number + metrics), the candidate design aside (proposed parameters + assumptions + risks), and the scorecard for all 10 topics.
The capstone — 🧬 Synthesize. When all 10 blockers have a passing design, the button unlocks and fuses them into one end-to-end non-invasive brain-uploading system: a schematic of the whole
Label → Read → Map → Emulatepipeline wrapped in a human-safety envelope, plus the consolidated bill of materials and a step-by-step "how it works." Ten solved problems → one complete system.
10/10 → unlocked, and every synthesis is saved as a prototype. Each
synthesizerun is stored in thesynthesestable (MongoDB · JSONL fallback), so you build a library of prototypes — listed under Saved prototypes (andbci synthesize --history), each clickable to reopen its full schematic. Improve a blocker's design, re-synthesize, and compare systems over time.Curated prototype presets. With a rich library (several inventions per topic), the Synthesize dropdowns let you hand-pick which invention feeds each of the 10 stages. Six ready-made, internally coherent combinations ship as presets — build any with one command instead of setting 10 dropdowns:
bci synthesize --preset echo # or lumen | swift | guardian | titan | vanguard bci synthesize --list-presets # show all six with descriptions
echois the fully-acoustic flagship (every stage chains through ultrasound/photoacoustic); the others trade for resolution, leanness, safety margin, raw performance, or future scale. See PROTOTYPES.md for the exact per-topic picks and the reasoning behind each build.
Every saved prototype can be exported as a ~25–30 page journal-style research paper — the document an actual lab would work from. Each Saved prototypes row has a 📕 Research button next to 📄 PDF:
The monograph is generated server-side (GET /api/research/{id}) and opens print-ready in the browser
(→ Save as PDF). It is written in proper IMRaD form — structured abstract, numbered sections,
governing equations, per-blocker prior-art/gap analysis, and Vancouver references — and every number is
a value the law simulator actually accepted, with the document explicitly framed as an in-silico design
study for real experimental follow-up.
For each of the ten blockers the paper gives the objective, the governing model, the design and its accepted parameters, a computed figure showing the set-points clearing the threshold, a worked quantitative check, materials, an experimental protocol, failure modes, and an expected empirical benchmark. It closes with an integrated interface budget, a stage-gated translational roadmap (TRL 2 → first-in-human), a discussion with a sensitivity ranking, and limitations.
Wet-lab program. §5.1 lists one concrete experiment per module (E1–E10) — the experiment to run, the model system, the primary readout, and the quantitative success criterion — mapped to that prototype's actual modules and ordered to de-risk the hardest couplings (barcoding and deep read) first:
A real invention from local Qwen (
bci record snr_depth "focused ultrasound, deep cortex, low thermal dose, safe") — the biomimicry lens turned an eardrum into a focused-ultrasound transducer array. Every invention is captured in full: mechanism, the law simulator's per-domain read (biophysics · physics · electronics · biology), proposed parameters, materials, protocol, parts, assumptions, and risks — click any saved invention to read it like this.
The same run as a static graph. Green = the proposed design is physically admissible in-model; the right-hand tag is the fidelity of that verdict (
full-sim= fully modelled;physics-only/estimate/limits-only= honestly partial).
Read the entire invention. Click any saved design and it opens in full — the header verdict (pass/fail · score · fidelity · limiting factor), the mechanism, the law simulator's per-domain read (biophysics · physics · electronics · biology), every proposed parameter, the parts list, and the assumptions and risks. Nothing is truncated.
- ✅ Port the inventor-studio-v3 invention pipeline — 10 creative lenses + critic/MVP reasoning, converted Node → Python.
- ✅ Local-LLM-first — runs on your Qwen 7B via
LOCAL_LLM_URL, NVIDIA NIM fallback, rule-based fallback with no LLM at all. - ✅ All 10 innovation topics from the v2 map, each with a target spec + parameter schema.
- ✅ Law-based simulator — biophysics · physics · electronics engines grade every design.
- ✅ Invent → simulate → refine loop — failures feed the limiting number back to the engine.
- ✅ Candidate ranking — one design per lens, ordered by simulated score (an idea tournament).
- ✅ Honest fidelity flags — a pass means physically admissible, never proven in a living brain.
- ✅ 34 tests, deterministic — the whole pipeline runs offline in CI.
- ✅ Cockpit GUI — v1's theme + cockpit view; pick a topic, invent, and watch the law simulator grade it live in the browser.
- ✅ Thin FastAPI backend — the cockpit calls the Python engine (and your local Qwen) live; auto-detected, graceful browser fallback.
- ✅
.envconfig — pasteLOCAL_LLM_URL/LOCAL_LLM_MODEL/NVIDIA_API_KEYonce (zero-dependency loader, git-ignored). - ✅ GUI model picker — the cockpit auto-detects the models you've pulled (Ollama) and lets you choose which one invents; each record stores its model, so the simulator A-Bs them.
- ✅ Approach constraint — a Non-invasive (biomolecules) / Invasive (electrodes) selector that hard-constrains the design, so the engine returns molecular, non-invasive inventions by default (no stray electrode-on-brain proposals).
- ✅ Auto-save to a database — every invention (design + multi-domain detail + parts + score) is captured in MongoDB, grouped by the 10 categories, with delete; JSONL fallback when Mongo is down.
- ✅ Literature grounding — searches PubMed · arXiv · USPTO · PubChem · GitHub · SearXNG · Wikipedia and invents from the retrieved prior art; citations are stored with the record.
- ✅ Benchmark —
bci benchsweeps topics × N samples → pass-rate + mean-score leaderboard per category (A-B models), saved to the DB. - ✅ Synthesize — once all 10 blockers have a passing design, fuse them into one end-to-end brain-uploading system: a schematic of the whole
Label → Read → Map → Emulatepipeline (inside a human-safety envelope), the consolidated parts list, and how it works. The button unlocks only at 10/10. - ✅ Mix-and-match prototypes + 6 curated presets — hand-pick which invention feeds each of the 10 stages from per-topic dropdowns, or build a ready-made coherent combination in one command (
bci synthesize --preset echo|lumen|swift|guardian|titan|vanguard). Every run is saved to thesynthesestable as a reusable prototype. - ✅ Research-grade monograph per prototype — a 📕 Research button (and
GET /api/research/{id}) renders any saved prototype as a ~25–30 page journal-style paper: structured abstract, governing equations, per-blocker sections with computed figures + worked derivations, an integrated interface budget, a stage-gated translational roadmap, discussion, and Vancouver references — print-ready to Save as PDF. - ✅ Per-prototype wet-lab plan — §5.1 of the monograph gives one concrete experiment per module (E1–E10) with model system, primary readout, and quantitative success criterion, mapped to that prototype's actual modules.
- ⬜ Amber topics as full estimators — richer models for assembly / twin-sim at scale (Phase 4).
The goal of the whole program is a working, non-invasive brain-computer interface. v1 interfaces with a connectome; v2 maps it and pins down the 10 missing-link inventions — the blockers that stand between today and a non-invasive human brain map. v3 exists to invent those 10 missing links — and refuses to take the invention's word for it, grading each against physical law:
pick 1 of 10 topics + prompt
│
▼
RETRIEVAL (PubMed · arXiv · USPTO · PubChem · GitHub · SearXNG · Wikipedia)
→ prior-art context to ground the design
│
▼
INVENTION ENGINE (local Qwen, ported from inventor-studio-v3)
→ candidate design: mechanism + parameters + assumptions + risks + citations
│
▼
LAW SIMULATOR — grades the parameters against:
🧬 biophysics (coverage, reporter kinetics, thermal/AAV safety limits)
〰️ physics (wave attenuation → SNR/depth, resolution wall, capacity law)
🔌 electronics (channels, bandwidth, scan-time, array feasibility)
│
▼
pass / fail + limiting number → auto-save to MongoDB (grouped by category)
The two halves are kept separate on purpose: a persuasive narrative can never fake a passing score — only the physics moves the number.
| # | Topic | Layer | Domain | Laws | Fidelity |
|---|---|---|---|---|---|
| 1 | In-vivo, non-destructive barcode readout | 🧬 bio · 🔌 hw | life-science | physics, biophysics | physics-only |
| 2 | Massively-multiplexed reporters | 🧬 bio | life-science | physics, electronics | full-sim |
| 3 | Trans-synaptic pairing at scale | 🧬 bio | life-science | physics | full-sim |
| 4 | ~100% neuron delivery | 🧬 bio | cell-therapy | biophysics | full-sim |
| 5 | Signal boost + noise cut (SNR) | 🔌 hw · 🧬 bio | electronics | physics, biophysics | full-sim |
| 6 | Whole-brain scan throughput | 🔌 hw | hardware | electronics | full-sim |
| 7 | Exabyte assembly + error-correction | 💻 sw · 🧠 tpl | software | electronics | estimate |
| 8 | Whole-brain twin simulation | 💻 sw · 🌐 venv | software | electronics | estimate |
| 9 | Behavioural upload-verification | 🌐 venv | software | physics | full-sim |
| 10 | Human safety of the whole chain | 🧬 bio · 🔌 hw | cell-therapy | biophysics | limits-only |
6 fully-modelled, 4 honestly flagged. Domains map onto inventor-studio-v3's taxonomy (software · hardware · electronics · life-science · cell-therapy · hybrid).
Ported from inventor-studio-v3 — ten creative lenses frame the reasoning, then the model must return a design whose numeric parameters the simulator can grade:
analogical · inversion · crossDomain · extreme · historical · biomimicry · combinatorial · reduction · scaling · future
rank() runs one candidate per lens and orders them by simulated score — a small idea tournament.
Requires Python 3.10+ and git. (Optional: a local Ollama + Qwen for real invention, and MongoDB for storage — both auto-detected, both have graceful fallbacks.)
Create the venv at the repo root (one venv for the whole project) and install the backend as an editable package.
Windows (PowerShell)
# first time — clone:
git clone https://github.com/sanjaydoc/Brain-Computer-Interface-v3.git
cd Brain-Computer-Interface-v3
# already cloned — update instead: cd Brain-Computer-Interface-v3 ; git pull origin main
# from the repo root:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned # one-time, allows venv activate
python -m venv .venv # create the venv (at the repo root)
.\.venv\Scripts\Activate.ps1 # ACTIVATE (prompt shows (.venv))
pip install -e "backend[api,db]" # install: api = cockpit server, db = MongoDB driver
.\serve.ps1 # ▶ RUN → open http://localhost:8000/app/macOS / Linux (bash / zsh)
# first time — clone:
git clone https://github.com/sanjaydoc/Brain-Computer-Interface-v3.git
cd Brain-Computer-Interface-v3
# already cloned — update instead: cd Brain-Computer-Interface-v3 && git pull origin main
# from the repo root:
python3 -m venv .venv # create the venv (at the repo root)
source .venv/bin/activate # ACTIVATE (prompt shows (.venv))
pip install -e "backend[api,db]" # install: api = cockpit server, db = MongoDB driver
./serve.sh # ▶ RUN → open http://localhost:8000/app/Extras:
api(cockpit server) anddb(MongoDB driver) are all you need to run. To also run the tests and the matplotlib scorecard, adddev,plot:pip install -e "backend[dev,plot,api,db]", then verify withpython -m pytest backend -q→ 34 passed.
cd Brain-Computer-Interface-v3 # ← the repo root
.\serve.ps1 # Windows → http://localhost:8000/app/cd Brain-Computer-Interface-v3 # ← the repo root
./serve.sh # macOS / Linux → http://localhost:8000/app/The launchers find the venv for you (flags pass through: .\serve.ps1 --port 9000).
Without a local model the cockpit still runs on the deterministic browser proposer. For real LLM inventions, install Ollama, pull a Qwen model, and point the engine at it.
# 1) pull a model (7B is the recommended default; 3B is faster on small GPUs)
ollama pull qwen2.5:7b # recommended — clean JSON, good inventions
ollama pull qwen2.5:3b # optional — lighter / faster fallback
# 2) start the Ollama server (leave it running)
ollama serve # serves the OpenAI-compatible API on http://localhost:11434
# 3) warm the model once so the first invention isn't slow
ollama run qwen2.5:7b "hello"Then tell BCI which model to use. Put this in backend/.env (created once, git-ignored):
LOCAL_LLM_URL=http://localhost:11434/v1
LOCAL_LLM_MODEL=qwen2.5:7bVerify it's wired: bci ping (one tiny timed call — confirms the model works and how fast) and
bci health (shows the active provider). To A-B models per run, pass --model:
bci invent snr_depth "deep, safe" --model qwen2.5:3b. Full LLM troubleshooting → RUN.md.
# Windows — from the repo root:
.\.venv\Scripts\Activate.ps1# macOS / Linux — from the repo root:
source .venv/bin/activateWith the venv active (your prompt shows (.venv)), these work from any directory:
bci serve # API + cockpit on one port
bci health # LLM provider / database / search sources
bci ping # one tiny timed LLM call — is the model working & fast?
bci topics # list the 10 innovation topics
bci invent multiplexed_reporters "deep, safe" # invent + simulate, one-shot
bci record in_vivo_readout "non-destructive" # search → invent → simulate → save to DB
bci record neuron_delivery "AAV, crosses BBB" --constraint noninvasive # biomolecular only (no electrodes)
bci record scan_throughput "whole brain fast" --constraint invasive # electrodes / implants allowed
bci record snr_depth "deep, safe" --no-ground # skip the literature search (faster)
bci invent snr_depth "deep, safe" --model qwen2.5:3b # pick the model for this run (A-B models)
bci search "gas vesicle acoustic reporter" # preview retrieved literature (per-source status)
bci bench --samples 5 # leaderboard across all 10 topics
bci db --stats # counts + pass-rate per categoryApproach constraint:
--constraint noninvasive(default in the GUI) forces a biomolecular design — no electrodes, implants, or surgery; use--constraint invasiveto allow hardware. It's the approach constraint dropdown in the cockpit, and it's saved with every record.
First LLM run using
fallbackinstead of your model? Runbci ping— it fires one tiny timed call and prints the exact cause (wrong model, timeout, JSON-grammar hang, Ollama crash) with the one-line fix. See RUN.md § 7 · Troubleshooting.
Set LOCAL_LLM_URL + LOCAL_LLM_MODEL (best in backend/.env), then swap the model — the
physics simulator decides the winner:
# macOS / Linux
LOCAL_LLM_MODEL=qwen2.5:7b bci bench --samples 5
LOCAL_LLM_MODEL=qwen3.5:9b bci bench --samples 5# Windows (PowerShell)
$env:LOCAL_LLM_MODEL="qwen2.5:7b"; bci bench --samples 5
$env:LOCAL_LLM_MODEL="qwen3.5:9b"; bci bench --samples 5import bciv3
cand = bciv3.invent("multiplexed_reporters", "acoustic reporters, deep, safe")
print(bciv3.report("multiplexed_reporters", cand)) # design + verdict + limiting number
print(bciv3.bench.run(samples=3)) # leaderboard across all 10 topicsFull setup — MongoDB, .env, Ollama/Qwen, thinking models, per-OS details → RUN.md.
backend/bciv3/
llm.py local-Qwen-first LLM adapter (→ NIM → cloud → rule-based fallback)
laws/ the simulator: physics.py · biophysics.py · electronics.py
innovations/ the 10 topics — base.py (abstraction) + catalog.py (specs + evaluators)
engine/ invention pipeline: prompt.py (10 lenses) · inventor.py · loop.py
simulator.py route a candidate to its laws → Score
detailer.py multi-domain summary (biophysics/physics/electronics/biology) + parts
recorder.py invent → simulate → detail → save (one timestamped record)
store.py MongoDB persistence (+ JSONL fallback): save / list / grouped / delete
cli.py `bci` CLI: serve · ping · invent · record · bench · db · topics · search
api/app.py FastAPI: serves the cockpit + /api/{invent,record,inventions,rank,models,stats}
backend/tests/ 29 deterministic tests
backend/scripts/ demo_invent.py
docs/app/ the cockpit GUI (v1 theme) — served by `bci serve`
"Passes the simulator" means physically admissible under the model — that the design doesn't
violate a known law of biophysics, physics, or circuit feasibility. It does not mean proven in
a living brain. The fidelity flags (physics-only, estimate, limits-only) and the safety
topic's deliberately tight margin keep v3 a research-agenda engine, not a discovery oracle: it
prunes the impossible, ranks the plausible, and prints the target numbers to build toward.











