def testFixedProbability(self): """For all connections created with "fixedProbability"...""" for srcP in [self.source5, self.source22]: for tgtP in [self.target1, self.target6, self.target33]: prj1 = sim.Projection(srcP, tgtP, sim.FixedProbabilityConnector(0.5), rng=random.NumpyRNG(12345)) prj2 = sim.Projection(srcP, tgtP, sim.FixedProbabilityConnector(0.5), rng=random.NativeRNG(12345)) for prj in prj1, prj2: assert (0 < len(prj) < len(srcP) * len(tgtP) ), 'len(prj) = %d, len(srcP)*len(tgtP) = %d' % ( len(prj), len(srcP) * len(tgtP))
facilitating_synapse_ee = sim.TsodyksMarkramSynapse(weight=0.05, delay=0.5, U=0.04, tau_rec=100.0, tau_facil=1000) static_synapse = sim.StaticSynapse(weight=0.05, delay=0.5) Input_E_connection = sim.Projection(Excinp, Pexc, sim.AllToAllConnector(), static_synapse, receptor_type='excitatory') E_E_connection = sim.Projection(Pexc, Pexc, sim.FixedProbabilityConnector(p_connect=0.5), depressing_synapse_ee, receptor_type='excitatory') Excinp.record('spikes') # Excinp[1].record('v') Pexc.record('spikes') Pexc[5:6].record('v') for i in range(no_run): sim.run(run_time) spikes = Excinp.get_data() spike = Pexc.get_data() # print connection.get('weight',format = 'array') # print E_E_connection.get('weight', format = 'array') # print connection.get('tau_facil', format = 'array')
# todo: the Population structure # ==========create neuron connection====================== # the network topology is based on 'compensating inhomogeneities of neuromorphic VLSI devices via short-term synaptic plasticity' # todo: generate a concrete connection probability and weight (not chaged for each run) # connection probability # todo: connection probability based on position P_c = 0.1 # scaling factor of connection probability; make sure the largest p (i.e. p_ii if (N_e > N_i)) is smaller than 1 p_ee = P_c p_ie = 2 * P_c p_ei = N_e / N_i * P_c p_ii = 2 * N_e / N_i * P_c connector_ee = sim.FixedProbabilityConnector( p_connect=p_ee) # connector algorithm connector_ie = sim.FixedProbabilityConnector(p_connect=p_ie) connector_ei = sim.FixedProbabilityConnector(p_connect=p_ei) connector_ii = sim.FixedProbabilityConnector(p_connect=p_ii) # connection weight # todo: weight distribution according to position W_c = 0.5 # scaling factor of weight w_ee = W_c * 1 w_ie = 0.5 * W_c * 0.1 w_ei = W_c * 3 w_ii = 0.5 * W_c * 0.5 # type of synaptic connection depressing_synapse_ee = sim.TsodyksMarkramSynapse(weight=w_ee, delay=0.2,
weight_dependence=sim.AdditiveWeightDependence(w_min=0, w_max=0.04), dendritic_delay_fraction=0) #Error: The pyNN.brian backend does not currently support dendritic delays: # for the purpose of STDP calculations all delays are assumed to be axonal #for brian dendritic_delay_fraction=0 default value 1.0 ''' Connection algorithms ''' connector = sim.AllToAllConnector(allow_self_connections=False) # no autapses #default True connector = sim.OneToOneConnector() #Connecting neurons with a fixed probability connector = sim.FixedProbabilityConnector(p_connect=0.2) #Connecting neurons with a position-dependent probability DDPC = sim.DistanceDependentProbabilityConnector connector = DDPC("exp(-d)") connector = DDPC("d<3") #The constructor requires a string d_expression, which should be a distance expression, # as described above for delays, but returning a probability (a value between 0 and 1) #Divergent/fan-out connections #connects each pre-synaptic neuron to exactly n post-synaptic neurons chosen at random connector = sim.FixedNumberPostConnector(n=30) distr_npost = RandomDistribution(distribution='binomial', n=100, p=0.3) connector = sim.FixedNumberPostConnector(n=distr_npost)
Pexc = sim.Population( N_e, cell_type, label="excitotary neurons") # excitatory neuron population # todo: the Population structure # ==========create neuron connection====================== # the network topology is based on 'compensating inhomogeneities of neuromorphic VLSI devices via short-term synaptic plasticity' # todo: generate a concrete connection probability and weight (not chaged for each run) # connection probability # todo: connection probability based on position P_c = 0.1 # scaling factor of connection probability; make sure the largest p (i.e. p_ii if (N_e > N_i)) is smaller than 1 p_ee = P_c connector_ee = sim.FixedProbabilityConnector( p_connect=p_ee) # connector algorithm # connection weight # todo: weight distribution according to position W_c = 0.5 # scaling factor of weight w_ee = W_c * 1 # type of synaptic connection # syn = sim.StaticSynapse(weight = 0.05, delay = 0.5) depressing_synapse_ee = sim.TsodyksMarkramSynapse(weight=w_ee, delay=0.2, U=0.5, tau_rec=800.0, tau_facil=0.01) # connect the neuronal network
# todo: the initail parameters of neurons might be modified cell_type_parameters = {'tau_refrac': 0.1, 'v_thresh': -50.0, 'tau_m': 20.0, 'tau_syn_E': 0.5, 'v_rest': -65.0,\ 'cm': 1.0, 'v_reset': -65.0, 'tau_syn_I': 0.5, 'i_offset': 0.0} # print(sim.IF_curr_alpha.default_parameters) cell_type = sim.IF_cond_exp(**cell_type_parameters) # neuron type of population Pexc = sim.Population(N_e, cell_type, label = "excitotary neurons") # excitatory neuron population Pinh = sim.Population(N_i, cell_type, label = "inhibitatory neurons") # inhibitoty neuron population all_cells = sim.Assembly(Pexc, Pinh) # assembly for all neuron population for the purpose of data recording # todo: the Population structure # ==========injecting neuron currents OR connect to the input signal======================= syn = sim.StaticSynapse(weight = weight_inp[0], delay = 0.5) Ie_E_connections = sim.Projection(Excinp, Pexc, sim.FixedProbabilityConnector(p_connect = 0.5), syn, receptor_type = 'excitatory', label = "excitatory input to excitatory neurons") Ii_E_connections = sim.Projection(Inhinp, Pexc, sim.FixedProbabilityConnector(p_connect = 0.5), syn, receptor_type = 'inhibitory', label = "inhibitory input to excitatory neurons") Ie_I_connections = sim.Projection(Excinp, Pinh, sim.FixedProbabilityConnector(p_connect = 0.5), syn, receptor_type = 'excitatory', label = "excitatory input to inhibitory neurons") Ii_I_connections = sim.Projection(Inhinp, Pinh, sim.FixedProbabilityConnector(p_connect = 0.5), syn, receptor_type = 'inhibitory', label = "inhibitory input to inhibitory neurons") # ==========define the parameter need to be record================= all_cells.record('spikes') # Excinp.record('spikes') for i, j in enumerate(weight_inp): Ie_E_connections.set(weight = j) Ii_E_connections.set(weight = j) Ie_I_connections.set(weight = j) Ii_E_connections.set(weight = j) sim.run(run_time) # ==========retrieve the data======================
# todo: the initail parameters of neurons might be modified cell_type_parameters = {'tau_refrac': 0.1, 'v_thresh': -50.0, 'tau_m': 20.0, 'tau_syn_E': 0.5, 'v_rest': -65.0,\ 'cm': 1.0, 'v_reset': -65.0, 'tau_syn_I': 0.5, 'i_offset': 0.0} # print(sim.IF_curr_alpha.default_parameters) cell_type = sim.IF_cond_exp(**cell_type_parameters) # neuron type of population Pexc = sim.Population(3, cell_type, label = "excitotary neurons") # excitatory neuron population # ==========generate OR read in the input spikes data===================== noSpikes = 20 # number of spikes per chanel per simulation run stimSpikes = RandomDistribution('uniform', low = 0, high = 500, rng = NumpyRNG(seed = 72386)).next(noSpikes) # generate a time uniform distributed signal with Exc_in + Inh_in chanels and noSpikes for each chanel Excinp = sim.Population(3, sim.SpikeSourceArray(spike_times = stimSpikes)) syn = sim.StaticSynapse(weight = 0.05, delay = 0.5) Ie_A_connections = sim.Projection(Excinp, Pexc, sim.FixedProbabilityConnector(p_connect = 0.5), syn, receptor_type = 'excitatory', label = "excitatory input") for i in range(ite_no): sim.run(100) # ==========write the data====================== sim.reset() Ie_A_connections.set(weight = (i + 2) * 0.05) print Ie_A_connections.get('weight', format = 'list') # Ie_A_connections.set(weight = 0.02) # print Ie_A_connections.get('weight', format = 'list') # sim.run(200) # sim.reset()