Current source models¶
There is a number of predefined models which can be used with the ModelSpec::addCurrentSource function:
Defining your own current source model¶
In order to define a new current source type for use in a GeNN application, it is necessary to define a new class derived from CurrentSourceModels::Base. For convenience the methods this class should implement can be implemented using macros:
- DECLARE_MODEL(TYPE, NUM_PARAMS, NUM_VARS), SET_DERIVED_PARAMS(), SET_PARAM_NAMES(), SET_VARS() perform the same roles as they do in the neuron models discussed in Defining your own neuron type.
- SET_INJECTION_CODE(INJECTION_CODE) : where INJECTION_CODE contains the code for injecting current into the neuron every simulation timestep. The $(injectCurrent, ) function is used to inject current.
For example, using these macros, we can define a uniformly distributed noisy current source:
class UniformNoise : public CurrentSourceModels::Base { public: DECLARE_MODEL(UniformNoise, 1, 0); SET_SIM_CODE("$(injectCurrent, $(gennrand_uniform) * $(magnitude));"); SET_PARAM_NAMES({"magnitude"}); };