Skip to content

GNB-UAM/neun_py

Repository files navigation

Neun Python Bindings

License: AGPL v3 Python 3.8+ Documentation

Python bindings for the Neun neural simulation library. High-performance computational neuroscience with an intuitive Python interface.

Features

  • 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

Quick start

Installation

pip install neun_py

From source

git clone https://github.com/GNB-UAM/neun_py.git
cd neun_py
make

First simulation

import 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')

Documentation

Full Documentation - Complete guides and API reference

Quick Links:

Examples

See the examples/ directory:

Run with:

python examples/basic.py --plot output.pdf
python examples/synapsis.py --plot coupled.pdf

Available models

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

Development

Build system

make              # Build and install in development mode
make clean        # Remove build artifacts
make test         # Run tests
make dist         # Build distributions

Adding models

  1. Create C++ header in include/neun/models/
  2. Add entry to models.json
  3. Rebuild with make clean && make

See Adding Models Guide for details.

Contributing

Contributions welcome! See Contributing Guide.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests
  5. Submit a pull request

License

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.

Citation

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}
}

Links


Made with ❤️ by Angel Lareo

About

Python bindings for the Neun simulation library (https://github.com/GNB-UAM/neun), generated using pybind11 and metaprogramming.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published