A computational reproduction of the whole-brain Drosophila melanogaster spiking neural network model based on the FlyWire connectome.
This repository reproduces the computational model from the Nature paper:
A Drosophila computational brain model reveals sensorimotor processing Philip K. Shiu, Gabriella R. Sterne, Nico Spiller, Romain Franconville, et al. Nature 634, 210-219 (2024) DOI: 10.1038/s41586-024-07763-9
This implementation is modified from the original repository by Philip Shiu and collaborators.
The model implements a leaky integrate-and-fire (LIF) spiking neural network of the entire adult Drosophila central brain, containing:
- 127,400 neurons derived from the FlyWire connectome
- ~50 million synaptic connections with excitatory/inhibitory weights
- Biologically realistic parameters:
- Membrane time constant: 20 ms
- Synaptic time constant: 5 ms
- Refractory period: 2.2 ms
- Resting potential: -52 mV
- Threshold potential: -45 mV
- Synaptic delay: 1.8 ms
The dynamics follow the LIF equations:
dv/dt = (v_rest - v + g) / tau_m
dg/dt = -g / tau_syn
Where v is membrane potential, g is synaptic conductance, tau_m is membrane time constant, and tau_syn is synaptic time constant.
- Whole-brain simulation: Simulates all 127,400 neurons with their complete connectivity
- Sensorimotor processing: Models gustatory (taste) and mechanosensory pathways
- Multiple input modalities: Sugar, bitter, water sensing, and Johnston's organ neurons (JON)
- Silencing experiments: Supports inhibiting specific neuron populations
- GPU acceleration: Built on JAX for efficient parallel computation
- Python 3.9+
- CUDA-compatible GPU (recommended for full simulations)
pip install BrainX pandas seabornfrom drosophila_whole_brain import Network, run_one_exp
import brainstate
import brainunit as u
# Define neurons to stimulate (sugar-sensing gustatory receptor neurons)
neu_sugar = [
720575940624963786, 720575940630233916, 720575940637568838,
# ... additional FlyWire neuron IDs
]
# Run simulation
firing_rates = run_one_exp(
neurons_to_excite=[{'ids': neu_sugar, 'rate': 150 * u.Hz}],
duration=1000 * u.ms,
dt=0.1 * u.ms,
)import brainstate
import brainunit as u
import numpy as np
from drosophila_whole_brain import Network
with brainstate.environ.context(dt=0.1 * u.ms):
net = Network(
path_neu='./2023_03_23_completeness_630_final.csv',
path_syn='./2023_03_23_connectivity_630_final.parquet',
neuron_to_excite=[
{'ids': neu_sugar, 'rate': 150 * u.Hz},
],
)
brainstate.nn.init_all_states(net)
# Run for 1000 timesteps
indices = np.arange(10000)
spks = brainstate.transform.for_loop(
lambda i: net.step_run(i, ret_val='spike'),
indices
).
├── README.md # This file
├── drosophila_whole_brain.py # Core simulation module
├── brainstate_figures.ipynb # Jupyter notebook reproducing paper figures
├── 2023_03_23_completeness_630_final.csv # Neuron metadata (FlyWire IDs)
├── 2023_03_23_connectivity_630_final.parquet # Synaptic connectivity matrix
└── sez_neurons.pickle # SEZ neuron type classifications
The brainstate_figures.ipynb notebook reproduces key figures from the paper:
- Figure 1D: Whole-brain activity when activating sugar GRN
- Figure 1E: Which neurons activate MN9 motor neuron
- Figure 1F: Silencing experiments
- Figure 2: Which cell types activate MN9
- Figure 3: Sugar + bitter / sugar + IR94e interactions
- Figure 4: Water GRN activation and interactions
- Figure 5: Johnston's organ neuron (JON) experiments
Run the notebook:
jupyter notebook brainstate_figures.ipynbThe connectome data is derived from:
- FlyWire - A complete whole-brain connectome of Drosophila
- Data version: 2023_03_23, completeness threshold 630
If you use this repository, please cite:
@software{wang2025drosophila,
author = {Wang, Chaoming},
title = {chaobrain/drosophila\_whole\_brain\_snn\_simulation: Release Version 0.1},
year = 2025,
publisher = {Zenodo},
doi = {10.5281/zenodo.17791458},
url = {https://doi.org/10.5281/zenodo.17791458}
}@article{shiu2024drosophila,
title = {A Drosophila computational brain model reveals sensorimotor processing},
author = {Shiu, Philip K. and Sterne, Gabriella R. and Spiller, Nico and
Franconville, Romain and Sandoval, Andrea and Zhou, Joie and
Bhardwaj, Neha and Prieto-Godino, Lucia L. and Bhalla, Upinder S. and
others},
journal = {Nature},
volume = {634},
number = {8032},
pages = {210--219},
year = {2024},
publisher = {Nature Publishing Group},
doi = {10.1038/s41586-024-07763-9}
}@misc{shiu2024drosophila_code,
author = {Shiu, Philip K.},
title = {Drosophila brain model},
year = {2024},
publisher = {GitHub},
url = {https://github.com/philshiu/Drosophila_brain_model}
}This project is licensed under the Apache License 2.0 - see the source files for details.
- FlyWire consortium for the connectome data
- Philip Shiu and collaborators for the original model implementation
- BDP Ecosystem for the brainstate/brainunit/brainevent frameworks