This project simulates a spiking neural network (SNN) using a terminal-based user interface built with the ncurses library. The simulation incorporates various biological phenomena such as conduction delays, background noise, synaptic plasticity via spike-timing dependent plasticity (STDP), and neurotransmitter dynamics, offering an insightful and interactive exploration of neural behavior.
To build and run this simulation, you will need:
- GCC: A C compiler that supports C99 (or later).
- ncurses Library: Used for the terminal-based user interface.
- Math Library: Standard math functions (linked via
-lm), e.g., for the exponential function. - Standard C Libraries: Such as
stdlib.h,stdio.h,math.h, andtime.hwhich are typically available on your system.
On most Linux distributions, you can install ncurses using your package manager. For example:
# Debian/Ubuntu:
sudo apt-get install libncurses5-dev libncursesw5-dev
# Fedora:
sudo dnf install ncurses-develThe provided Makefile automates the compilation process.
- Compile the Program:
Run the following command in the project directory:
makeThis will compile the source file (SNN.c) into an executable (named snn by default).
- Compile in Debug Mode:
For debugging symbols, use:
make debug- Run the Simulation:
After compiling, start the simulation by running:
./snnThis simulation models a simplified biological neural network using the integrate-and-fire model, where each neuron behaves as follows:
- Integration: Neurons accumulate synaptic currents and external inputs over time.
- Firing: When the membrane potential reaches a predefined threshold, the neuron fires (produces a spike), then resets its potential.
- Refractory Period: After firing, neurons enter a refractory period during which they cannot fire again, mimicking biological recovery.
- Leak: The membrane potential decays over time, simulating the natural leakage of charge in neurons.
- Synaptic Plasticity (STDP): The simulation adjusts the strength of synaptic connections based on the relative timing of spikes, enabling learning-like behavior.
Several mathematical concepts form the backbone of this simulation:
-
Integrate-and-Fire Dynamics:
- Neurons integrate inputs over time.
- When the membrane potential VV reaches the threshold (V≥THRESHOLDV≥THRESHOLD), the neuron fires and resets to V=RESET_POTENTIALV=RESET_POTENTIAL.
- Neurons integrate inputs over time.
-
Exponential Decay: * The potential decays each time step by a factor defined as LEAK_FACTORLEAK_FACTOR, simulating the natural leakage of ions.
-
Spike-Timing Dependent Plasticity (STDP): * Potentiation (LTP): When the pre-synaptic neuron fires shortly before the post-synaptic neuron: Δw=A+⋅e−Δtτ+ Δw=A+⋅e−τ+Δt
-
Depression (LTD): When the post-synaptic neuron fires shortly before the pre-synaptic neuron: Δw=A−⋅e−Δtτ− Δw=A−⋅e−τ−Δt * These adjustments allow synapses to strengthen or weaken based on the timing of neuronal activity.
-
Conduction Delays:
- Synaptic delays are incorporated to simulate the finite speed of neural signal propagation.
-
Noise:
- Random background noise mimics the inherent variability observed in biological neural networks.
* Real-Time Visualization: The ncurses-driven UI offers a dynamic, real-time view of neuronal activity directly in the terminal.
* Biologically Inspired: This simulation provides an accessible model of how real neurons communicate, learn, and adapt through STDP.
* Educational Value: It serves as a hands-on tool for understanding neural dynamics, integration, and the effect of synaptic plasticity.
* Customizability: With easily adjustable parameters and modular code, you can experiment with various aspects of neural behavior or extend the simulation to more complex models.
* Interactive Experience: Watch how neurons fire, how potentials evolve, and how synaptic weights change over time, all in a terminal-based environment.
Enjoy exploring the fascinating dynamics of spiking neural networks!