Skip to content

Commit

Permalink
Merge pull request #637 from apdavison/issue636
Browse files Browse the repository at this point in the history
Fix problem with setting STDP parameters for inhibitory synapses with pyNN.nest
  • Loading branch information
apdavison authored Dec 3, 2019
2 parents 3ad05f3 + 2cdb65f commit ed1cddd
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions pyNN/nest/projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ def _connect(self, rule_params, syn_params):
else:
raise NotImplementedError()
syn_params.update({'tau_psc': nest.GetStatus([self.nest_connections[0,1]], param_name)})


syn_params.update({'synapse_label': self.nest_synapse_label})
nest.Connect(self.pre.all_cells.astype(int).tolist(),
self.post.all_cells.astype(int).tolist(),
rule_params, syn_params)
self._sources = [cid[0] for cid in nest.GetConnections(synapse_model=self.nest_synapse_model,
synapse_label=self.nest_synapse_label)]

def _convergent_connect(self, presynaptic_indices, postsynaptic_index,
**connection_parameters):
"""
Expand All @@ -137,10 +137,20 @@ def _convergent_connect(self, presynaptic_indices, postsynaptic_index,
postsynaptic_cell = self.post[postsynaptic_index]
assert presynaptic_cells.size == presynaptic_indices.size
assert len(presynaptic_cells) > 0, presynaptic_cells
syn_dict = {
'model': self.nest_synapse_model,
'synapse_label': self.nest_synapse_label,
}

weights = connection_parameters.pop('weight')
if self.receptor_type == 'inhibitory' and self.post.conductance_based:
weights *= -1 # NEST wants negative values for inhibitory weights, even if these are conductances
if "stdp" in self.nest_synapse_model:
syn_dict["Wmax"] = -1.2345e6 # just some very large negative value to avoid
# NEST complaining about weight and Wmax having different signs
# (see https://github.com/NeuralEnsemble/PyNN/issues/636)
# Will be overwritten below.
connection_parameters["Wmax"] *= -1
if hasattr(self.post, "celltype") and hasattr(self.post.celltype, "receptor_scale"): # this is a bit of a hack
weights *= self.post.celltype.receptor_scale # needed for the Izhikevich model
delays = connection_parameters.pop('delay')
Expand All @@ -153,10 +163,7 @@ def _convergent_connect(self, presynaptic_indices, postsynaptic_index,
weights = numpy.array([weights])
if not numpy.isscalar(delays):
delays = numpy.array([delays])
syn_dict = {'model': self.nest_synapse_model,
'weight': weights, 'delay': delays,
'synapse_label': self.nest_synapse_label,
}
syn_dict.update({'weight': weights, 'delay': delays})

if 'tsodyks' in self.nest_synapse_model:
if self.receptor_type == 'inhibitory':
Expand All @@ -165,7 +172,7 @@ def _convergent_connect(self, presynaptic_indices, postsynaptic_index,
param_name = self.post.local_cells[0].celltype.translations['tau_syn_E']['translated_name']
else:
raise NotImplementedError()
syn_dict.update({'tau_psc': numpy.array([[nest.GetStatus([postsynaptic_cell], param_name)[0]] * len(presynaptic_cells.astype(int).tolist())])})
syn_dict.update({'tau_psc': numpy.array([[nest.GetStatus([postsynaptic_cell], param_name)[0]] * len(presynaptic_cells.astype(int).tolist())])})

nest.Connect(presynaptic_cells.astype(int).tolist(),
[int(postsynaptic_cell)],
Expand All @@ -183,13 +190,9 @@ def _convergent_connect(self, presynaptic_indices, postsynaptic_index,
if numpy.isscalar(delays):
delays = repeat(delays)
for pre, w, d in zip(presynaptic_cells, weights, delays):

syn_dict = {'weight': w, 'delay': d, 'receptor_type': receptor_type,
'model': self.nest_synapse_model,
'synapse_label': self.nest_synapse_label}

if 'tsodyks' in self.nest_synapse_model:
syn_dict.update({'tau_psc': numpy.array([[nest.GetStatus([postsynaptic_cell], param_name)[0]] * len(presynaptic_cells.astype(int).tolist())])})
syn_dict.update({'weight': w, 'delay': d, 'receptor_type': receptor_type})
if 'tsodyks' in self.nest_synapse_model:
syn_dict.update({'tau_psc': numpy.array([[nest.GetStatus([postsynaptic_cell], param_name)[0]] * len(presynaptic_cells.astype(int).tolist())])})

nest.Connect([pre], [postsynaptic_cell], 'one_to_one', syn_dict)

Expand Down

0 comments on commit ed1cddd

Please sign in to comment.