Changeset 415
- Timestamp:
- 07/16/08 10:35:16 (1 month ago)
- Files:
-
- trunk/src/common.py (modified) (2 diffs)
- trunk/src/nest1/connectors.py (modified) (1 diff)
- trunk/src/nest2/connectors.py (modified) (2 diffs)
- trunk/src/nest2/synapses.py (modified) (6 diffs)
- trunk/src/neuron2/connectors.py (modified) (1 diff)
- trunk/test/brunel.py (modified) (10 diffs)
- trunk/test/simple_STDP.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/common.py
r414 r415 1066 1066 raise Exception("No available plasticity models") 1067 1067 elif len(possible_models) > 1 : 1068 raise Exception("Multiple plasticity models available") 1068 if self.synapse_dynamics.slow.model: 1069 if self.synapse_dynamics.slow.model in list(possible_models): 1070 self.long_term_plasticity_mechanism = self.synapse_dynamics.slow.model 1071 else: 1072 print "The particular model %s does not exists !" %self.synapse_dynamics.slow.model 1073 else: 1074 print "Several stdp models are available for those plastics connections" 1075 for model in possible_models: 1076 print "--> %s" %model 1077 self.long_term_plasticity_mechanism = list(possible_models)[0] 1078 print "By default, %s is used" %self.long_term_plasticity_mechanism 1079 #raise Exception("Multiple plasticity models available") 1069 1080 1070 1081 #print "Using %s" % self._plasticity_model … … 1542 1553 1543 1554 def __init__(self, timing_dependence=None, weight_dependence=None, 1544 voltage_dependence=None, dendritic_delay_fraction=1.0 ):1555 voltage_dependence=None, dendritic_delay_fraction=1.0, model=None): 1545 1556 self.timing_dependence = timing_dependence 1546 1557 self.weight_dependence = weight_dependence 1547 1558 self.voltage_dependence = voltage_dependence 1548 1559 self.dendritic_delay_fraction = dendritic_delay_fraction 1560 self.model = model 1549 1561 1550 1562 trunk/src/nest1/connectors.py
r411 r415 116 116 # We evaluate the probabilities of connections for those distances 117 117 func = eval("lambda d: %s" %self.d_expression) 118 distances = func(distances[:,0])118 probabilities = func(distances[:,0]) 119 119 rarr = rng.uniform(0, 1, (npre,)) 120 # We get the list of cells that will established a connection 121 source_list = numpy.compress((distances >= 1) | ((0 < distances) & (distances < 1) & (rarr <= distances)), presynaptic_neurons).tolist() 120 # We get the list of cells that will established a connecti 121 idx = numpy.where((probabilities >= 1) | ((0 < probabilities) & (probabilities < 1) & (rarr <= probabilities)))[0] 122 source_list = presynaptic_neurons[idx].tolist() 122 123 # We remove the post cell if we don't allow self connections 123 124 if not self.allow_self_connections and post in source_list: 125 idx.remove(source_list.index(post)) 124 126 source_list.remove(post) 125 127 N = len(source_list) 126 weights = self.getWeights(N) 128 if isinstance(self.weights,str): 129 func = eval("lambda d: %s" %self.weights) 130 weights = func(distances[:,0])[idx] 131 else: 132 weights = self.getWeights(N) 127 133 weights = _convertWeight(weights, projection.synapse_type).tolist() 128 delays = self.getDelays(N).tolist() 134 # We deal with the fact that the user could have given a delays distance dependent 135 if isinstance(self.delays,str): 136 func = eval("lambda d: %s" %self.delays) 137 delays = func(distances[:,0])[idx].tolist() 138 else: 139 delays = self.getDelays(N).tolist() 129 140 projection._targets += [post]*N 130 141 projection._sources += source_list trunk/src/nest2/connectors.py
r411 r415 114 114 print "Periodic boundaries activated and set to size ", periodic_boundaries 115 115 postsynaptic_neurons = projection.post.cell.flatten() # array 116 npost = len(postsynaptic_neurons)117 #postsynaptic_neurons = projection.post.cell_local116 npost = len(postsynaptic_neurons) 117 #postsynaptic_neurons = projection.post.cell_local 118 118 # what about NativeRNG? 119 119 if projection.rng: … … 132 132 # We evaluate the probabilities of connections for those distances 133 133 func = eval("lambda d: %s" %self.d_expression) 134 distances = func(distances[0])134 probabilities = func(distances[0]) 135 135 # We get the list of cells that will established a connection 136 136 rarr = rng.uniform(0, 1, (npost,)) 137 target_list = numpy.compress((distances >= 1) | ((0 < distances) & (distances < 1) & (rarr <= distances)), postsynaptic_neurons).tolist() 138 #target_list = postsynaptic_neurons[idx].tolist()137 idx = numpy.where((probabilities >= 1) | ((0 < probabilities) & (probabilities < 1) & (rarr <= probabilities)))[0] 138 target_list = postsynaptic_neurons[idx].tolist() 139 139 # We remove the pre cell if we don't allow self connections 140 140 if not self.allow_self_connections and pre in target_list: 141 idx.remove(target_list.index(pre)) 141 142 target_list.remove(pre) 142 143 N = len(target_list) 143 weights = self.getWeights(N) 144 weights = _convertWeight(weights, projection.synapse_type).tolist() 145 delays = self.getDelays(N).tolist() 144 # We deal with the fact that the user could have given a weights distance dependent 145 if isinstance(self.weights,str): 146 func = eval("lambda d: %s" %self.weights) 147 weights = func(distances[0])[idx] 148 else: 149 weights = self.getWeights(N) 150 weights = _convertWeight(weights, projection.synapse_type).tolist() 151 # We deal with the fact that the user could have given a delays distance dependent 152 if isinstance(self.delays,str): 153 func = eval("lambda d: %s" %self.delays) 154 delays = func(distances[0])[idx].tolist() 155 else: 156 delays = self.getDelays(N).tolist() 146 157 projection._targets += target_list 147 158 projection._sources += [pre]*N trunk/src/nest2/synapses.py
r407 r415 22 22 23 23 def __init__(self, timing_dependence=None, weight_dependence=None, 24 voltage_dependence=None, dendritic_delay_fraction=1.0 ):24 voltage_dependence=None, dendritic_delay_fraction=1.0, model=None): 25 25 assert dendritic_delay_fraction == 1, """NEST does not currently support axonal delays: 26 26 for the purpose of STDP calculations all delays 27 27 are assumed to be dendritic.""" 28 28 common.STDPMechanism.__init__(self, timing_dependence, weight_dependence, 29 voltage_dependence, dendritic_delay_fraction )29 voltage_dependence, dendritic_delay_fraction,model) 30 30 31 31 … … 62 62 ('A_minus', 'alpha', 'A_minus/A_plus', 'alpha*lambda'), 63 63 ) 64 possible_models = set(['stdp_synapse ',]) #'stdp_synapse_hom'64 possible_models = set(['stdp_synapse_hom','stdp_synapse']) #'stdp_synapse_hom' 65 65 66 66 def __init__(self, w_min=0.0, w_max=1.0, A_plus=0.01, A_minus=0.01): # units? … … 87 87 ('A_minus', 'alpha', 'A_minus/A_plus', 'alpha*lambda'), 88 88 ) 89 possible_models = set(['stdp_synapse ',]) #'stdp_synapse_hom'89 possible_models = set(['stdp_synapse_hom','stdp_synapse']) #'stdp_synapse_hom' 90 90 91 91 def __init__(self, w_min=0.0, w_max=1.0, A_plus=0.01, A_minus=0.01): … … 111 111 ('A_minus', 'alpha', 'A_minus/A_plus', 'alpha*lambda'), 112 112 ) 113 possible_models = set(['stdp_synapse ',]) #'stdp_synapse_hom'113 possible_models = set(['stdp_synapse_hom','stdp_synapse']) #'stdp_synapse_hom' 114 114 115 115 def __init__(self, w_min=0.0, w_max=1.0, A_plus=0.01, A_minus=0.01): … … 138 138 ('mu_minus', 'mu_minus'), 139 139 ) 140 possible_models = set(['stdp_synapse ',]) #'stdp_synapse_hom'140 possible_models = set(['stdp_synapse_hom','stdp_synapse']) #'stdp_synapse_hom' 141 141 142 142 def __init__(self, w_min=0.0, w_max=1.0, A_plus=0.01, A_minus=0.01,mu_plus=0.5,mu_minus=0.5): … … 155 155 ('tau_minus', 'tau_minus'), # defined in post-synaptic neuron 156 156 ) 157 possible_models = set(['stdp_synapse ',]) #'stdp_synapse_hom'157 possible_models = set(['stdp_synapse_hom','stdp_synapse']) #'stdp_synapse_hom' 158 158 159 159 def __init__(self, tau_plus=20.0, tau_minus=20.0): trunk/src/neuron2/connectors.py
r399 r415 134 134 periodic_boundaries) 135 135 p_array = eval(self.d_expression) 136 if isinstance(self.weights,str): 137 raise Exception("The weights distance dependent are not implemented yet") 138 if isinstance(self.delays,str): 139 raise Exception("The delays distance dependent are not implemented yet") 136 140 probabilistic_connect(self, projection, p_array.flatten()) 137 141 trunk/test/brunel.py
r341 r415 27 27 # scale synaptic weights up by this factor to 28 28 # obtain similar dynamics independent of size 29 order = 50000 # determines size of network:29 order = 50000 # determines size of network: 30 30 # 4*order excitatory neurons 31 31 # 1*order inhibitory neurons … … 48 48 49 49 # simulation-related parameters 50 simtime = 100.0 # simulation time [ms]50 simtime = 100.0 # simulation time [ms] 51 51 dt = 0.1 # simulation step length [ms] 52 52 … … 57 57 # seed for random generator(s) used during simulation 58 58 kernelseed = 43210987 59 60 exfilename = "brunel_ex_%s.ras" % simulator # output file for excit. population61 infilename = "brunel_in_%s.ras" % simulator # output file for inhib. population62 vexfilename = "brunel_ex_%s.v" % simulator # output file for membrane potential traces63 vinfilename = "brunel_in_%s.v" % simulator # output file for membrane potential traces64 59 65 60 # === Calculate derived parameters ============================================= … … 113 108 # For NEST, limits must be set BEFORE connecting any elements 114 109 115 extra = {'threads' : 2} 110 #extra = {'threads' : 2} 111 extra = {} 116 112 117 113 myid = setup(timestep=dt, max_delay=delay, **extra) 114 np = num_processes() 115 import socket 116 host_name = socket.gethostname() 117 print "Host #%d is on %s" % (myid+1, host_name) 118 118 119 119 if extra.has_key('threads'): 120 120 print "%d Initialising the simulator with %d threads..." %(myid, extra['threads']) 121 121 else: 122 print "%d Initialising the simulator with single thread..." %( node_id)122 print "%d Initialising the simulator with single thread..." %(myid) 123 123 124 124 # Small function to display information only on node 1 … … 130 130 131 131 print "%d Setting up random number generator" %myid 132 rng = NumpyRNG(kernelseed +myid)132 rng = NumpyRNG(kernelseed, parallel_safe=True, rank=myid, num_processes=np) 133 133 134 134 print "%d Creating excitatory population." %myid … … 139 139 140 140 print "%d Initialising membrane potential to random values." %myid 141 rng2 = NumpyRNG(kernelseed+myid) 142 uniformDistr = RandomDistribution('uniform',[U0,theta],rng2) 141 uniformDistr = RandomDistribution('uniform',[U0,theta],rng) 143 142 E_net.randomInit(uniformDistr) 144 143 I_net.randomInit(uniformDistr) … … 171 170 print "input --> E\t", len(input_to_E), "connections" 172 171 172 print E_to_E.describe() 173 173 174 print "%d Connecting inhibitory population." %myid 174 175 E_to_I = Projection(E_net, I_net, E_Connector, rng=rng, target="excitatory") … … 189 190 simCPUTime = Timer.elapsedTime() 190 191 192 exfilename = "Results/Brunel_exc_%s_np%d.ras" % (simulator,np) # output file for excit. population 193 infilename = "Results/Brunel_inh_%s_np%d.ras" % (simulator,np) # output file for inhib. population 194 vexfilename = "Results/Brunel_exc_%s_np%d.v" % (simulator,np) # output file for membrane potential traces 195 vinfilename = "Results/Brunel_inh_%s_np%d.v" % (simulator,np) # output file for membrane potential traces 196 191 197 # write data to file 192 198 E_net.printSpikes(exfilename) … … 200 206 # write a short report 201 207 nprint("\n--- Brunel Network Simulation ---") 208 nprint("Nodes : %d" % np) 202 209 nprint("Number of Neurons : %d" %N) 203 210 nprint("Number of Synapses : %d" %Nsyn) … … 209 216 nprint("Build time : %g s" %buildCPUTime) 210 217 nprint("Simulation time : %g s" %simCPUTime) 211 212 218 213 219 # === Clean up and quit ======================================================== 214 220 215 221 end() 216 trunk/test/simple_STDP.py
r384 r415 36 36 37 37 if simulator == "nest2": 38 print nest.GetConnection([p1[0]], 'stdp_synapse ', 0)38 print nest.GetConnection([p1[0]], 'stdp_synapse_hom', 0) 39 39 print nest.GetStatus([p2[0]]) 40 40 … … 47 47 while t < 50: 48 48 t = run(1.0) 49 syn_dict = nest.GetConnection([p1[0]], 'stdp_synapse ', 0)49 syn_dict = nest.GetConnection([p1[0]], 'stdp_synapse_hom', 0) 50 50 print "%4.1f %6.4f %7.3f %6.4f" % (t, prj.getWeights()[0], syn_dict['Kplus'], syn_dict['weight']) 51 51 #run(1000.0)
