コード例 #1
0
 def check_rates(self, rates, seconds):
     n_neurons = 100
     sim.setup(timestep=1.0)
     inputs = {}
     for rate in rates:
         params = {"rate": rate}
         input = sim.Population(n_neurons,
                                sim.SpikeSourcePoisson,
                                params,
                                label='inputSpikes_{}'.format(rate))
         input.record("spikes")
         inputs[rate] = input
     sim.run(seconds * 1000)
     for rate in rates:
         self.check_spikes(inputs[rate], rate * seconds)
     sim.end()
コード例 #2
0
    def test_get_v_view(self):
        sim.setup(timestep=1.0)
        pop = sim.Population(4, sim.IF_curr_exp(), label="a label")
        pop.record("spikes")
        pop._get_spikes = mock_spikes
        pop._get_recorded_matrix = mock_v_all
        get_simulator().get_current_time = mock_time

        view = pop[1:3]
        neo = view.get_data("v")
        v = neo.segments[0].filter(name='v')[0].magnitude
        (target, _, _) = mock_v_one_two("v")
        assert v.shape == target.shape
        assert numpy.array_equal(v, target)

        sim.end()
コード例 #3
0
    def do_run(self):
        sim.setup(timestep=1.0)
        sim.set_number_of_neurons_per_core(sim.IF_curr_exp, neurons_per_core)

        input_spikes = list(range(0, simtime - 100, 10))
        expected_spikes = len(input_spikes)
        input = sim.Population(
            1, sim.SpikeSourceArray(spike_times=input_spikes), label="input")
        pop_1 = sim.Population(n_neurons, sim.IF_curr_exp(), label="pop_1")
        sim.Projection(input, pop_1, sim.AllToAllConnector(),
                       synapse_type=sim.StaticSynapse(weight=5, delay=1))
        pop_1.record(["spikes", "v", "gsyn_exc"])
        sim.run(simtime//4*3)
        sim.run(simtime//4)
        check_data(pop_1, expected_spikes, simtime)
        sim.end()
コード例 #4
0
ファイル: test_getting.py プロジェクト: jspaaks/sPyNNaker8
    def test_get_spikes_by_view(self):
        sim.setup(timestep=1.0)
        pop = sim.Population(4, sim.IF_curr_exp(), label="a label")
        pop._get_spikes = mock_spikes
        get_simulator().get_current_time = mock_time

        view = pop[1:3]
        view.record("spikes")
        neo = view.get_data("spikes", gather=False)
        spikes = neo_convertor.convert_spikes(neo)
        target = trim_spikes(mock_spikes(), [1, 2])
        assert numpy.array_equal(spikes, target)
        spiketrains = neo.segments[0].spiketrains
        assert 2 == len(spiketrains)

        sim.end()
コード例 #5
0
def do_run(nNeurons, timestep):

    spike_list = {'spike_times': SPIKE_TIMES}
    print(spike_list)
    p.setup(timestep=timestep, min_delay=timestep, max_delay=timestep * 10)

    pop = p.Population(nNeurons, p.SpikeSourceArray, spike_list, label='input')

    pop.record("spikes")

    p.run(200)

    neo = pop.get_data("spikes")
    p.end()

    return neo
コード例 #6
0
ファイル: test_getting.py プロジェクト: jspaaks/sPyNNaker8
    def test_get_spike_counts(self):
        sim.setup(timestep=1.0)
        pop = sim.Population(4, sim.IF_curr_exp(), label="a label")
        pop.record("spikes")
        pop._get_spikes = mock_spikes
        get_simulator().get_current_time = mock_time

        assert {0: 7, 1: 3, 2: 2, 3: 0} == pop.get_spike_counts()

        view = pop[1:4]
        assert {1: 3, 2: 2, 3: 0} == view.get_spike_counts()

        assert 3 == pop.meanSpikeCount()
        assert 5 / 3 == view.mean_spike_count()

        sim.end()
コード例 #7
0
ファイル: test_getting.py プロジェクト: jspaaks/sPyNNaker8
    def test_get_(self):
        sim.setup(timestep=1.0)
        pop = sim.Population(4, sim.IF_curr_exp(), label="a label")
        pop._get_spikes = mock_spikes
        pop._get_recorded_matrix = mock_v_all
        get_simulator().get_current_time = mock_time

        v = pop.spinnaker_get_data("v")
        assert 400 == len(v)

        v = pop.spinnaker_get_data(["v"])
        assert 400 == len(v)

        with pytest.raises(ConfigurationException):
            pop.spinnaker_get_data(["v", "spikes"])
        sim.end()
コード例 #8
0
ファイル: test_reset_add_pop.py プロジェクト: ghlim/sPyNNaker
    def testReset_add(self):
        sim.setup(timestep=1.0)
        sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 1)

        input = sim.Population(1,
                               sim.SpikeSourceArray(spike_times=[0]),
                               label="input")
        pop_1 = sim.Population(2, sim.IF_curr_exp(), label="pop_1")
        sim.Projection(input,
                       pop_1,
                       sim.AllToAllConnector(),
                       synapse_type=sim.StaticSynapse(weight=5, delay=1))
        sim.run(10)
        sim.Population(2, sim.IF_curr_exp(), label="pop_2")
        with self.assertRaises(NotImplementedError):
            sim.run(10)
コード例 #9
0
ファイル: test_getting.py プロジェクト: jspaaks/sPyNNaker8
    def test_get_v_missing(self):
        sim.setup(timestep=1.0)
        pop = sim.Population(4, sim.IF_curr_exp(), label="a label")
        pop._get_recorded_matrix = mock_v_one_two
        get_simulator().get_current_time = mock_time

        view = pop[0:3]
        neo = view.get_data("v")
        v = neo.segments[0].filter(name='v')[0].magnitude
        (target, _, _) = mock_v_one_two("v")
        assert numpy.array_equal(
            [1, 2], neo.segments[0].filter(name='v')[0].channel_index.index)
        assert v.shape == target.shape
        assert numpy.array_equal(v, target)

        sim.end()
コード例 #10
0
    def test_using_static_synapse_doubles(self):
        sim.setup(timestep=1.0)
        input = sim.Population(2, sim.SpikeSourceArray([0]), label="input")
        pop = sim.Population(2, sim.IF_curr_exp(), label="pop")
        as_list = [(0, 0), (1, 1)]
        conn = sim.Projection(
            input, pop, sim.FromListConnector(as_list),
            sim.StaticSynapse(weight=[0.7, 0.3], delay=[3, 33]))
        sim.run(1)
        weights = conn.get(['weight', 'delay'], 'list')
        target = [(0, 0, 0.7, 3), (1, 1, 0.3, 33)]
        for i in range(2):
            for j in range(2):
                self.assertAlmostEqual(weights[i][j], target[i][j], places=3)

        sim.end()
コード例 #11
0
    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()
コード例 #12
0
 def test_set_spikes_interval(self):
     sim.setup(timestep=1)
     if_curr = sim.Population(1, sim.IF_curr_exp())
     recorder = if_curr._vertex.neuron_recorder
     self.assertCountEqual([],
                           if_curr._recorder.get_all_recording_variables())
     ssa = sim.Population(1, sim.SpikeSourceArray(spike_times=[0]))
     ssp = sim.Population(2,
                          sim.SpikeSourcePoisson(rate=100.0),
                          additional_parameters={"seed": 1})
     if_curr.record("spikes", sampling_interval=2)
     ssa.record("spikes", sampling_interval=2)
     ssp.record("spikes", sampling_interval=2)
     self.assertCountEqual(["spikes"],
                           if_curr._recorder.get_all_recording_variables())
     assert recorder.get_neuron_sampling_interval("spikes") == 2
コード例 #13
0
ファイル: test_getting.py プロジェクト: ghlim/sPyNNaker
    def test_get_spikes_by_index(self):
        sim.setup(timestep=1.0)
        pop = sim.Population(4, sim.IF_curr_exp(), label="a label")
        pop.record("spikes")

        Recorder.get_spikes = mock_spikes
        get_simulator().get_current_time = mock_time

        neo = pop.get_data_by_indexes("spikes", [1, 2])
        spikes = neo_convertor.convert_spikes(neo)
        target = trim_spikes(mock_spikes(None), [1, 2])
        assert numpy.array_equal(spikes, target)
        spiketrains = neo.segments[0].spiketrains
        assert 2 == len(spiketrains)

        sim.end()
コード例 #14
0
def do_run(split, seed=None):
    p.setup(1.0)

    if split:
        p.set_number_of_neurons_per_core(p.SpikeSourcePoisson, 27)
        p.set_number_of_neurons_per_core(p.IF_curr_exp, 22)

    inp = p.Population(100,
                       p.SpikeSourcePoisson(rate=100, seed=seed),
                       label="input")
    pop = p.Population(100, p.IF_curr_exp, {}, label="pop")

    p.Projection(inp,
                 pop,
                 p.OneToOneConnector(),
                 synapse_type=p.StaticSynapse(weight=5))

    pop.record("spikes")
    inp.record("spikes")

    p.run(100)

    inp.set(rate=10)
    # pop.set("cm", 0.25)
    pop.set(tau_syn_E=1)

    p.run(100)

    pop_spikes1 = pop.spinnaker_get_data('spikes')
    inp_spikes1 = inp.spinnaker_get_data('spikes')

    p.reset()

    inp.set(rate=0)
    pop.set(i_offset=1.0)
    vs = p.RandomDistribution("uniform", [-65.0, -55.0],
                              rng=NumpyRNG(seed=seed))
    pop.initialize(v=vs)

    p.run(100)

    pop_spikes2 = pop.spinnaker_get_data('spikes')
    inp_spikes2 = inp.spinnaker_get_data('spikes')

    p.end()

    return (pop_spikes1, inp_spikes1, pop_spikes2, inp_spikes2)
コード例 #15
0
    def do_run(self):
        sim.setup(1.0)
        pop = sim.Population(1, sim.IF_curr_exp, {}, label="pop")
        pop.set(i_offset=1.0)
        pop.record(["v"])
        initial1 = -64.0
        initial2 = -62.0
        initial3 = -63.0
        initial4 = -61.0
        runtime = 10

        pop.initialize(v=initial1)
        sim.run(runtime)

        sim.reset()
        pop.initialize(v=initial2)
        sim.run(runtime)

        sim.reset()
        pop.initialize(v=initial3)
        pop.set(i_offset=2.0)
        sim.run(runtime)

        try:
            pop.initialize(v=initial4)  # this should throw an exception
        except Exception:
            pass

        pop.set(i_offset=2.5)
        sim.run(runtime)

        v = pop.get_data('v')

        sim.end()

        # test values at start of each run() call above
        self.assertEqual(v.segments[0].filter(name='v')[0][0], initial1)
        self.assertEqual(v.segments[1].filter(name='v')[0][0], initial2)
        self.assertEqual(v.segments[2].filter(name='v')[0][0], initial3)
        self.assertNotEqual(v.segments[2].filter(name='v')[0][runtime],
                            initial4)

        # test the lengths of each segment are correct
        self.assertEqual(len(v.segments[0].filter(name='v')[0]), runtime)
        self.assertEqual(len(v.segments[0].filter(name='v')[0]),
                         len(v.segments[1].filter(name='v')[0]))
        self.assertEqual(len(v.segments[2].filter(name='v')[0]), 2 * runtime)
コード例 #16
0
    def do_run(self):
        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
        spike_times = [20., 40., 60.]
        exc_pop = p.Population(1, p.SpikeSourceArray,
                               {'spike_times': spike_times})
        inh_pop = p.Population(1, p.SpikeSourceArray,
                               {'spike_times': [120, 140, 160]})
        # setup excitatory and inhibitory connections
        listcon = p.FromListConnector([(0, 0, 0.05, 1.0)])
        p.Projection(exc_pop, if_pop, listcon, receptor_type='excitatory')
        p.Projection(inh_pop, if_pop, listcon, receptor_type='inhibitory')
        # setup recorder
        if_pop.record(["v"])
        p.run(100)
        p.reset()
        if_pop.initialize(v=-65)
        exc_pop.set(spike_times=[])
        inh_pop.set(spike_times=spike_times)
        p.run(100)
        # read out voltage and plot
        neo = if_pop.get_data("all")
        p.end()
        v = neo_convertor.convert_data(neo, "v", run=0)
        v2 = neo_convertor.convert_data(neo, "v", run=1)

        self.assertGreater(v[22][2], v[21][2])
        self.assertGreater(v[42][2], v[41][2])
        self.assertGreater(v[62][2], v[61][2])
        self.assertLess(v2[22][2], v2[21][2])
        self.assertLess(v2[42][2], v2[41][2])
        self.assertLess(v2[62][2], v2[61][2])
def do_run(nNeurons):

    p.setup(timestep=0.1, min_delay=1.0, max_delay=7.5)
    p.set_number_of_neurons_per_core(p.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()
    synapse_type = p.StaticSynapse(weight=weight_to_spike,
                                   delay=injection_delay)
    projections.append(p.Projection(populations[0], populations[1], connector,
                                    synapse_type=synapse_type))
    connector = p.OneToOneConnector()
    synapse_type = p.StaticSynapse(weight=weight_to_spike, delay=delay)
    projections.append(p.Projection(populations[1], populations[2], connector,
                                    synapse_type=synapse_type))

    populations[1].record("v")
    populations[1].record("spikes")

    p.run(100)

    neo = populations[1].get_data(["v", "spikes"])

    v = neo_convertor.convert_data(neo, name="v")
    spikes = neo_convertor.convert_spikes(neo)

    p.end()

    return (v, spikes)
コード例 #18
0
def structural_eliminate_to_empty():
    p.setup(1.0)
    stim = p.Population(9, p.SpikeSourceArray(range(10)), label="stim")

    # These populations should experience elimination
    pop = p.Population(9, p.IF_curr_exp(), label="pop")

    # Make a full list

    # Elimination with random selection (0 probability formation)
    proj = p.Projection(
        stim, pop, p.AllToAllConnector(),
        p.StructuralMechanismStatic(
            partner_selection=p.RandomSelection(),
            formation=p.DistanceDependentFormation([3, 3], 0.0),
            elimination=p.RandomByWeightElimination(4.0, 1.0, 1.0),
            f_rew=1000,
            initial_weight=4.0,
            initial_delay=3.0,
            s_max=9,
            seed=0,
            weight=0.0,
            delay=1.0))

    pop.record("rewiring")

    p.run(1000)

    # Get the final connections
    conns = list(proj.get(["weight", "delay"], "list"))

    rewiring = pop.get_data("rewiring")
    formation_events = rewiring.segments[0].events[0]
    elimination_events = rewiring.segments[0].events[1]

    num_forms = len(formation_events.times)
    num_elims = len(elimination_events.times)

    first_elim = elimination_events.labels[0]

    p.end()

    # These should have no connections since all should be eliminated
    assert (len(conns) == 0)
    assert (num_elims == 81)
    assert (num_forms == 0)
    assert (first_elim == "7_5_elimination")
コード例 #19
0
    def test_write(self):
        sim.setup(timestep=1.0)
        pop = sim.Population(4, sim.IF_curr_exp(), label="a label")
        pop._get_spikes = mock_spikes
        pop._get_recorded_matrix = mock_v_all
        get_simulator().get_current_time = mock_time

        # Note gather=False will be ignored just testing it can be
        pop.write_data("spikes.pkl", "spikes", gather=False)
        try:
            with open("spikes.pkl") as pkl:
                neo = pickle.load(pkl)
                spikes = neo_convertor.convert_spikes(neo)
                assert numpy.array_equal(spikes, mock_spikes())
        except UnicodeDecodeError:
            raise SkipTest(
                "https://github.com/NeuralEnsemble/python-neo/issues/529")

        pop.printSpikes("spikes.pkl")
        try:
            with open("spikes.pkl") as pkl:
                neo = pickle.load(pkl)
                spikes = neo_convertor.convert_spikes(neo)
                assert numpy.array_equal(spikes, mock_spikes())
        except UnicodeDecodeError:
            raise SkipTest(
                "https://github.com/NeuralEnsemble/python-neo/issues/529")

        (target, _, _) = mock_v_all("any")

        pop.print_v("v.pkl")
        with open("v.pkl") as pkl:
            neo = pickle.load(pkl)
            v = neo.segments[0].filter(name='v')[0].magnitude
            assert v.shape == target.shape
            assert numpy.array_equal(v, target)

        pop.print_gsyn("gsyn.pkl")
        with open("gsyn.pkl") as pkl:
            neo = pickle.load(pkl)
            exc = neo.segments[0].filter(name='gsyn_exc')[0].magnitude
            assert numpy.array_equal(exc, target)
            inh = neo.segments[0].filter(name='gsyn_inh')[0].magnitude
            assert numpy.array_equal(inh, target)

        sim.end()
コード例 #20
0
ファイル: test_idmixin.py プロジェクト: jspaaks/sPyNNaker8
 def test_get_set(self):
     sim.setup(timestep=1.0)
     pop_1 = sim.Population(N_NEURONS, sim.IF_curr_exp(), label=LABEL)
     cells = pop_1.all_cells
     p_tau_m = pop_1.get("tau_m")
     tau_m_3 = cells[3].tau_m
     assert p_tau_m[3] == tau_m_3
     cells[2].tau_m = 2
     p_tau_m = pop_1.get("tau_m")
     assert 2 == p_tau_m[2]
     params = cells[1].get_parameters()
     p_i_offset = pop_1.get("i_offset")
     assert params["i_offset"][0] == p_i_offset[1]
     cells[2].set_parameters(tau_m=3, i_offset=13)
     params = cells[2].get_parameters()
     assert 13 == params["i_offset"][0]
     sim.end()
    def test_cause_error(self):
        with self.assertRaises(ConfigurationException):
            sim.setup(timestep=1.0)
            sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 100)

            pop_1 = sim.Population(1, sim.IF_curr_exp(), label="pop_1")
            input = sim.Population(1,
                                   sim.SpikeSourceArray(spike_times=[0]),
                                   label="input")
            sim.Projection(input,
                           pop_1,
                           sim.OneToOneConnector(),
                           synapse_type=sim.StaticSynapse(weight=5, delay=1))
            simtime = 10
            sim.run(simtime)

            pop_1.get_data(variables=["v"])
コード例 #22
0
 def check_other_connect(self, connections, with_replacement):
     sim.setup(1.0)
     pop1 = sim.Population(SOURCES, sim.IF_curr_exp(), label="pop1")
     pop2 = sim.Population(DESTINATIONS, sim.IF_curr_exp(), label="pop2")
     synapse_type = sim.StaticSynapse(weight=5, delay=1)
     projection = sim.Projection(pop1,
                                 pop2,
                                 sim.FixedNumberPostConnector(
                                     connections,
                                     with_replacement=with_replacement),
                                 synapse_type=synapse_type)
     sim.run(0)
     self.check_weights(projection,
                        connections,
                        with_replacement,
                        allow_self_connections=True)
     sim.end()
コード例 #23
0
 def test_check_connection_estimates(self):
     # Test that the estimates for connections per neuron/vertex work
     sim.setup(timestep=1.0)
     n_neurons = 25
     pop1 = sim.Population(n_neurons, sim.IF_curr_exp(), label="pop_1")
     pop2 = sim.Population(n_neurons, sim.IF_curr_exp(), label="pop_2")
     projection = sim.Projection(pop1,
                                 pop2,
                                 sim.FixedNumberPostConnector(n_neurons //
                                                              2),
                                 synapse_type=sim.StaticSynapse(weight=5,
                                                                delay=1))
     simtime = 10
     sim.run(simtime)
     weights = projection.get(["weight"], "list")
     self.assertEqual(n_neurons * int(n_neurons / 2), len(weights))
     sim.end()
コード例 #24
0
    def 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(p.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("spikes")

        p.run(5000)

        spike_array_spikes = populations[1].spinnaker_get_data("spikes")
        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()
コード例 #25
0
 def check_self_connect(self, connections, with_replacement,
                        allow_self_connections):
     sim.setup(1.0)
     pop = sim.Population(DESTINATIONS, sim.IF_curr_exp(), label="pop")
     synapse_type = sim.StaticSynapse(weight=5, delay=1)
     projection = sim.Projection(
         pop,
         pop,
         sim.FixedNumberPreConnector(
             connections,
             with_replacement=with_replacement,
             allow_self_connections=allow_self_connections),
         synapse_type=synapse_type)
     sim.run(0)
     self.check_weights(projection, connections, with_replacement,
                        allow_self_connections)
     sim.end()
コード例 #26
0
 def run_set_run_reset_set(self):
     sim.setup(1.0)
     pop = sim.Population(1, sim.IF_curr_exp, {}, label="pop")
     pop.set(i_offset=1.0)
     pop.set(tau_syn_E=1)
     pop.record(["v"])
     sim.run(2)
     pop.set(tau_syn_E=1)
     sim.run(3)
     v1 = pop.spinnaker_get_data('v')
     self.check_from_65(v1)
     sim.reset()
     pop.set(tau_syn_E=1)
     sim.run(5)
     v2 = pop.spinnaker_get_data('v')
     sim.end()
     self.check_from_65(v2)
コード例 #27
0
ファイル: reset.py プロジェクト: stjordanis/sPyNNaker8
    def test_run(self):
        p.setup()
        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
        }

        pop = p.Population(10, p.IF_curr_exp(**cell_params_lif), label='test')
        p.run(100)
        pop.set(cm=0.30)
コード例 #28
0
 def do_run(self):
     sim.setup(timestep=1.0)
     input_pop = sim.Population(1,
                                sim.SpikeSourceArray(range(
                                    0, run_time, 100)),
                                label="input")
     test_pop = sim.Population(1, MyFullNeuron(), label="my_full_neuron")
     test_pop.record(['spikes', 'v'])
     sim.Projection(input_pop,
                    test_pop,
                    sim.AllToAllConnector(),
                    receptor_type='excitatory',
                    synapse_type=sim.StaticSynapse(weight=2.0))
     sim.run(run_time)
     neo = test_pop.get_data('all')
     sim.end()
     self.check_results(neo, [501])
コード例 #29
0
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_exc")
    populations[0].record("spikes")
    populations[1].record("v")
    populations[1].record("gsyn_exc")
    populations[1].record("spikes")

    p.run(100)

    v1 = populations[0].spinnaker_get_data("v")
    gsyn1 = populations[0].spinnaker_get_data("gsyn_exc")
    spikes1 = populations[0].spinnaker_get_data("spikes")
    v2 = populations[1].spinnaker_get_data("v")
    gsyn2 = populations[1].spinnaker_get_data("gsyn_exc")
    spikes2 = populations[1].spinnaker_get_data("spikes")

    p.end()

    return (v1, gsyn1, v2, gsyn2, spikes1, spikes2)
コード例 #30
0
def do_run():
    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
    }

    p.setup()
    p1 = p.Population(5, p.IF_curr_exp(**CELL_PARAMS_LIF), label='pop_1')

    p1.set(cm=0.2)