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))
            pop_1.record(["v"])
            simtime = 10
            sim.run(simtime)

            pop_1.get_data(variables=["spikes"])
Esempio n. 2
0
 def fixedpost_population_views(self):
     sim.setup(timestep=1.0)
     in_pop = sim.Population(4, sim.SpikeSourceArray([0]), label="in_pop")
     pop = sim.Population(4, sim.IF_curr_exp(), label="pop")
     rng = NumpyRNG(seed=1)
     conn = sim.Projection(in_pop[0:3], pop[1:4],
                           sim.FixedNumberPostConnector(2, rng=rng),
                           sim.StaticSynapse(weight=0.5, delay=2))
     sim.run(1)
     weights = conn.get(['weight', 'delay'], 'list')
     sim.end()
     # The fixed seed means this gives the same answer each time
     target = [(0, 1, 0.5, 2.0), (0, 3, 0.5, 2.0), (1, 1, 0.5, 2.0),
               (1, 3, 0.5, 2.0), (2, 1, 0.5, 2.0), (2, 2, 0.5, 2.0)]
     self.assertEqual(weights.tolist(), target)
Esempio n. 3
0
 def different_views(self):
     ps = PatternSpiker()
     sim.setup(timestep=1)
     simtime = 100
     pop = ps.create_population(sim,
                                n_neurons=10,
                                v_rec_indexes=[2, 4, 6, 8],
                                label="test")
     sim.run(simtime)
     ps.check(pop,
              simtime,
              v_rec_indexes=[2, 3, 4],
              is_view=True,
              missing=True)
     sim.end()
Esempio n. 4
0
def do_run():
    # Setup
    p.setup(timestep=1.0)

    # FPGA Retina - Down Polarity
    p.Population(2000,
                 p.external_devices.ArbitraryFPGADevice, {
                     'fpga_link_id': 12,
                     'fpga_id': 1,
                     'label': "bacon"
                 },
                 label='External sata thing')

    p.run(1000)
    p.end()
Esempio n. 5
0
def do_run():
    # Setup
    p.setup(timestep=1.0)

    p.Population(
        None,
        p.external_devices.ArbitraryFPGADevice(
            2000, fpga_link_id=12, fpga_id=1, label="bacon"))

    p.Population(
        None, p.external_devices.ArbitraryFPGADevice(
            2000, fpga_link_id=11, fpga_id=1, label="bacon"))

    p.run(1000)
    p.end()
Esempio n. 6
0
 def do_run(self):
     with LogCapture() as lc:
         sim.setup(1.0)
         pop = sim.Population(1, sim.IF_curr_exp, {}, label="pop")
         inp = sim.Population(1,
                              sim.SpikeSourceArray(spike_times=[0]),
                              label="input")
         sim.Projection(inp,
                        pop,
                        sim.OneToOneConnector(),
                        synapse_type=sim.StaticSynapse(weight=5))
         sim.run(10)
         self.assert_logs_messages(lc.records,
                                   "Working out if machine is booted",
                                   'INFO', 1)
Esempio n. 7
0
 def change_pre_reset(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(5)
     v1 = pop.spinnaker_get_data('v')
     self.check_from_65(v1)
     pop.set(tau_syn_E=1)
     sim.reset()
     sim.run(5)
     v2 = pop.spinnaker_get_data('v')
     sim.end()
     self.check_from_65(v2)
 def do_one_to_one_conductance_test(self, neurons_per_core, pre_size,
                                    post_size, weight, delay):
     sim.setup(1.0)
     sim.set_number_of_neurons_per_core(sim.IF_cond_exp, neurons_per_core)
     pre = sim.Population(pre_size, sim.IF_cond_exp())
     post = sim.Population(post_size, sim.IF_cond_exp())
     proj = sim.Projection(pre, post, sim.OneToOneConnector(),
                           sim.StaticSynapse(weight=weight, delay=delay))
     sim.run(0)
     conns = proj.get(["weight", "delay"], "list")
     sim.end()
     for pre, post, w, d in conns:
         assert pre == post
         assert numpy.allclose(w, weight, rtol=0.0001)
         assert d == delay
Esempio n. 9
0
    def __run_sim(self, run_times, populations, projections, run_count,
                  spike_times_list, extract_between_runs, get_spikes,
                  record_7, get_v, record_v_7, get_gsyn_exc, record_gsyn_exc_7,
                  get_gsyn_inh, record_gsyn_inh_7, record_input_spikes,
                  record_input_spikes_7, get_all, get_weights, get_delays,
                  new_pop, n_neurons, cell_class, cell_params, weight_to_spike,
                  set_between_runs, reset):
        results = ()

        for runtime in run_times[:-1]:
            # This looks strange but is to allow getting data before run
            if runtime > 0:
                p.run(runtime)
            run_count += 1

            if extract_between_runs:
                self._get_data(populations[0], populations[1],
                               get_spikes, record_7, get_v, record_v_7,
                               get_gsyn_exc, record_gsyn_exc_7,
                               get_gsyn_inh, record_gsyn_inh_7,
                               record_input_spikes, record_input_spikes_7,
                               get_all)
                self._get_weight_delay(projections[0], get_weights, get_delays)

            if new_pop:
                populations.append(
                    p.Population(
                        n_neurons, cell_class(**cell_params), label='pop_2'))
                injection_connection = [(n_neurons - 1, 0, weight_to_spike, 1)]
                new_projection = p.Projection(
                    populations[0], populations[2],
                    p.FromListConnector(injection_connection),
                    p.StaticSynapse(weight=weight_to_spike, delay=1))
                projections.append(new_projection)

            if spike_times_list is not None:
                populations[1].set(spike_times=spike_times_list[run_count])

            for (pop, name, value) in set_between_runs:
                new_values = {name: value}
                populations[pop].set(**new_values)

            if reset:
                p.reset()

        p.run(run_times[-1])

        return results
    def test_tun(self):
        with self.assertRaises(SpinnmanTimeoutException):
            p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)

            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,
                             FakeIFCurrExpDataHolder,
                             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_exc")
            populations[0].record("spikes")
            p.run(5000)
            p.end()
Esempio n. 11
0
def do_run():
    """
    test that tests the printing of v from a pre determined recording
    :return:
    """
    p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
    n_neurons = 128 * 128  # number of neurons in each population
    p.set_number_of_neurons_per_core(p.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 = 17

    spikes = read_spikefile('test.spikes', 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(),
        synapse_type=p.StaticSynapse(weight=weight_to_spike, delay=delay)))
    populations[1].record("spikes")

    p.run(1000)

    spikes = populations[1].spinnaker_get_data('spikes')

    p.end()

    return spikes
    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()
Esempio n. 13
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()
Esempio n. 14
0
    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)
 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()
Esempio n. 16
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
Esempio n. 17
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()
Esempio n. 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")
    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)
Esempio n. 21
0
    def do_run(self):
        sim.setup(timestep=1.0, n_boards_required=1)
        sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 100)

        machine = globals_variables.get_simulator().machine

        input1 = sim.Population(1,
                                sim.SpikeSourceArray(spike_times=[0]),
                                label="input1")
        input2 = sim.Population(1,
                                sim.SpikeSourceArray(spike_times=[0]),
                                label="input2")
        input3 = sim.Population(1,
                                sim.SpikeSourceArray(spike_times=[0]),
                                label="input3")
        input4 = sim.Population(1,
                                sim.SpikeSourceArray(spike_times=[0]),
                                label="input4")

        # Make sure there is stuff at the cores specified in the cfg file
        input1.set_constraint(ChipAndCoreConstraint(0, 0, 1))
        input2.set_constraint(ChipAndCoreConstraint(0, 0, 3))
        # While there must be a chip 0,0  chip 1,1 could be missing
        if machine.is_chip_at(1, 1):
            input3.set_constraint(ChipAndCoreConstraint(1, 1, 1))
        # Make sure there is stuff at a core not specified in the cfg file
        input4.set_constraint(ChipAndCoreConstraint(0, 0, 2))

        sim.run(500)

        provenance_files = self.get_app_iobuf_files()
        sim.end()

        self.assertIn("iobuf_for_chip_0_0_processor_id_1.txt",
                      provenance_files)
        self.assertNotIn("iobuf_for_chip_0_0_processor_id_2.txt",
                         provenance_files)
        self.assertIn("iobuf_for_chip_0_0_processor_id_3.txt",
                      provenance_files)
        self.assertNotIn("iobuf_for_chip_0_0_processor_id_4.txt",
                         provenance_files)
        if machine.is_chip_at(1, 1):
            self.assertIn("iobuf_for_chip_1_1_processor_id_1.txt",
                          provenance_files)
        self.assertNotIn("iobuf_for_chip_1_1_processor_id_2.txt",
                         provenance_files)
 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()
 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()
Esempio n. 24
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)
Esempio n. 25
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()
 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()
 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])
Esempio n. 28
0
def do_run():
    p.setup(1.0)

    inp = p.Population(100,
                       p.SpikeSourcePoisson(rate=2, seed=417),
                       label="input")
    inp.record("spikes")

    p.run(100)

    p.reset()

    inp.set(rate=30)

    p.run(100)

    p.end()
Esempio n. 29
0
    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)
Esempio n. 30
0
    def record_all(self):
        sim.setup(timestep=1)
        simtime = 100
        input = sim.Population(1, sim.SpikeSourceArray(spike_times=[0, 30]),
                               label="input")
        pop = sim.Population(32, sim.IF_curr_exp(), label="pop")
        sim.Projection(input, pop, sim.AllToAllConnector(),
                       synapse_type=sim.StaticSynapse(weight=5, delay=1))
        pop.record("all")
        sim.run(simtime)

        neo = pop.get_data("all")
        pop.write_data(pickle_path, "all")
        io = PickleIO(filename=pickle_path)
        all_saved = io.read()[0]
        neo_compare.compare_blocks(neo, all_saved)
        assert len(neo.segments[0].spiketrains) > 0
        assert len(neo.segments[0].filter(name="v")) > 0
        assert len(neo.segments[0].filter(name="gsyn_exc")) > 0

        spikes_neo = pop.get_data("spikes")
        pop.write_data(pickle_path, "spikes")
        io = PickleIO(filename=pickle_path)
        spikes_saved = io.read()[0]
        neo_compare.compare_blocks(spikes_neo, spikes_saved)
        assert len(spikes_neo.segments[0].spiketrains) > 0
        assert len(spikes_neo.segments[0].filter(name="v")) == 0
        assert len(spikes_neo.segments[0].filter(name="gsyn_exc")) == 0

        v_neo = pop.get_data("v")
        pop.write_data(pickle_path, "v")
        io = PickleIO(filename=pickle_path)
        v_saved = io.read()[0]
        neo_compare.compare_blocks(v_neo, v_saved)
        assert len(v_neo.segments[0].spiketrains) == 0
        assert len(v_neo.segments[0].filter(name="v")) > 0
        assert len(v_neo.segments[0].filter(name="gsyn_exc")) == 0

        gsyn_neo = pop.get_data("gsyn_exc")
        pop.write_data(pickle_path, "gsyn_exc")
        io = PickleIO(filename=pickle_path)
        gsyn_saved = io.read()[0]
        neo_compare.compare_blocks(gsyn_neo, gsyn_saved)
        assert len(gsyn_neo.segments[0].spiketrains) == 0
        assert len(spikes_neo.segments[0].filter(name="v")) == 0
        assert len(gsyn_neo.segments[0].filter(name="gsyn_exc")) > 0