diff --git a/pyNN/nest/projections.py b/pyNN/nest/projections.py index 76a1aa96c..db0c6bd78 100644 --- a/pyNN/nest/projections.py +++ b/pyNN/nest/projections.py @@ -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): """ @@ -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') @@ -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': @@ -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)], @@ -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)