A web-based interactive simulator for spiking neural networks using Brian2 and Flask. Users can configure neuron and network parameters, run simulations, visualize results, and download data.
The main goal of this project is to make neural modeling and simulation with Brian2 accessible and user-friendly, lowering the barrier for learning, teaching, and rapid prototyping in computational neuroscience.
- LIF (Leaky Integrate-and-Fire): Classic computational neuron model
- Izhikevich: Biologically realistic with various firing patterns
- AdEx (Adaptive Exponential): Advanced model with adaptation currents
- Custom: Write your own differential equations, threshold, and reset rules
- Random (Erdős–Rényi): Basic random connectivity patterns
- Small World (Watts-Strogatz): Local clustering with long-range shortcuts
- Scale-Free (Barabási–Albert): Hub-based networks with power-law degree distribution
- Regular Lattice: Structured ring networks with uniform connectivity
- Modular: Community-based networks with intra/inter-module connectivity
- Interactive plots (Plotly): Zoomable, pannable visualizations
- Static plots (Matplotlib): Publication-ready figures
- Network topology visualization: See the actual connectivity structure
- Multiple output types: Voltage traces, spike rasters, and network graphs
- Preset scenarios: Quick-start configurations for common network types
- Parameter validation: Real-time input checking with helpful error messages
- Configuration management: Save/load simulation setups with validation
- Data export: CSV and JSON formats for further analysis
- Code generation: Automatically generate Brian2 Python scripts
- Responsive UI: Modern, accessible, and mobile-friendly design
- Automatic cleanup: Old output files are automatically deleted to save disk space
- Memory management: Smart cache cleanup prevents memory buildup
- Python 3.8+
- Brian2
- Flask
- matplotlib
- pandas
- numpy
- plotly
- networkx
All dependencies are listed in requirements.txt
.
-
Clone the repository:
git clone https://github.com/Metanome/brian2sim-web.git cd brian2sim-web
-
Install dependencies:
pip install -r requirements.txt
-
Run the app:
python app.py
-
Open your browser: Go to http://127.0.0.1:5000/
-
Configure and run simulations:
- Adjust parameters or select a preset in the left panel
- Choose your desired network topology and connection parameters
- Select neuron model (LIF, Izhikevich, AdEx, or custom)
- Click "Run Simulation" to see plots and download data
- Use output options to switch between interactive and static plots
brian2sim-web/
├── app.py # Main Flask application and routes
├── simulator.py # Core Brian2 simulation logic
├── topology.py # NetworkX-based network topology generation
├── plotting.py # Visualization utilities (Matplotlib & Plotly)
├── models.py # Neuron model definitions
├── code_generator.py # Python code generation utilities
├── requirements.txt # Python dependencies
├── templates/
│ └── index.html # Main UI template
├── static/
│ ├── css/
│ │ └── style.css # Responsive UI styling
│ └── js/
│ └── main.js # Frontend logic and interactions
└── output/ # Auto-cleaned simulation results
The app includes robust configuration management:
- Save configurations: Export your simulation setups as JSON
- Load configurations: Import previously saved setups with validation
- Local storage: Browser remembers your settings between sessions
- Validation: Configurations are validated before loading to prevent errors
Perfect for:
- Teaching computational neuroscience: Students explore concepts without coding
- Research prototyping: Quickly test network hypotheses
- Learning network theory: Visualize how topologies affect neural dynamics
- Parameter exploration: Understand relationships between parameters and behavior
- Memory management: Automatic Brian2 cache cleanup prevents memory buildup
- Temporary files: Plots and data are auto-cleaned after 3 minutes
- Input validation: Comprehensive error checking with user-friendly messages
- Mobile responsive: Optimized for tablets and mobile devices
- Large simulations (many neurons or long durations) may take significant time to run
- Very dense networks with many neurons may impact browser performance for interactive plots
- Custom equations require basic knowledge of Brian2 syntax
- Additional neuron models: Hodgkin-Huxley, Morris-Lecar, and more
- Live Plot Option: Implement real-time updates of the plots using JavaScript refresh techniques.
Contributions are welcome! Please feel free to submit pull requests or open issues for:
- Bug fixes
- New neuron models
- Additional network topologies
- UI/UX improvements
- Documentation enhancements
- Brian2 for the powerful simulation engine
- NetworkX for graph theory and network analysis
- Flask for the lightweight web framework
- Plotly for interactive plotting capabilities
- Matplotlib for publication-quality static plots
If you use this software in your research, please cite:
@software{brian2sim_web,
title={Brian2 Web Simulation App},
author={Metanome},
year={2025},
url={https://github.com/Metanome/brian2sim-web},
license={GPL-3.0}
}