@@ -113,15 +113,15 @@ def _connect(self, rule_params, syn_params):
113113 else :
114114 raise NotImplementedError ()
115115 syn_params .update ({'tau_psc' : nest .GetStatus ([self .nest_connections [0 ,1 ]], param_name )})
116-
117-
116+
117+
118118 syn_params .update ({'synapse_label' : self .nest_synapse_label })
119119 nest .Connect (self .pre .all_cells .astype (int ).tolist (),
120120 self .post .all_cells .astype (int ).tolist (),
121121 rule_params , syn_params )
122122 self ._sources = [cid [0 ] for cid in nest .GetConnections (synapse_model = self .nest_synapse_model ,
123123 synapse_label = self .nest_synapse_label )]
124-
124+
125125 def _convergent_connect (self , presynaptic_indices , postsynaptic_index ,
126126 ** connection_parameters ):
127127 """
@@ -137,10 +137,20 @@ def _convergent_connect(self, presynaptic_indices, postsynaptic_index,
137137 postsynaptic_cell = self .post [postsynaptic_index ]
138138 assert presynaptic_cells .size == presynaptic_indices .size
139139 assert len (presynaptic_cells ) > 0 , presynaptic_cells
140+ syn_dict = {
141+ 'model' : self .nest_synapse_model ,
142+ 'synapse_label' : self .nest_synapse_label ,
143+ }
140144
141145 weights = connection_parameters .pop ('weight' )
142146 if self .receptor_type == 'inhibitory' and self .post .conductance_based :
143147 weights *= - 1 # NEST wants negative values for inhibitory weights, even if these are conductances
148+ if "stdp" in self .nest_synapse_model :
149+ syn_dict ["Wmax" ] = - 1.2345e6 # just some very large negative value to avoid
150+ # NEST complaining about weight and Wmax having different signs
151+ # (see https://github.com/NeuralEnsemble/PyNN/issues/636)
152+ # Will be overwritten below.
153+ connection_parameters ["Wmax" ] *= - 1
144154 if hasattr (self .post , "celltype" ) and hasattr (self .post .celltype , "receptor_scale" ): # this is a bit of a hack
145155 weights *= self .post .celltype .receptor_scale # needed for the Izhikevich model
146156 delays = connection_parameters .pop ('delay' )
@@ -153,10 +163,7 @@ def _convergent_connect(self, presynaptic_indices, postsynaptic_index,
153163 weights = numpy .array ([weights ])
154164 if not numpy .isscalar (delays ):
155165 delays = numpy .array ([delays ])
156- syn_dict = {'model' : self .nest_synapse_model ,
157- 'weight' : weights , 'delay' : delays ,
158- 'synapse_label' : self .nest_synapse_label ,
159- }
166+ syn_dict .update ({'weight' : weights , 'delay' : delays })
160167
161168 if 'tsodyks' in self .nest_synapse_model :
162169 if self .receptor_type == 'inhibitory' :
@@ -165,7 +172,7 @@ def _convergent_connect(self, presynaptic_indices, postsynaptic_index,
165172 param_name = self .post .local_cells [0 ].celltype .translations ['tau_syn_E' ]['translated_name' ]
166173 else :
167174 raise NotImplementedError ()
168- syn_dict .update ({'tau_psc' : numpy .array ([[nest .GetStatus ([postsynaptic_cell ], param_name )[0 ]] * len (presynaptic_cells .astype (int ).tolist ())])})
175+ syn_dict .update ({'tau_psc' : numpy .array ([[nest .GetStatus ([postsynaptic_cell ], param_name )[0 ]] * len (presynaptic_cells .astype (int ).tolist ())])})
169176
170177 nest .Connect (presynaptic_cells .astype (int ).tolist (),
171178 [int (postsynaptic_cell )],
@@ -183,13 +190,9 @@ def _convergent_connect(self, presynaptic_indices, postsynaptic_index,
183190 if numpy .isscalar (delays ):
184191 delays = repeat (delays )
185192 for pre , w , d in zip (presynaptic_cells , weights , delays ):
186-
187- syn_dict = {'weight' : w , 'delay' : d , 'receptor_type' : receptor_type ,
188- 'model' : self .nest_synapse_model ,
189- 'synapse_label' : self .nest_synapse_label }
190-
191- if 'tsodyks' in self .nest_synapse_model :
192- syn_dict .update ({'tau_psc' : numpy .array ([[nest .GetStatus ([postsynaptic_cell ], param_name )[0 ]] * len (presynaptic_cells .astype (int ).tolist ())])})
193+ syn_dict .update ({'weight' : w , 'delay' : d , 'receptor_type' : receptor_type })
194+ if 'tsodyks' in self .nest_synapse_model :
195+ syn_dict .update ({'tau_psc' : numpy .array ([[nest .GetStatus ([postsynaptic_cell ], param_name )[0 ]] * len (presynaptic_cells .astype (int ).tolist ())])})
193196
194197 nest .Connect ([pre ], [postsynaptic_cell ], 'one_to_one' , syn_dict )
195198
0 commit comments