Skip to content

Commit

Permalink
Fix third-factor plasticity buffering and add third factor plasticity…
Browse files Browse the repository at this point in the history
… tutorial
  • Loading branch information
C.A.P. Linssen committed Sep 27, 2024
1 parent cb4fa30 commit 22ba93a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ along with NEST. If not, see <http://www.gnu.org/licenses/>.
**/

// uncomment the next line to enable printing of detailed debug information
// #define DEBUG
#define DEBUG

namespace nest
{
Expand Down Expand Up @@ -740,13 +740,6 @@ void get_entry_from_continuous_variable_history(double t,

{%- if paired_neuron_name is not none and paired_neuron_name|length > 0 %}
double timestep = 0;
/**
* Updates due to post-synaptic spikes since last pre-synaptic spike.
*
* t_lastspike_ contains the point in time of the last spike. So we read the history (t_last_spike - dendritic_delay, ..., __t_spike - dendritic_delay]
*
* Note that this also increases the access counter for these entries which is used to prune the history.
**/
std::deque< histentry__{{ paired_neuron_name }} >::iterator start;
std::deque< histentry__{{ paired_neuron_name }} >::iterator finish;
{
Expand All @@ -758,14 +751,12 @@ void get_entry_from_continuous_variable_history(double t,
* Note that this also increases the access counter for these entries which is used to prune the history.
**/

// get spike history in relevant range (t1, t2] from post-synaptic neuron
std::deque< histentry__{{ paired_neuron_name }} >::iterator start;
std::deque< histentry__{{ paired_neuron_name }} >::iterator finish;
{%- if vt_ports is defined and vt_ports|length > 0 %}
double t0 = t_last_update_;
{%- endif %}

{%- if paired_neuron_name is not none and paired_neuron_name|length > 0 and paired_neuron.state_vars_that_need_continuous_buffering | length > 0 and continuous_state_buffering_method == "continuous_time_buffer" %}
// get continuous-time history entries in relevant range (t1, t2] from post-synaptic neuron
std::deque< continuous_variable_histentry_{{ paired_neuron_name }} >::iterator continuous_history_start;
std::deque< continuous_variable_histentry_{{ paired_neuron_name }} >::iterator continuous_history_finish;

Expand All @@ -775,6 +766,7 @@ void get_entry_from_continuous_variable_history(double t,
&continuous_history_finish );
{%- endif %}

// get spike history entries in relevant range (t1, t2] from post-synaptic neuron
__target->get_history__( t_lastspike_ - __dendritic_delay,
__t_spike - __dendritic_delay,
&start,
Expand Down Expand Up @@ -802,7 +794,6 @@ void get_entry_from_continuous_variable_history(double t,
{%- endfor %}
{%- endif %}


{#- continuous time based: grab the entry from the postsynaptic continuous time history buffer #}
{%- if continuous_state_buffering_method == "continuous_time_buffer" %}
#ifdef DEBUG
Expand Down Expand Up @@ -907,13 +898,13 @@ void get_entry_from_continuous_variable_history(double t,
{{ printer._expression_printer._simple_expression_printer._variable_printer.set_getter_string("((post_neuron_t*)(__target))->get_%s(_tr_t)") }}
{%- for pre_port in pre_ports %}

/**
* NESTML generated onReceive code block for presynaptic port "{{pre_port}}" begins here!
**/
{%- if synapse.get_on_receive_block(pre_port) %}
/**
* NESTML generated onReceive code block for presynaptic port "{{ pre_port }}" begins here!
**/
{% if synapse.get_on_receive_block(pre_port) %}
{%- set dynamics = synapse.get_on_receive_block(pre_port) %}
{%- with ast = dynamics.get_block() %}
{%- filter indent(8, True) %}
{%- filter indent(6, True) %}
{%- include "directives_cpp/Block.jinja2" %}
{%- endfilter %}
{%- endwith %}
Expand All @@ -926,7 +917,7 @@ void get_entry_from_continuous_variable_history(double t,
* update all convolutions with pre spikes
**/

{%- for spike_updates_for_port in spike_updates.values() %}
{% for spike_updates_for_port in spike_updates.values() %}
{%- for spike_update in spike_updates_for_port %}
{{ printer.print(spike_update.get_variable()) }} += 1.; // XXX: TODO: increment with initial value instead of 1
{%- endfor %}
Expand All @@ -939,9 +930,9 @@ void get_entry_from_continuous_variable_history(double t,

if (pre_before_post_flag)
{
auto get_t = [__t_spike](){ return __t_spike; }; // do not remove, this is in case the predefined time variable ``t`` is used in the NESTML model
auto get_t = [__t_spike](){ return __t_spike; }; // do not remove, this is in case the predefined time variable ``t`` is used in the NESTML model

{%- if paired_neuron_name is not none and paired_neuron_name|length > 0 and paired_neuron.state_vars_that_need_continuous_buffering | length > 0 %}
{% if paired_neuron_name is not none and paired_neuron_name|length > 0 and paired_neuron.state_vars_that_need_continuous_buffering | length > 0 %}

/**
* grab state variables from the postsynaptic neuron (at the "current" simulation time, which corresponds to t_pre)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
#}
{%- if tracing %}/* generated by {{self._TemplateReference__context.name}} */ {% endif %}

/**
* generated code for emit_spike() function
**/

{% if ast.get_args() | length == 0 %}
// begin generated code for emit_spike() function
{% if ast.get_args() | length == 0 %}
{#- no parameters -- emit_spike() called from within neuron #}
#ifdef DEBUG
std::cout << "Emitting a spike at t = " << nest::Time(nest::Time::step(origin.get_steps() + lag + 1)).get_ms() << "\n";
Expand All @@ -28,3 +25,4 @@ e.set_delay_steps( get_delay_steps() );
e.set_rport( get_rport() );
e();
{%- endif %}
// end generated code for emit_spike() function

0 comments on commit 22ba93a

Please sign in to comment.