Skip to content

retrage/drosophila.cpp

Repository files navigation

Drosophila.cpp

This repository contains a minimal leaky integrate-and-fire (LIF) simulator for the adult fly (Drosophila) connectome. The simulator is implemented in a single C++ file (main.cpp) and is driven by CSV connectome data.

Building

Use the provided Makefile:

make

This produces an executable named main. To enable Apache Arrow support pass USE_ARROW=1 (requires Arrow C++ libraries with pkg-config files).

WebAssembly

Emscripten can build the simulator to WebAssembly. Install em++ and run:

make web

The generated web/ directory contains main.js, main.wasm, and a small index.html that runs the example dataset in your browser.

Running

Run the simulator by providing a connectome CSV file and lists of active and silent neurons. When built with Arrow support you may provide a Parquet file instead:

./main --csv connectome.csv --active active.txt --silent silent.txt --t 1000

To load a Parquet file when Arrow support is enabled use:

./main --parquet Connectivity_783.parquet --active active.txt --silent silent.txt --t 1000

The output spike times are written to spikes.bin, and basic statistics are printed to stderr.

Example data

The test/ directory contains small example files (test_connectome.csv, active.txt, silent.txt) that can be used for quick runs or automated tests. A unit test (test/test_submodule.py) demonstrates how to use data from the optional Drosophila_brain_model submodule.

Submodule

Large connectome data can be pulled in via the Drosophila_brain_model submodule. Clone with submodules enabled:

git clone --recurse-submodules <repo url>

Tests

The project includes a Python test that checks the simulator with a small subset of the data. Install the Python dependencies and run:

pip install -r requirements.txt  # pandas and pyarrow are required
pytest

Benchmark

Build and run the Google Benchmark suite to measure performance:

make bench
./bench --benchmark_out=benchmark.json --benchmark_out_format=json

License

This project is provided for educational purposes and comes with no warranty.