Changeset 405
- Timestamp:
- 06/28/08 09:39:13 (5 months ago)
- Files:
-
- trunk/src/common.py (modified) (2 diffs)
- trunk/src/nest1/connectors.py (modified) (1 diff)
- trunk/src/nest2/__init__.py (modified) (3 diffs)
- trunk/src/nest2/connectors.py (modified) (4 diffs)
- trunk/src/recording.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/common.py
r399 r405 215 215 if not periodic_boundaries == None: 216 216 d = numpy.minimum(abs(d),periodic_boundaries-abs(d)) 217 #d = numpy.array(map(min, ((x_i, y_i) for (x_i, y_i) in zip(abs(d), periodic_boundaries-abs(d)))))218 217 if mask is not None: 219 218 d = d[mask] … … 246 245 diff2 = diff2.flatten() 247 246 diff2 = numpy.minimum(diff2, periodic_boundaries[i]-diff2) 248 #diff2 = numpy.array(map(min, ((x_i, y_i) for (x_i, y_i) in zip(diff2, periodic_boundaries[i]-diff2))))249 247 diff2 = diff2.reshape(dims) 250 248 diff2 **= 2 trunk/src/nest1/connectors.py
r404 r405 113 113 for post in postsynaptic_neurons: 114 114 distances = common.distances(projection.pre, post, self.mask, self.scale_factor, self.offset, periodic_boundaries) 115 # We evaluate the probabilities of connections for those distances 115 116 func = eval("lambda d: %s" %self.d_expression) 116 117 distances[:,0] = func(distances[:,0]) 117 118 rarr = rng.uniform(0, 1, len(distances[:,0]),) 119 # We get the list of cells that will established a connection 118 120 idx = numpy.where((distances[:,0] >= 1) | ((0 < distances[:,0]) & (distances[:,0] < 1) & (rarr < distances[:,0])))[0] 119 121 source_list = presynaptic_neurons[idx].tolist() 120 if self.allow_self_connections: 122 # We remove the post cell if we don't allow self connections 123 if not self.allow_self_connections: 121 124 try: 122 125 source_list.remove(post) 123 126 except Exception: 124 127 pass 125 #for pre in presynaptic_neurons:126 #if self.allow_self_connections or pre != post:127 ## calculate the distance between the two cells :128 #p = distances[idx_pre,0]129 #if p >= 1 or (0 < p < 1 and rarr[j] < p):130 #source_list.append(pre)131 #j += 1132 #idx_pre += 1133 128 N = len(source_list) 134 129 weights = self.getWeights(N) trunk/src/nest2/__init__.py
r403 r405 144 144 nest_filename = _merge_files(self._device, gather) 145 145 data = recording.readArray(nest_filename, sepchar=None) 146 os.remove(nest_filename)146 #os.remove(nest_filename) 147 147 if data.size > 0: 148 148 # the following returns indices, not IDs. I'm not sure this is what we want. … … 164 164 user_filename += '.%d' % rank() 165 165 if gather == False or rank() == 0: # if we gather, only do this on the master node 166 recording.write_compatible_output(nest_filename, user_filename, Recorder.formats[self.variable], 167 self.population, get_time_step()) 166 recording.write_compatible_output(nest_filename, user_filename, Recorder.formats[self.variable],self.population, get_time_step()) 168 167 else: 169 168 system_line = 'cat %s >> %s' % (nest_filename, user_filename) … … 767 766 else: 768 767 rng = rng or numpy.random 769 for neuron in rng.permutation(numpy.reshape(self.cell, (self.cell.size,)))[0:n_rec]: 770 tmp_list.append(neuron) 768 tmp_list = rng.permutation(numpy.reshape(self.cell, (self.cell.size,)))[0:n_rec] 771 769 772 770 self.recorders[variable].record(tmp_list) trunk/src/nest2/connectors.py
r404 r405 131 131 rng = numpy.random 132 132 for pre in presynaptic_neurons: 133 # We compute the distances from the post cell to all the others 133 134 distances = common.distances(pre, projection.post, self.mask, 134 135 self.scale_factor, self.offset, 135 136 periodic_boundaries) 137 # We evaluate the probabilities of connections for those distances 136 138 func = eval("lambda d: %s" %self.d_expression) 137 139 distances[0] = func(distances[0]) 140 # We get the list of cells that will established a connection 138 141 rarr = rng.uniform(0, 1, len(distances[0,:]),) 139 142 idx = numpy.where((distances[0,:] >= 1) | ((0 < distances[0,:]) & (distances[0,:] < 1) & (rarr < distances[0,:])))[0] 140 143 target_list = postsynaptic_neurons[idx].tolist() 141 if self.allow_self_connections: 144 # We remove the pre cell if we don't allow self connections 145 if not self.allow_self_connections: 142 146 try: 143 147 target_list.remove(pre) 144 148 except Exception: 145 149 pass 146 #for post in postsynaptic_neurons:147 # if self.allow_self_connections or pre != post:148 # calculate the distance between the two cells :149 # p = distances[0,idx_post]150 # if p >= 1 or (0 < p < 1 and rarr[j] < p):151 # target_list.append(post)152 # j += 1153 # idx_post += 1154 150 N = len(target_list) 155 151 weights = self.getWeights(N) … … 163 159 164 160 165 class FixedNumberP reConnector(common.FixedNumberPreConnector):161 class FixedNumberPostConnector(common.FixedNumberPostConnector): 166 162 167 163 def connect(self, projection): … … 185 181 weights = _convertWeight(weights, projection.synapse_type).tolist() 186 182 delays = self.getDelays(N).tolist() 187 183 print target_list,[pre] 188 184 nest.DivergentConnectWD([pre], target_list.tolist(), weights, delays) 189 190 185 projection._sources += [pre]*N 191 186 conn_dict = nest.GetConnections([pre], projection._plasticity_model)[0] … … 209 204 return n 210 205 211 class FixedNumberP ostConnector(common.FixedNumberPostConnector):206 class FixedNumberPreConnector(common.FixedNumberPreConnector): 212 207 213 208 def connect(self, projection): trunk/src/recording.py
r400 r405 68 68 # Writing spiketimes, cell_id-min(cell_id) 69 69 # open file 70 if os.path.getsize(sim_filename) > 0: 70 71 try: 72 N = os.path.getsize(sim_filename) 73 except Exception: 74 N = 0 75 76 if N > 0: 71 77 data = readArray(sim_filename, sepchar=None) 72 78

