C++ code references
Base spiking dynamics
Defines
-
MAX_POTENTIAL_SLOPE
Cutoff value of potential slope [mV/ms].
-
OSCILLATORY_AMPLITUDE_MIN
Minimal value for an oscillatory input to be considered valid [pA].
Typedefs
-
typedef std::vector<double> dynamical_state
-
class Spike
- #include <neurons_base.hpp>
A spike object is a weight and arrival time.
This object is the one through which neurons communicate. The overriden ‘operator <’ is used to insert the spike in the priority queue of the neuron.
Public Functions
-
inline Spike(float weight, double arrival_time)
-
inline Spike(float weight, double arrival_time)
-
class Synapse
- #include <neurons_base.hpp>
A weight-delay connection object between two neurons.
The method fire() of the synapse creates a spike and adds it to the spike queue of the postsynaptic neuron.
Public Functions
-
void fire(EvolutionContext *evo)
-
inline void set_delay(float new_delay)
-
inline float get_delay()
-
int get_efferent_pop_id()
Public Static Attributes
-
static float min_delay = std::numeric_limits<float>::infinity()
Smallest synaptic delay of the model. Used to check timestep.
Private Members
-
void fire(EvolutionContext *evo)
-
class Neuron
- #include <neurons_base.hpp>
The base spiking dynamical object.
This class is a virtual base class. The explicit dynamic model must override the
evolve_state()
method.The main method of
Neuron
isevolve()
, in which are called in sequence:on_spike()
(ifspike_flag
is true)
To declare a new neuron:
override the
evolve_state
methodadd the neuron to neuron_type enum class
After profiling, it became evident that spike processing has a significantly greater impact on computational cost than I had initially anticipated. Therefore, each improvement attempt should start with an analysis of
handle_incoming_spikes()
.Subclassed by aeif_neuron, aqif2_neuron, aqif_neuron, izhikevich_neuron
Public Functions
-
inline dynamical_state get_state()
-
Neuron(Population *population)
-
virtual ~Neuron() = default
-
void evolve()
The evolution function
-
void connect(Neuron *neuron, double weight, double delay)
Connection function. Adds an efferent synapse to the synapse list.
-
void handle_incoming_spikes()
Manages the incoming spikes.
-
void emit_spike()
Makes the neuron’s efferent synapses fire
-
inline double getV()
-
inline void set_evolution_context(EvolutionContext *evo)
-
virtual void on_spike()
The actions to take when the model has a spike
-
inline virtual void evolve_state(const dynamical_state&, dynamical_state&, const double)
The differential equations of the neuron
-
class NeuroParam
- #include <neurons_base.hpp>
A container for the parameters of each neuron type.
This class is necessary to store population-wise the information about the neurons and to grant efficient access to parameter values
Subclassed by aeif_param, aqif_param, izhikevich_param
Public Functions
-
NeuroParam()
Builds the default neuroparam. External currents are set to zero.
-
NeuroParam(ParaMap ¶map)
Constructor of
NeuroParam
given aParaMap
-
inline string get_neuron_type()
-
void add(const std::string &key, float value)
Public Members
-
ParaMap paramap
-
float E_l
Rest potential [mV].
-
float V_reset
Reset potential [mV].
-
float V_peak
Spike-emission threshold [mV].
-
float E_ex
Excitatory synaptic potential [mV].
-
float E_in
Inhibitory synaptic potential [mV].
-
float C_m
Membrane potential [pF].
-
float tau_ex
Excitatory synapse decay time [ms].
-
float tau_in
Inhibitory synapse decay time [ms].
-
float tau_refrac
Refractory time.
-
float I_e
External current (constant) amplitude [nA].
-
float I_osc
External current (oscillatory) amplitude [nA].
-
float omega_I
External current (oscillatory) angular frequency [rad/s].
Protected Attributes
-
string neur_type
-
NeuroParam()
-
class NeuroFactory
- #include <neurons_base.hpp>
A factory for generating neuron objects.
Public Types
-
typedef std::function<NeuroParam*(ParaMap)> neuroparam_constructor
Public Functions
-
inline void add_neuron(string neuron_model, neuron_constructor nc, neuroparam_constructor npc)
-
inline NeuroParam *get_neuroparam(string neuron_model, ParaMap ¶ms)
Public Static Functions
-
static inline NeuroFactory *get_neuro_factory()
-
template<class NP>
static inline NeuroParam *neuroparam_maker(ParaMap params)
Private Functions
-
inline NeuroFactory()
Private Members
-
map<string, neuron_constructor> neuro_constructors_
-
map<string, neuroparam_constructor> neuroparam_constructors_
Private Static Attributes
-
static NeuroFactory *instance = nullptr
-
typedef std::function<NeuroParam*(ParaMap)> neuroparam_constructor
Devices
Devices for the quilt multiscale simulator.
This file contains the declarations of:
monitors:
injectors:
- Author
Gianluca Becuzzi (becuzzigianluca@gmail.com)
- Copyright
Copyright (c) 2024 Gianluca Becuzzi
Typedefs
-
typedef std::vector<double> dynamical_state
-
class PopulationMonitor
- #include <devices.hpp>
Base class for population monitors.
Subclassed by PopulationRateMonitor, PopulationSpikeMonitor, PopulationStateMonitor
-
class PopulationRateMonitor : public PopulationMonitor
Public Functions
-
inline PopulationRateMonitor(Population *population)
-
virtual void gather() override
Disclaimer: this section is cumbersome due to the redundancy of the ‘get_history()’ methods. For now this is somewhat a patch, in future I will make it more clean (for the procrastination demon: today is feb 29 - 2024 )
-
vector<float> get_history()
Protected Attributes
-
vector<float> history
-
inline PopulationRateMonitor(Population *population)
-
class PopulationSpikeMonitor : public PopulationMonitor
- #include <devices.hpp>
Monitor for the variable
Population::n_spikes_last_step
Monitor for the variables
Population::neurons::state
Public Functions
-
inline PopulationSpikeMonitor(Population *pop)
-
virtual void gather()
-
vector<int> get_history()
Protected Attributes
-
vector<int> history
-
inline PopulationSpikeMonitor(Population *pop)
-
class PopulationStateMonitor : public PopulationMonitor
Public Functions
-
inline PopulationStateMonitor(Population *pop)
-
virtual void gather()
-
vector<vector<dynamical_state>> get_history()
Protected Attributes
-
vector<vector<dynamical_state>> history
-
inline PopulationStateMonitor(Population *pop)
-
class PopInjector
- #include <devices.hpp>
Virtual base class for population injectors.
Subclassed by InhomPoissonSpikeSource, PoissonSpikeSource, PopCurrentInjector
Public Functions
-
inline PopInjector(Population *pop)
-
virtual ~PopInjector() = default
-
inline virtual void inject(EvolutionContext*)
Public Members
-
Population *pop
-
inline PopInjector(Population *pop)
-
class PopCurrentInjector : public PopInjector
- #include <devices.hpp>
Constant current population injector.
-
class PoissonSpikeSource : public PopInjector
- #include <devices.hpp>
Source of poisson-distributed spikes.
For now only one-to-one connection is implemented
Public Functions
-
PoissonSpikeSource(Population *pop, float rate, float weight, float weight_delta, double t_min, double t_max)
-
virtual void inject(EvolutionContext *evo) override
Generates spikes until a spike is generated in another time bin to prevent the spike queue from being uselessly too long.
-
void set_rate(float new_rate)
-
PoissonSpikeSource(Population *pop, float rate, float weight, float weight_delta, double t_min, double t_max)
-
class InhomPoissonSpikeSource : public PopInjector
- #include <devices.hpp>
Source of poisson-distributed spikes with time-dependent rate.
For now only one-to-one connection is implemented
- Param pop:
Target spiking population of the source
- Param rate_function:
The rate function r(t). Must be double(double)
- Param weight:
- Param weight_delta:
- Param generation_window_length:
The length of the generation windos in ms
Public Functions
-
InhomPoissonSpikeSource(Population *pop, std::function<double(double)> rate_function, float weight, float weight_delta, double generation_window_length)
Initializes a Inhomogeneous Poisson Spike Source
- Parameters:
pop – The spiking population
rate_function – The rate function. It must have double(double) signature, given a time returns the rate.
-
void _inject_partition(const vector<double> &rate_buffer, double now, double dt, int start_id, int end_id, RNGDispatcher *rng_disp)
Generate one spike for neuron given the current rate
Injects a partition of the target population. For multithreading.
-
virtual void inject(EvolutionContext *evo) override
Creates (easy) population partitions and start threads to generate spikes using
InhomogeneousPoissonSPikeSource::_inject_partition()
Public Members
-
std::shared_ptr<PerformanceManager> perf_mgr
Private Members
-
std::function<double(double)> rate_function
-
float weight
Weight of the spikes.
-
float weight_delta
Semidispersion of the weight of the spikes.
-
std::vector<float> weights
-
double generation_window_length
-
double currently_generated_time
-
RNG rng
-
std::vector<double> integration_start
-
std::vector<double> integration_leftovers
-
std::vector<double> integration_thresholds
Private Static Attributes
-
static ThreadSafeFile outfile
Neuron models
-
class aqif_neuron : public Neuron
- #include <neuron_models.hpp>
The adaptive quadratic integrate-and-fire neuron.
Parameters are hold in an
aqif_param
object\[ C_m \frac{dV}{dt} = k(V-V_{rest})(V - V_{thr}) - w \]\[ \tau_w \frac{dw}{dt} = -w + a(V-V_{rest}) \]On spike:
\[ V\rightarrow V_{reset} \]\[ w \rightarrow w + b \]Public Functions
-
aqif_neuron(Population *population)
-
void evolve_state(const dynamical_state &x, dynamical_state &dxdt, const double t) override
-
virtual void on_spike() override
The actions to take when the model has a spike
-
aqif_neuron(Population *population)
-
class aqif_param : public NeuroParam
- #include <neuron_models.hpp>
Container for parameters of
aqif_neuron
Subclassed by aqif2_param
Public Functions
-
inline aqif_param(ParaMap ¶map)
-
inline aqif_param(ParaMap ¶map)
-
class izhikevich_neuron : public Neuron
- #include <neuron_models.hpp>
The adaptive quadratic neuron model of Izhikevich.
Parameters are hold in
izhikevich_param
object\[ C_m\frac{dV}{dt} = 0.04 V^2 + 5V + 140 - w \]\[ \frac{dw}{dt} = a(b(V-V_{rest})-w) \]Public Functions
-
izhikevich_neuron(Population *population)
-
void evolve_state(const dynamical_state &x, dynamical_state &dxdt, const double t) override
-
virtual void on_spike() override
The actions to take when the model has a spike
-
izhikevich_neuron(Population *population)
-
class izhikevich_param : public NeuroParam
- #include <neuron_models.hpp>
Container for parameters of
izhikevich_neuron
Public Functions
-
inline izhikevich_param(ParaMap ¶map)
-
inline izhikevich_param(ParaMap ¶map)
-
class aeif_neuron : public Neuron
- #include <neuron_models.hpp>
The adaptive exponential integrate-and-fire model.
Parameters are hold in
aeif_param
object\[ \frac{dV}{dt} = - (V - V_{rest}) + \Delta \exp{\left(\frac{V - V_{expthresh}}{\Delta}\right)} - w \]\[ \tau_w \frac{dw}{dt} = -w + a(V-V_{rest}) \]Public Functions
-
aeif_neuron(Population *population)
-
void evolve_state(const dynamical_state &x, dynamical_state &dxdt, const double t) override
-
virtual void on_spike() override
The actions to take when the model has a spike
-
aeif_neuron(Population *population)
-
class aeif_param : public NeuroParam
- #include <neuron_models.hpp>
Container for parameters of
aeif_neuron
Public Functions
-
inline aeif_param(ParaMap ¶map)
Public Members
-
float delta_T
exponential width factor [mV]
-
float V_th
threshold value of the exponential factor [mV]
-
float ada_a
drift coefficient of the recovery variable
-
float ada_b
jump coefficient of the recovery variable
-
float ada_tau_w
timescale parameter of the recovery variable [ms]
-
float G_L
Membrane leak conductance [nS].
-
inline aeif_param(ParaMap ¶map)
-
class aqif2_neuron : public Neuron
Public Functions
-
aqif2_neuron(Population *population)
-
void evolve_state(const dynamical_state &x, dynamical_state &dxdt, const double t) override
-
virtual void on_spike() override
The actions to take when the model has a spike
-
aqif2_neuron(Population *population)
-
class aqif2_param : public aqif_param
Public Functions
-
inline aqif2_param(ParaMap ¶map)
Public Members
-
float V_b
-
inline aqif2_param(ParaMap ¶map)
Oscillators
Warning
This section is under construction. The code is not well defined yet.
A network of oscillators is defined by a matrix of weights \(W_{ij}\) and a matrix of delays \(\Delta_{ij}\).
Functions
-
template<class OSC>
Oscillator *oscillator_maker(ParaMap *params, OscillatorNetwork *osc) Builder method for creating an oscillator instance of a specific type.
- Parameters:
OSC – Type of the oscillator.
params – Parameter map for the oscillator.
osc – Pointer to the oscillator network.
- Returns:
Raw pointer to the created oscillator.
-
OscillatorFactory &get_oscillator_factory()
Singleton method to return a unique instance of OscillatorFactory.
- Returns:
Reference to the OscillatorFactory instance.
-
class Oscillator
- #include <oscillators.hpp>
Base class of oscillators.
The
evolve_state()
method defines the oscillator dynamics and must be overridden.Subclassed by Transducer, harmonic_oscillator, jansen_rit_oscillator, leon_jansen_rit_oscillator, noisy_jansen_rit_oscillator, test_oscillator
Public Functions
-
Oscillator(ParaMap *params, OscillatorNetwork *oscnet)
Constructor for the Oscillator class.
- Parameters:
params – Parameter map for the oscillator.
oscnet – Pointer to the oscillator network.
-
inline ~Oscillator()
-
inline string get_type()
-
inline unsigned int get_space_dimension()
-
inline vector<dynamical_state> get_history()
-
inline double get_past(unsigned int axis, double t)
-
inline vector<double> get_eeg()
-
inline virtual vector<double> get_rate_history()
-
void set_evolution_context(EvolutionContext *evo)
-
void print_info()
Public Members
-
HierarchicalID id
Unique identifier for the oscillator.
-
ParaMap *params
Pointer to parameter map for the oscillator.
-
OscillatorNetwork *oscnet
Pointer to the oscillator network to which the oscillator belongs.
-
ContinuousRK memory_integrator
Continuous Runge-Kutta integrator for storing state history.
-
string oscillator_type = "base"
Type of the oscillator. Default is “base”.
-
unsigned int space_dimension = 2
Dimension of the oscillator’s state space. Default is 2.
-
vector<Link*> incoming_osc
Vector of incoming links to the oscillator.
-
vector<double> input_history
Vector of the history of inputs
-
std::function<void(const dynamical_state &x, dynamical_state &dxdt, double t)> evolve_state
Virtual function representing the evolution of the oscillator’s state.
- Param x:
Current state of the oscillator.
- Param dxdt:
Output for the derivative of the state.
- Param t:
Current time.
-
std::function<double(const dynamical_state &x)> eeg_voi
Virtual function representing the variable of interest for EEG of the oscillator.
Private Members
-
EvolutionContext *evo
Pointer to the evolution context for the oscillator.
-
Oscillator(ParaMap *params, OscillatorNetwork *oscnet)
-
class OscillatorFactory
- #include <oscillators.hpp>
Factory class for creating oscillators of different types.
Public Functions
-
inline bool add_constructor(string const &oscillator_type, constructor const &lker)
Adds a constructor for a specific oscillator type.
- Parameters:
oscillator_type – Type of the oscillator.
lker – Constructor function for the oscillator type.
- Returns:
True if the constructor was added successfully.
-
Oscillator *get_oscillator(string const &oscillator_type, ParaMap *params, OscillatorNetwork *osc_net)
Gets an oscillator instance based on the type.
- Parameters:
oscillator_type – Type of the oscillator.
params – Parameter map for the oscillator.
osc_net – Pointer to the oscillator network.
- Returns:
Pointer to the created oscillator.
-
OscillatorFactory()
Constructor for the OscillatorFactory class.
Private Types
-
typedef std::function<Oscillator*(ParaMap*, OscillatorNetwork*)> constructor
Private Members
-
map<string, constructor> _constructor_map
Map of oscillator types to their corresponding constructors.
-
inline bool add_constructor(string const &oscillator_type, constructor const &lker)
-
class harmonic_oscillator : public Oscillator
Public Functions
-
harmonic_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
Public Members
-
float k
-
harmonic_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
-
class test_oscillator : public Oscillator
Public Functions
-
test_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
Public Members
-
float k
-
test_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
-
class jansen_rit_oscillator : public Oscillator
- #include <oscillators.hpp>
The Jansen-Rit oscillator.
From Jansen, B.H., Rit, V.G. Electroencephalogram and visual evoked potential generation in a mathematical model of coupled cortical columns. Biol. Cybern. 73, 357–366 (1995). https://doi.org/10.1007/BF00199471
Public Functions
-
jansen_rit_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
-
double sigm(double v)
-
virtual vector<double> get_rate_history() override
Public Members
-
float ke
Rate constant for postsynaptic population response to excitatory input [ms^(-1)]. Default 0.1.
-
float ki
Rate constant for postsynaptic population response to inhibitory input [ms^(-1)]. Default 0.05.
-
float He
Maximum amplitude of the excitatory postsynaptic population response [mV]. Default 3.25.
-
float Hi
Maximum amplitude of the inhibitory postsynaptic population response [mV]. Default 22.0.
-
float C
Connectivity constant: pyramidal to spiny stellate. Default 135.
-
float v0
Population mean firing threshold potential [mV]. Default 6.0.
-
float s
Firing rate sigmoid function voltage sensitivity parameter [mV]. Default 0.56.
-
float rmax
Maximum population mean firing rate [ms^(-1)]. Default 0.005.
-
float U
Bifurcation parameter: background constant input [ms^(-1)]. Default 0.13.
-
jansen_rit_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
-
class noisy_jansen_rit_oscillator : public Oscillator
Public Functions
-
noisy_jansen_rit_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
-
double sigm(double v)
-
virtual vector<double> get_rate_history() override
Public Members
-
float ke
Rate constant for postsynaptic population response to excitatory input [ms^(-1)]. Default 0.1.
-
float ki
Rate constant for postsynaptic population response to inhibitory input [ms^(-1)]. Default 0.05.
-
float He
Maximum amplitude of the excitatory postsynaptic population response [mV]. Default 3.25.
-
float Hi
Maximum amplitude of the inhibitory postsynaptic population response [mV]. Default 22.0.
-
float C
Connectivity constant: pyramidal to spiny stellate. Default 135.
-
float v0
Population mean firing threshold potential [mV]. Default 6.0.
-
float s
Firing rate sigmoid function voltage sensitivity parameter [mV]. Default 0.56.
-
float rmax
Maximum population mean firing rate [ms^(-1)]. Default 0.005.
-
float U
Bifurcation parameter: background constant input [ms^(-1)]. Default 0.13.
-
float sigma_noise
Variability of the uniformly distributed white noise. Default 0.0.
-
float epsC_exc_pre
Relative variation of connectivity: C1 -> (1+ delta)*1.0*C.
-
float epsC_exc_post
Relative variation of connectivity: C2 -> (1+ delta)*0.8*C.
-
float epsC_inh_pre
Relative variation of connectivity: C3 -> (1+delta)*0.25*C.
-
float epsC_inh_post
Relative variation of connectivity: C4 -> (1+delta)*0.25*C.
Private Members
-
RNG rng
-
noisy_jansen_rit_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
-
class leon_jansen_rit_oscillator : public Oscillator
Public Functions
-
leon_jansen_rit_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
-
double sigm(double v)
-
leon_jansen_rit_oscillator(ParaMap *params, OscillatorNetwork *oscnet)
-
class OscillatorNetwork
Public Functions
-
OscillatorNetwork(int N, ParaMap *params)
-
OscillatorNetwork(vector<ParaMap*> params)
-
~OscillatorNetwork()
-
void build_connections(Projection *proj, ParaMap *link_params)
-
void build_connections(Projection *proj, vector<ParaMap*> links_params)
-
void initialize(EvolutionContext *evo, double tau, double vmin, double vmax)
-
void evolve()
-
void run(EvolutionContext *evo, double time, int verbosity)
-
inline void set_evolution_context(EvolutionContext *evo)
-
inline EvolutionContext *get_evolution_context()
Public Members
-
HierarchicalID id
-
vector<Oscillator*> oscillators
-
PerformanceManager perf_mgr
-
bool has_oscillators = false
-
bool has_links = false
-
bool is_initialized = false
-
float max_delay
-
float min_delay
Private Members
-
EvolutionContext *evo
-
OscillatorNetwork(int N, ParaMap *params)