NeuroCode

See inside every step of your EEG & fNIRS analysis.

Running the script yourself gives you a figure at the end and no clue which step caused what. NeuroCode runs it step by step in a real Jupyter kernel, then hands each step — and the real state of your data after it — to an LLM that explains what changed and why that step belongs there. The model writes with the actual result in front of it, not a guess at what the code probably did.

A teaching tool for people learning EEG & fNIRS analysis. Bring your own Claude or Gemini key — everything else stays on your machine.

Free & open source · Built for learning · EEG · MEG · fNIRS

127.0.0.1:8765 — NeuroCode
Your script
Pipeline

Steps are grouped by what they do, not one per line. Every one executes for real — the badges are read back out of the live objects, not guessed.

Made for people still learning this

NeuroCode is a teaching tool first. It's built for students and early-career researchers who can run an MNE-Python script but aren't yet sure what each line is doing to their data — or why the order matters.

New to EEG or fNIRS analysis

Start from a bundled example — EEG preprocessing, epoching, ERP, time–frequency, or the fNIRS chain — read what every step does at Novice depth, and ask follow-up questions on anything that doesn't land.

Handed a lab script

The pipeline you inherited that nobody remembers writing — run it and find out what it actually does before you trust its output.

Coming from EEGLAB / Homer3

You already know the analysis. Look up the MNE equivalent of the functions you use, and translate a script you've got.

Experienced users get use out of it too — but the explanations, the Novice / Intermediate / Expert control and the defaults are all tuned for learning, not for speed.

“Couldn't I just ask ChatGPT?”

You could, and it will hand you code that looks right. The difference is what happens next.

The model sees what happened

The step executes in a real kernel before the LLM says a word. It writes with the actual result in front of it — the sampling rate, the filter band, the trials that survived rejection — read back by introspection. Same class of model, far better context.

🔒 Your recordings stay put

No server, no upload, no account. What reaches the model is your source code and a short summary of the data's shape — sampling rate, channel count, filter band, trial count. Never the signal itself.

It reads the whole script

Explanations, edits and next-step suggestions are grounded in the code you already have and the state of the data at that point — so advice fits your pipeline, not a generic one.

Three things it does

01 · Understand

Annotate a script you were handed

The script from your lab that nobody remembers writing — run it and find out what it does, line by line.

  • Steps grouped semantically and labelled
  • Novice / Intermediate / Expert depth
  • Ask follow-up questions on any step
  • Click a step → its source lines highlight
02 · Write

Generate and edit from plain language

“Band-pass 1–40 Hz and epoch around events.” “Add ICA to remove eye blinks.” Write from scratch or tweak in place.

  • Diff view shows exactly what changed
  • One-click undo
  • Suggested next steps, aware of your research goal
03 · Migrate

Translate EEGLAB / Homer3 → MNE

Paste a .m script. Recognised pop_* / hmrR_* calls are flagged with a confidence rating before translating.

  • Grounded in a curated mapping table, not improvised
  • Says so when it can't map a call, instead of guessing
  • Built-in reference browser for both tables

Works with EEG, MEG and fNIRS objects. Bundled examples use synthetic data, so they run instantly with nothing to download.

About the LLM

The explanations, the code generation and the legacy translation are all LLM-driven — but the model is kept on a short leash, and you own the key.

Grounded in a real run, not free improvisation

Every explanation is generated after the step executes, with the introspected data state in the prompt. Translation is anchored to a curated EEGLAB / Homer3 → MNE mapping table, and flags calls it can't map instead of inventing an answer.

Bring your own key — Claude or Gemini

NeuroCode auto-detects ANTHROPIC_API_KEY (Claude, default claude-haiku-4-5) or GEMINI_API_KEY (Gemini, default gemini-2.5-flash). Cheap, fast defaults; override with NEUROCODE_MODEL. No NeuroCode account, no middleman billing.

Exactly what leaves your machine

Your source code, plus a short JSON summary of the data's shape — sampling rate, channel count and the first few channel names, filter band, epoch count. The recordings themselves are never sent, and nothing goes anywhere else.

No key? It still works

Without a key NeuroCode runs every step, plots every figure and reports the real data state — you just get templated text instead of written explanations. The kernel half needs no LLM at all.

Cached, so you're not paying twice

Explanations are cached on disk keyed by model, level, code and data state. Re-running a script, or clicking back through steps, costs no API call and returns instantly — which matters on a free tier.

Try it in about a minute

No signup, no hosted service — it starts a local server and opens your browser.

bash
$ git clone https://github.com/ruixip/NeuroCode.git
$ cd NeuroCode
$ python3 -m venv .venv && source .venv/bin/activate
$ pip install -e .
$ neurocode                 # opens http://127.0.0.1:8765

To turn the explanations on, copy .env.example to .env and paste in an ANTHROPIC_API_KEY or a GEMINI_API_KEY — the provider is picked automatically. It's optional; see above for what runs without one.

Actively being built — tell me what you need

NeuroCode is under active development, with more updates on the way. It's early enough that your feedback genuinely changes what gets built next: what's confusing, what's missing, and what would make you reach for it while working with your own data.

Watch the repo on GitHub to hear about new releases.