Skip to content

Repository files navigation

FlyLoop

FinalSpark × Janelia — living electrode signals driving a connectome-based digital fly.

FlyLoop brings an embodied fly, animated MaleCNS anatomy, and 32-channel FinalSpark readouts into one browser page. It is an experimental digital-twin interface: recorded biological activity drives a declared neuron model and simulated body. It is not an exact biological twin, a reconstructed living fly brain, or evidence of sentience.

The localhost dashboard with FS-driven simulated flight, animated Janelia anatomy, 32 electrode channels and inspectable signal-to-body readouts

Actual capture of localhost:5173/#arena during the live demonstration. Electrode readouts are measured; connectome dynamics and flight are modeled. Browser chrome and credentials are excluded.

What you can run

  • Fly arena: a 160 mm environment, walking, modeled flight and landing, movable light cues, overview camera and minimap.
  • Janelia neuron model: 166,700 annotated neurons, 25,582,938 directed pairs, and 124,177,617 retained anatomical contacts. Original body IDs and verified graph chunks are preserved.
  • Live FinalSpark input: electrode event rasters, channel rates, freshness and database delay. Missing recordings stop powered movement.
  • Inspectable control: received event timestamps → numerical input decoder → model firing/voltage/spike counts → body speed, turn and altitude. Export the current data and model snapshot as JSON.
  • Notebook analysis: Matplotlib anatomy, connectivity, model responses, measured electrode events and live flight traces.

No FinalSpark account is needed for Janelia model mode. Live mode requires your own authorized Neuroplatform access, current recording configuration, and notebook connection.

Start the demo

Requires Node.js 22.13+ and a browser with WebGL and DecompressionStream. The repository includes about 164 MB of published/derived anatomical assets so the demo does not depend on an external demo server.

git clone https://github.com/4R7I5T/flyloop.git
cd flyloop/demo
npm ci
npm run dev -- --port 5173

Open http://localhost:5173/#arena. Choose Janelia model, then Load & run brain. The complete graph is loaded and SHA-256 checked in a Web Worker. Real FS → fly starts without biological input; follow the FinalSpark setup to connect your own recording.

The full model uses substantial browser memory. The interface reports simulated time separately from wall time; it may run slower than real time.

How the signals connect

flowchart LR
  FS[Measured FS electrode events] --> D[Declared input decoder]
  D --> N[Neuron model on Janelia wiring]
  N --> B[Simulated fly body]
  B --> E[Modeled visual and boundary inputs]
  E --> N
  FS --> V[Channel readouts and exact timestamps]
  N --> V
  B --> V
Loading

The living preparation supplies electrode threshold events, not identified fly neurons. The example decoder reads e08/e10, excludes e09, normalizes current counts by recent baseline, and uses those values to drive the digital motor circuit. Channels do not map to fixed left/right turn commands. Check your own electrode mapping before using this example with another preparation.

Janelia supplies anatomy. Homogeneous LIF dynamics, sensory gains, transmitter signs, and motor decoding are explicit assumptions. DNg100 output powers walking and the surrogate flight animation; a biological flight circuit and muscle physics are not reconstructed. Moving light cues belong to the simulated environment, not to biological decision-making. See model and evidence boundaries.

The current public setup is a recording-to-simulation demonstration. It does not automatically stimulate hardware. Analysis helpers can consume an independently controlled experiment, and a scene predicate supports bounded feedback integration. A private session exercised that command path; the session results distinguish three verified feedback commands from the unestablished claims of evoked control and learning.

Advancing FlyLoop compares pinned FlyGym, Flybody, FlyVis, Shiu and Eon implementations, proposes controlled neural-choice experiments, and documents the offline decoder audit. Physics integration and biological learning remain proposed work.

Notebook and verification

Python 3.11–3.12 is recommended for the FinalSpark SDK environment.

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python bridge/server.py

Open notebooks/FlyLoop.ipynb in your notebook environment. All included cells are read-only with respect to stimulation hardware. No credentials, execution outputs, private recordings or session notebooks are included.

python -m pytest tests
cd demo
npm test
npm run typecheck
npm run lint
npm run build

Rebuilding anatomical assets retains the original public sources and verifies their hashes. Raw bulk downloads are ignored by Git.

Repository map

Path Contents
demo/ Browser arena, connectome, numerical model and recording UI
bridge/server.py Loopback HTTP bridge with separate operator/notebook tokens
notebooks/ Clean notebook, recording, plotting and experiment-analysis helpers
build_*.py, download_connectome.py Public-source anatomical data preparation
tests/, demo/checks/ Neural, decoder, protocol and evidence checks
docs/ Setup, scientific assumptions, data provenance and publication policy

Sources and licensing

MaleCNS data: FlyEM / HHMI Janelia, University of Cambridge, MRC LMB and Google Research, CC BY 4.0. Dataset, project.

Fly body: NeuroMechFly / FlyGym, EPFL Neuroengineering Laboratory, pinned v1.2.1 geometry under Apache-2.0. Original license and file hashes are retained with the meshes.

Original FlyLoop code is MIT licensed. Third-party data and components retain their own licenses; see THIRD_PARTY_NOTICES.md. This project is not an official FinalSpark, Janelia, Google or EPFL product.

About

FlyLoop: FinalSpark electrode activity driving a Janelia connectome-based digital fly, with live readouts and an embodied arena.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages