def do_run(nNeurons): p.setup(timestep=1.0, min_delay=1.0, max_delay=8.0) cell_params_lif_in = { 'tau_m': 333.33, 'cm': 208.33, 'v_init': 0.0, 'v_rest': 0.1, 'v_reset': 0.0, 'v_thresh': 1.0, 'tau_syn_E': 1, 'tau_syn_I': 2, 'tau_refrac': 2.5, 'i_offset': 3.0 } pop1 = p.Population(nNeurons, p.IF_curr_exp, cell_params_lif_in, label='pop_0') pop1.record_v() pop1.record_gsyn() pop1.record() p.run(3000) v = pop1.get_v(compatible_output=True) gsyn = pop1.get_gsyn(compatible_output=True) spikes = pop1.getSpikes(compatible_output=True) p.end() return (v, gsyn, spikes)
def do_run(): sim.setup(timestep=1.0, min_delay=1.0, max_delay=1.0) simtime = 1000 pg_pop1 = sim.Population(2, sim.SpikeSourcePoisson, { 'rate': 10.0, 'start': 0, 'duration': simtime }, label="pg_pop1") pg_pop2 = sim.Population(2, sim.SpikeSourcePoisson, { 'rate': 10.0, 'start': 0, 'duration': simtime }, label="pg_pop2") pg_pop1.record() pg_pop2.record() sim.run(simtime) spikes1 = pg_pop1.getSpikes(compatible_output=True) spikes2 = pg_pop2.getSpikes(compatible_output=True) sim.end() return (spikes1, spikes2)
def do_run(): p.setup(timestep=1.0, min_delay=1.0, max_delay=1.0) cell_params = {'i_offset': .1, 'tau_refrac': 3.0, 'v_rest': -65.0, 'v_thresh': -51.0, 'tau_syn_E': 2.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'e_rev_E': 0., 'e_rev_I': -80.} # setup test population if_pop = p.Population(1, p.IF_cond_exp, cell_params) # setup spike sources exc_pop = p.Population(1, p.SpikeSourceArray, {'spike_times': [20., 40., 60.]}) inh_pop = p.Population(1, p.SpikeSourceArray, {'spike_times': [120., 140., 160.]}) # setup excitatory and inhibitory connections listcon = p.FromListConnector([(0, 0, 0.01, 1.0)]) p.Projection(exc_pop, if_pop, listcon, target='excitatory') p.Projection(inh_pop, if_pop, listcon, target='inhibitory') # setup recorder if_pop.record_v() p.run(200.) # read out voltage and plot V = if_pop.get_v() p.end() return V
def do_run(nNeurons): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) max_delay = 50 p.set_number_of_neurons_per_core("IF_curr_exp", nNeurons / 2) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() projections = list() weight_to_spike = 2.0 delay = numpy.random.RandomState() delays = list() connections = list() for i in range(0, nNeurons): d_value = int(delay.uniform(low=1, high=max_delay)) delays.append(float(d_value)) singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, d_value) connections.append(singleConnection) injectionConnection = [(0, 0, weight_to_spike, 1)] spikeArray = {'spike_times': [[0]]} populations.append( p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1')) projections.append( p.Projection(populations[0], populations[0], p.FromListConnector(connections))) projections.append( p.Projection(populations[1], populations[0], p.FromListConnector(injectionConnection))) populations[0].record_v() populations[0].record_gsyn() populations[0].record() run_time = (max_delay * nNeurons) print "Running for {} ms".format(run_time) p.run(run_time) v = populations[0].get_v(compatible_output=True) gsyn = populations[0].get_gsyn(compatible_output=True) spikes = populations[0].getSpikes(compatible_output=True) p.end() return (v, gsyn, spikes)
def do_run(nNeurons): p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0) p.set_number_of_neurons_per_core("IF_curr_exp", 250) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 5.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() projections = list() weight_to_spike = 1.5 delay = 1 connections = list() for i in range(0, nNeurons): singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay) connections.append(singleConnection) injectionConnection = [(0, 0, weight_to_spike, delay)] spikeArray = {'spike_times': [[0]]} populations.append( p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1')) projections.append( p.Projection(populations[0], populations[0], p.FromListConnector(connections))) projections.append( p.Projection(populations[1], populations[0], p.FromListConnector(injectionConnection))) populations[0].record_v() populations[0].record_gsyn() populations[0].record() p.run(1000) '''' weights = projections[0].getWeights() delays = projections[0].getDelays() ''' v = populations[0].get_v(compatible_output=True) gsyn = populations[0].get_gsyn(compatible_output=True) spikes = populations[0].getSpikes(compatible_output=True) p.end() return (v, gsyn, spikes)
def test_multi_board_spike_output(self): TestMultiBoardSpikeOutput.counts = dict() p.setup(1.0, n_chips_required=((48 * 2) + 1)) machine = p.get_machine() labels = list() for chip in machine.ethernet_connected_chips: print "Adding population on {}, {}".format(chip.x, chip.y) label = "{}, {}".format(chip.x, chip.y) labels.append(label) pop = p.Population( 10, p.SpikeSourceArray, {"spike_times": [i for i in range(100)]}, label=label) pop.add_placement_constraint(chip.x, chip.y) p.external_devices.activate_live_output_for(pop) TestMultiBoardSpikeOutput.counts[label] = 0 live_output = p.external_devices.SpynnakerLiveSpikesConnection( receive_labels=labels) for label in labels: live_output.add_receive_callback( label, TestMultiBoardSpikeOutput.spike_receiver) p.run(1000) p.end() for label in labels: print "Received {} of 1000 spikes from {}".format( TestMultiBoardSpikeOutput.counts[label], label) self.assertEqual(TestMultiBoardSpikeOutput.counts[label], 1000)
def do_run(): """ test that tests the printing of v from a pre determined recording :return: """ p.setup(timestep=0.04, min_delay=1.0, max_delay=4.0) n_neurons = 128 * 128 # number of neurons in each population p.set_number_of_neurons_per_core("IF_cond_exp", 256) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0, 'e_rev_E': 0., 'e_rev_I': -80. } populations = list() projections = list() weight_to_spike = 0.035 delay = 1.7 current_file_path = os.path.dirname(os.path.abspath(__file__)) spikes_file = os.path.join(current_file_path, 'test.spikes') spikes = read_spikefile(spikes_file, n_neurons) spike_array = {'spike_times': spikes} populations.append( p.Population(n_neurons, p.SpikeSourceArray, spike_array, label='inputSpikes_1')) populations.append( p.Population(n_neurons, p.IF_cond_exp, cell_params_lif, label='pop_1')) projections.append( p.Projection( populations[0], populations[1], p.OneToOneConnector(weights=weight_to_spike, delays=delay))) populations[1].record() p.run(1000) spikes = populations[1].getSpikes(compatible_output=True) p.end() return spikes
def test_recording_numerious_element(self): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) n_neurons = 20 # number of neurons in each population p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() projections = list() boxed_array = numpy.zeros(shape=(0, 2)) spike_array = list() for neuron_id in range(0, n_neurons): spike_array.append(list()) for counter in range(0, 20): random_time = random.randint(0, 5000) boxed_array = numpy.append(boxed_array, [[neuron_id, random_time]], axis=0) spike_array[neuron_id].append(random_time) spike_array_params = {'spike_times': spike_array} populations.append( p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(n_neurons, p.SpikeSourceArray, spike_array_params, label='inputSpikes_1')) projections.append( p.Projection(populations[1], populations[0], p.OneToOneConnector())) populations[1].record() p.run(5000) spike_array_spikes = populations[1].getSpikes() boxed_array = boxed_array[numpy.lexsort( (boxed_array[:, 1], boxed_array[:, 0]))] numpy.testing.assert_array_equal(spike_array_spikes, boxed_array) p.end()
def test_initial_setup(self): self.assertEqual(pynn.setup(timestep=1, min_delay=1, max_delay=15.0), 0) simulator = globals_variables.get_simulator() try: self.assertEqual(simulator._config.getint("Machine", "machineTimeStep"), 1 * 1000) self.assertEqual(pynn.get_min_delay(), 1) self.assertEqual(pynn.get_max_delay(), 15.0) finally: pynn.end()
def test_tun(self): with self.assertRaises(SpinnmanTimeoutException): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) # add to the path the location of the dodgy binary # (if_cur_exp with the c_main bodged to result in it # running for twice as long as expected) ex_finder = AbstractSpiNNakerCommon._EXECUTABLE_FINDER ex_finder.add_path(os.path.dirname(__file__)) nNeurons = 200 # number of neurons in each population cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() projections = list() weight_to_spike = 2.0 delay = 17 loopConnections = list() for i in range(0, nNeurons): singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay) loopConnections.append(singleConnection) injectionConnection = [(0, 0, weight_to_spike, 1)] spikeArray = {'spike_times': [[0]]} populations.append( p.Population(nNeurons, FakeIFCurrExp, cell_params_lif, label='pop_1')) populations.append( p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1')) projections.append( p.Projection(populations[0], populations[0], p.FromListConnector(loopConnections))) projections.append( p.Projection(populations[1], populations[0], p.FromListConnector(injectionConnection))) populations[0].record_v() populations[0].record_gsyn() populations[0].record() p.run(5000) p.end()
def do_run(nNeurons): p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0) p.set_number_of_neurons_per_core(IZK_curr_exp, 100) cell_params_izk = { 'a': 0.02, 'b': 0.2, 'c': -65, 'd': 8, 'v_init': -75, 'u_init': 0, 'tau_syn_E': 2, 'tau_syn_I': 2, 'i_offset': 0 } populations = list() projections = list() weight_to_spike = 40 delay = 1 connections = list() for i in range(0, nNeurons): singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay) connections.append(singleConnection) injectionConnection = [(0, 0, weight_to_spike, delay)] spikeArray = {'spike_times': [[50]]} populations.append(p.Population(nNeurons, IZK_curr_exp, cell_params_izk, label='pop_1')) populations.append(p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1')) projections.append(p.Projection(populations[0], populations[0], p.FromListConnector(connections))) projections.append(p.Projection(populations[1], populations[0], p.FromListConnector(injectionConnection))) populations[0].record_v() populations[0].record_gsyn() populations[0].record() p.run(500) v = populations[0].get_v(compatible_output=True) gsyn = populations[0].get_gsyn(compatible_output=True) spikes = populations[0].getSpikes(compatible_output=True) p.end() return (v, gsyn, spikes)
def do_run(): p.setup(timestep=1.0) input_pop = p.Population(1, p.SpikeSourceArray, cellparams={"spike_times": [0]}, label="input") cell_params_lif = { 'cm': 0.25, # nF 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } pop = p.Population(2, p.IF_curr_exp, cellparams=cell_params_lif, label="pop") connections = list() connections.append( p.Projection(input_pop, pop, p.AllToAllConnector(weights=[0.3, 1.0], delays=[1, 17]))) connections.append( p.Projection(input_pop, pop, p.AllToAllConnector(weights=[1.0, 0.7], delays=[2, 15]))) connections.append( p.Projection(input_pop, pop, p.AllToAllConnector(weights=[0.7, 0.3], delays=[3, 33]))) pre_weights = list() pre_delays = list() for connection in connections: pre_weights.append(connection.getWeights()) pre_delays.append(connection.getDelays()) p.run(100) post_weights = list() post_delays = list() for connection in connections: post_weights.append(connection.getWeights()) post_delays.append(connection.getDelays()) p.end() return (pre_weights, pre_delays, post_weights, post_delays)
def test_run(self): sim.setup() sim.Population(3, sim.SpikeSourcePoisson, {"rate": 100}) p2 = sim.Population(3, sim.SpikeSourceArray, {"spike_times": [[10.0], [20.0], [30.0]]}) p3 = sim.Population(4, sim.IF_cond_exp, {}) sim.Projection(p2, p3, sim.FromListConnector([ (0, 0, 0.1, 1.0), (1, 1, 0.1, 1.0), (2, 2, 0.1, 1.0)])) sim.run(100.0) sim.end()
def do_run(nNeurons): p.setup(timestep=0.1, min_delay=1.0, max_delay=7.5) p.set_number_of_neurons_per_core("IF_curr_exp", 100) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 6, 'tau_syn_I': 6, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -55.4 } populations = list() projections = list() weight_to_spike = 12 injection_delay = 1 delay = 1 spikeArray = {'spike_times': [[0, 10, 20, 30]]} populations.append( p.Population(1, p.SpikeSourceArray, spikeArray, label='pop_0')) populations.append( p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_2')) connector = p.AllToAllConnector(weights=weight_to_spike, delays=injection_delay) projections.append(p.Projection(populations[0], populations[1], connector)) connector = p.OneToOneConnector(weights=weight_to_spike, delays=delay) projections.append(p.Projection(populations[1], populations[2], connector)) populations[1].record_v() populations[1].record() p.run(100) v = populations[1].get_v(compatible_output=True) spikes = populations[1].getSpikes(compatible_output=True) p.end() return (v, spikes)
def do_run(): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) n_neurons = 900 # number of neurons in each population cell_params_lif = { 'cm': 0.25, # nF 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() projections = list() weight_to_spike = 2.0 delay = 1 populations.append( p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_2')) connectors = p.AllToAllConnector(weights=weight_to_spike, delays=delay) projections.append(p.Projection(populations[0], populations[1], connectors)) delays = [] weights = [] # before delays.append(projections[0].getDelays()) weights.append(projections[0].getWeights()) p.run(100) # after delays.append(projections[0].getDelays()) weights.append(projections[0].getWeights()) p.end() return (delays, weights)
def do_run(): p.setup(timestep=1.0, min_delay=1.0, max_delay=10.0, db_name='if_cond.sqlite') cell_params = { 'i_offset': .1, 'tau_refrac': 3.0, 'v_rest': -65.0, 'v_thresh': -51.0, 'tau_syn_E': 2.0, 'tau_syn_I': 5.0, 'v_reset': -70.0 } ifcell = p.Population(1, p.IF_curr_exp, cell_params, label='IF_curr_exp') spike_sourceE = p.Population( 1, p.SpikeSourceArray, {'spike_times': [ [i for i in range(5, 105, 10)], ]}, label='spike_sourceE') p.Projection(spike_sourceE, ifcell, p.OneToOneConnector(weights=1, delays=2), target='excitatory') breakMe = True if breakMe: p.Projection(spike_sourceE, ifcell, p.OneToOneConnector(weights=1, delays=2), target='excitatory') ifcell.record_v() ifcell.record_gsyn() p.run(200.0) recorded_v = ifcell.get_v() recorded_gsyn = ifcell.get_gsyn() p.end() return (recorded_v, recorded_gsyn)
def do_run(split_spike_source_poisson=False, change_spike_rate=True, split_if_curr_exp=False, change_if_curr=True): p.setup(1.0) if split_spike_source_poisson: print "split SpikeSourcePoisson", split_spike_source_poisson p.set_number_of_neurons_per_core(p.SpikeSourcePoisson, 27) if split_if_curr_exp: print "split IF_curr_exp" p.set_number_of_neurons_per_core(p.IF_curr_exp, 22) inp = p.Population(100, p.SpikeSourcePoisson, {"rate": 100}, label="input") pop = p.Population(100, p.IF_curr_exp, {}, label="pop") p.Projection(inp, pop, p.OneToOneConnector(weights=5.0)) pop.record() inp.record() p.run(100) if change_spike_rate: inp.set("rate", 10) if change_if_curr: # pop.set("cm", 0.25) pop.set("tau_syn_E", 1) p.run(100) pop_spikes1 = pop.getSpikes() inp_spikes1 = inp.getSpikes() p.reset() inp.set("rate", 0) pop.set("i_offset", 1.0) pop.initialize("v", p.RandomDistribution("uniform", [-65.0, -55.0])) p.run(100) pop_spikes2 = pop.getSpikes() inp_spikes2 = inp.getSpikes() p.end() return (pop_spikes1, inp_spikes1, pop_spikes2, inp_spikes2)
def do_run(nNeurons): p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0) p.set_number_of_neurons_per_core("IF_curr_exp", 100) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 10.0, 'tau_refrac': 2.0, 'tau_syn_E': 0.5, 'tau_syn_I': 0.5, 'v_reset': -65.0, 'v_rest': -65.0, 'v_thresh': -64.4 } populations = list() projections = list() weight_to_spike = 2 delay = 1 connections = list() for i in range(0, nNeurons): singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay) connections.append(singleConnection) injectionConnection = [(0, 0, weight_to_spike, delay)] spikeArray = {'spike_times': [[0]]} for x in range(6): populations.append( p.Population(nNeurons, p.IF_curr_exp, cell_params_lif)) populations.append(p.Population(1, p.SpikeSourceArray, spikeArray)) for x in range(0, 12, 2): projections.append( p.Projection(populations[x], populations[x], p.FromListConnector(connections))) connector = p.FromListConnector(injectionConnection) projections.append( p.Projection(populations[x + 1], populations[x], connector)) populations[x].record() p.run(1000) p.end()
def test_recording_1_element(self): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) n_neurons = 200 # number of neurons in each population p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() projections = list() spike_array = {'spike_times': [[0]]} populations.append( p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(1, p.SpikeSourceArray, spike_array, label='inputSpikes_1')) projections.append( p.Projection(populations[1], populations[0], p.AllToAllConnector())) populations[1].record() p.run(5000) spike_array_spikes = populations[1].getSpikes() boxed_array = numpy.zeros(shape=(0, 2)) boxed_array = numpy.append(boxed_array, [[0, 0]], axis=0) numpy.testing.assert_array_equal(spike_array_spikes, boxed_array) p.end()
def do_run(nNeurons): spike_list = {'spike_times': [11, 22]} print spike_list p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0) pop = p.Population(nNeurons, p.SpikeSourceArray, spike_list, label='input') pop.record() p.run(200) spikes = pop.getSpikes(compatible_output=True) p.end() return spikes
def setup(runtime): try: p.end() except ConfigurationException: pass p.setup(timestep=1) pop_1 = p.Population(1, p.IF_curr_exp, {}, label="pop_1") input = p.Population(1, p.SpikeSourceArray, {'spike_times': [[0]]}, label="input") input_proj = p.Projection(input, pop_1, p.OneToOneConnector(weights=5.0, delays=1), target="excitatory") assert input_proj is not None p.run(runtime) return (pop_1, input, input_proj)
def do_run(nNeurons): p.setup(timestep=1, min_delay=1, max_delay=15) nNeurons = 1 # number of neurons in each population neuron_parameters = { 'cm': 0.25, 'i_offset': 2, 'tau_m': 10.0, 'tau_refrac': 2.0, 'tau_syn_E': 0.5, 'tau_syn_I': 0.5, 'v_reset': -65.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() populations.append( p.Population(nNeurons, p.IF_curr_exp, neuron_parameters, label='pop_1')) populations.append( p.Population(nNeurons, p.IF_curr_exp, neuron_parameters, label='pop_2')) populations[1].add_placement_constraint(x=1, y=0) populations[0].record_v() populations[0].record_gsyn() populations[0].record() populations[1].record_v() populations[1].record_gsyn() populations[1].record() p.run(100) v1 = populations[0].get_v() gsyn1 = populations[0].get_gsyn() spikes1 = populations[0].getSpikes() v2 = populations[0].get_v() gsyn2 = populations[0].get_gsyn() spikes2 = populations[0].getSpikes() p.end() return (v1, gsyn1, v2, gsyn2, spikes1, spikes2)
def test_run(self): with LogCapture() as l: p.setup() p1 = p.Population(1, p.IF_curr_exp, {}) p2 = p.Population(1, p.IF_curr_exp, {}) proj = p.Projection(p1, p2, p.AllToAllConnector()) p.run(500) proj.getWeights() p.run(500) proj.getWeights() p.end() self.assert_logs_messages(l.records, "Getting weights", 'INFO', 2)
def do_run(nNeurons, _neurons_per_core): spike_list = {'spike_times': [float(x) for x in range(0, 599, 50)]} p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0) p.set_number_of_neurons_per_core("SpikeSourceArray", _neurons_per_core) pop = p.Population(nNeurons, p.SpikeSourceArray, spike_list, label='input') pop.record() p.run(1000) spikes = pop.getSpikes(compatible_output=True) p.end() return spikes
def test_recording_poisson_spikes_rate_0(self): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) n_neurons = 256 # number of neurons in each population p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() projections = list() populations.append( p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(n_neurons, p.SpikeSourcePoisson, {'rate': 0}, label='inputSpikes_1')) projections.append( p.Projection(populations[1], populations[0], p.OneToOneConnector())) populations[1].record() p.run(5000) spikes = populations[1].getSpikes() print spikes p.end()
def do_run(n_neurons, n_cores, new_i_offset): p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / n_cores) cell_params_lif = { 'cm': 0.25, 'i_offset': 0.0, 'tau_m': 20.0, 'tau_refrac': 2.0, 'tau_syn_E': 5.0, 'tau_syn_I': 5.0, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -50.0 } populations = list() populations.append( p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations[0].record_v() populations[0].record_gsyn() populations[0].record() p.run(2000) populations[0].set('i_offset', new_i_offset) p.run(2000) spikes = populations[0].getSpikes(compatible_output=True) v = populations[0].get_v(compatible_output=True) gsyn = populations[0].get_gsyn(compatible_output=True) p.end() return (spikes, v, gsyn)
def do_run(nNeurons): cell_params_lif = { 'cm': 0.25, # nF 'i_offset': 0.0, 'tau_m': 10.0, 'tau_refrac': 2.0, 'tau_syn_E': 2.5, 'tau_syn_I': 2.5, 'v_reset': -70.0, 'v_rest': -65.0, 'v_thresh': -55.4 } spike_list = {'spike_times': [float(x) for x in range(0, 599, 50)]} p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0) p.set_number_of_neurons_per_core("SpikeSourceArray", 100) # FAILS populations = list() projections = list() populations.append( p.Population(nNeurons, p.SpikeSourceArray, spike_list, label='input')) populations.append( p.Population(1, p.IF_curr_exp, cell_params_lif, label='pop_1')) projections.append( p.Projection(populations[0], populations[1], p.AllToAllConnector())) populations[0].record() p.run(1000) spikes = populations[0].getSpikes(compatible_output=True) p.end() return spikes
def do_run(): # this test ensures there is too much dtcm used up, thus crashes during # initisation p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0) input = p.Population(1024, p.SpikeSourcePoisson, {'rate': 10}, "input") relay_on = p.Population(1024, p.IF_curr_exp, {}, "input") t_rule_LGN = p.SpikePairRule(tau_plus=17, tau_minus=34) w_rule_LGN = p.AdditiveWeightDependence(w_min=0.0, w_max=0.3, A_plus=0.01, A_minus=0.0085) stdp_model_LGN = p.STDPMechanism(timing_dependence=t_rule_LGN, weight_dependence=w_rule_LGN) s_d_LGN = p.SynapseDynamics(slow=stdp_model_LGN) p.Projection(input, relay_on, p.OneToOneConnector(weights=1), synapse_dynamics=s_d_LGN, target='excitatory') p.run(1000) p.end()
def do_run(nNeurons): p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0) p.set_number_of_neurons_per_core("IF_curr_exp", 100) cm = list() i_off = list() tau_m = list() tau_re = list() tau_syn_e = list() tau_syn_i = list() v_reset = list() v_rest = list() v_thresh = list() cell_params_lif = {'cm': cm, 'i_offset': i_off, 'tau_m': tau_m, 'tau_refrac': tau_re, 'tau_syn_E': tau_syn_e, 'tau_syn_I': tau_syn_i, 'v_reset': v_reset, 'v_rest': v_rest, 'v_thresh': v_thresh} for atom in range(0, nNeurons): cm.append(0.25) i_off.append(0.0) tau_m.append(10.0) tau_re.append(2.0) tau_syn_e.append(0.5) tau_syn_i.append(0.5) v_reset.append(-65.0) v_rest.append(-65.0) v_thresh.append(-64.4) gbar_na_distr = RandomDistribution('normal', (20.0, 2.0), rng=NumpyRNG(seed=85524)) cell_params_lif = {'cm': cm, 'i_offset': i_off, 'tau_m': tau_m, 'tau_refrac': tau_re, 'tau_syn_E': tau_syn_e, 'tau_syn_I': tau_syn_i, 'v_reset': v_reset, 'v_rest': v_rest, 'v_thresh': v_thresh} populations = list() projections = list() weight_to_spike = 2 delay = 1 connections = list() for i in range(0, nNeurons): singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay) connections.append(singleConnection) injectionConnection = [(0, 0, weight_to_spike, delay)] spikeArray = {'spike_times': [[0]]} populations.append(p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append(p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1')) populations[0].set({'cm': 0.25}) populations[0].set('cm', cm) populations[0].set({'tau_m': tau_m, 'v_thresh': v_thresh}) populations[0].set('i_offset', gbar_na_distr) populations[0].set('i_offset', i_off) projections.append(p.Projection(populations[0], populations[0], p.FromListConnector(connections))) projections.append(p.Projection(populations[1], populations[0], p.FromListConnector(injectionConnection))) populations[0].record_v() populations[0].record_gsyn() populations[0].record() p.run(100) v = populations[0].get_v(compatible_output=True) gsyn = populations[0].get_gsyn(compatible_output=True) spikes = populations[0].getSpikes(compatible_output=True) p.end() return (v, gsyn, spikes)
#Primary_like_pop.record_v() T_stellate_pop.record('spikes') T_stellate_pop.record_v() # Run simulation sim.run(sim_duration) T_stellate_spikes = T_stellate_pop.getSpikes() T_stellate_v = T_stellate_pop.get_v() D_stellate_spikes = oct_pop.getSpikes() D_stellate_v = oct_pop.get_v() #Primary_like_spikes = Primary_like_pop.getSpikes() #Primary_like_v = Primary_like_pop.get_v() # End simulation sim.end() spike_raster_plot(T_stellate_spikes, plt=plt, duration=duration, ylim=T_stellate_pop_size, scale_factor=0.001) spike_raster_plot(D_stellate_spikes, plt=plt, duration=duration, ylim=oct_pop_size + 1, scale_factor=0.001) cell_voltage_plot(T_stellate_v, plt=plt, duration=duration, id=65) #cell_voltage_plot(D_stellate_v,plt=plt,duration=duration) #spike_raster_plot(Primary_like_spikes,plt=plt,duration=duration,ylim=Primary_like_pop_size,scale_factor=0.001) #cell_voltage_plot(Primary_like_v,plt=plt,duration=duration)