Python bindings for the Neun neural simulation library. High-performance computational neuroscience with an intuitive Python interface.
- Multiple neuron models - Hodgkin-Huxley, Hindmarsh-Rose, and more
- High performance - C++ speed with Python convenience
- Synaptic coupling - Electrical and diffusion synapses
- Type safe - Strongly typed bindings prevent errors
- Extensible - Add custom models through JSON configuration
- NumPy integration - Seamless array operations
pip install neun_pygit clone https://github.com/GNB-UAM/neun_py.git
cd neun_py
makeimport neun_py
import matplotlib.pyplot as plt
# Create Hodgkin-Huxley neuron
args = neun_py.HHDoubleConstructorArgs()
neuron = neun_py.HHDoubleRK4(args)
# Set parameters
neuron.set_param(neun_py.HHDoubleParameter.gna, 120 * 7.854e-3)
neuron.set_param(neun_py.HHDoubleParameter.gk, 36 * 7.854e-3)
# Initialize
neuron.set(neun_py.HHDoubleVariable.v, -65)
# Simulate
times, voltages = [], []
for i in range(100000):
neuron.add_synaptic_input(0.1)
neuron.step(0.001)
if i % 100 == 0:
times.append(i * 0.001)
voltages.append(neuron.get(neun_py.HHDoubleVariable.v))
plt.plot(times, voltages)
plt.xlabel('Time (ms)')
plt.ylabel('Voltage (mV)')
plt.savefig('spike.pdf')Full Documentation - Complete guides and API reference
Quick Links:
See the examples/ directory:
basic.py- Single neuron simulationsynapsis.py- Coupled neurons with electrical synapse
Run with:
python examples/basic.py --plot output.pdf
python examples/synapsis.py --plot coupled.pdf| Model | Short Name | Description |
|---|---|---|
| Hodgkin-Huxley | HH |
Classic conductance-based model |
| Hindmarsh-Rose | HR |
Simplified bursting model |
| Izhikevich | Iz |
simplified model of neuronal activity |
Each model supports:
- Precisions:
Float,Double - Integrators:
RK4(4th order),RK6(6th order)
Example class names: HHDoubleRK4, HRFloatRK6
make # Build and install in development mode
make clean # Remove build artifacts
make test # Run tests
make dist # Build distributions- Create C++ header in
include/neun/models/ - Add entry to
models.json - Rebuild with
make clean && make
See Adding Models Guide for details.
Contributions welcome! See Contributing Guide.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
- ✅ Free to use and modify
- ✅ Open source required for derivatives
- ✅ Network use requires source availability
See LICENSE for full text.
If you use this software in your research, please cite:
@software{lareo2025neun,
title = {Neun},
author = {Angel Lareo},
year = {2025},
url = {https://github.com/GNB-UAM/Neun}
}- Documentation: https://gnb-uam.github.io/neun_py/
- Neun library: https://github.com/GNB-UAM/neun
- Source code: https://github.com/GNB-UAM/neun_py
- Issue tracker: https://github.com/GNB-UAM/neun_py/issues
Made with ❤️ by Angel Lareo