Example #1
0
    # spinn_front_end_common.utilities.exceptions.ConfigurationException:
    # The number of params does not equal with
    # the number of atoms in the vertex
    def test_run(self):
        (pre_spikes, post_spikes, weights) = do_run(seed=self._test_seed)
        if self._test_seed == 1:
            self.assertEquals(183, len(pre_spikes))
            self.assertEquals(91, len(post_spikes))
            self.assertEquals(787, len(weights))
        else:
            try:
                self.assertLess(130, len(pre_spikes))
                self.assertGreater(220, len(pre_spikes))
                self.assertLess(70, len(post_spikes))
                self.assertGreater(110, len(post_spikes))
                self.assertLess(750, len(weights))
                self.assertGreater(900, len(weights))
            except Exception as ex:
                # Just in case the range failed
                raise SkipTest(ex)


if __name__ == '__main__':
    (pre_spikes, post_spikes, weights) = do_run()
    print(len(pre_spikes))
    print(len(post_spikes))
    plot_utils.plot_spikes([pre_spikes, post_spikes])
    print(len(weights))
    print("Weights:", weights)
Example #2
0
    populations[0].record("spikes")

    p.run(500)

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

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

    p.end()

    return (v, gsyn, spikes)


class SynfireIzhikevich(BaseTestCase):
    def test_run(self):
        nNeurons = 200  # number of neurons in each population
        (v, gsyn, spikes) = do_run(nNeurons)
        spike_checker.synfire_spike_checker(spikes, nNeurons)
        self.assertEquals(215, len(spikes))


if __name__ == '__main__':
    nNeurons = 200  # number of neurons in each population
    (v, gsyn, spikes) = do_run(nNeurons)
    print(len(spikes))
    plot_utils.plot_spikes(spikes)
    plot_utils.heat_plot(v, title="v")
    plot_utils.heat_plot(gsyn, title="gsyn")
Example #3
0
        spike_checker.synfire_multiple_lines_spike_checker(spikes,
                                                           n_neurons,
                                                           len(input),
                                                           wrap_around=False)

    def test_second_none(self):
        self.runsafe(self.second_none)


if __name__ == '__main__':
    synfire_run.do_run(n_neurons,
                       neurons_per_core=neurons_per_core,
                       run_times=run_times,
                       use_wrap_around_connections=wrap_around,
                       input_class=input_class,
                       start_time=start_time,
                       duration=duration,
                       rate=rate,
                       extract_between_runs=extract_between_runs,
                       set_between_runs=set_between_runs,
                       record_input_spikes=record_input_spikes)
    gsyn = synfire_run.get_output_pop_gsyn_exc_numpy()
    v = synfire_run.get_output_pop_voltage_numpy()
    input = synfire_run.get_spike_source_spikes_numpy()
    hist = numpy.histogram(input[:, 1], bins=[0, 5000, 10000])
    print(hist[0][0], hist[0][1])
    spikes = synfire_run.get_output_pop_spikes_numpy()
    plot_utils.plot_spikes(input, spikes2=spikes)
    plot_utils.heat_plot(v)
    plot_utils.heat_plot(gsyn)
synfire_run = TestRun()


class Synfire2RunExtractionIfCurrExpHigher(BaseTestCase):
    def test_run(self):
        synfire_run.do_run(nNeurons, spike_times=spike_times,
                           run_times=run_times, reset=reset)
        spikes = synfire_run.get_output_pop_spikes()

        self.assertEquals(53, len(spikes[0]))
        self.assertEquals(261, len(spikes[1]))
        spike_checker.synfire_spike_checker(spikes[0], nNeurons)
        spike_checker.synfire_multiple_lines_spike_checker(spikes[1], nNeurons,
                                                           2)


if __name__ == '__main__':
    synfire_run.do_run(nNeurons, spike_times=spike_times, run_times=run_times,
                       reset=reset)
    gsyn = synfire_run.get_output_pop_gsyn()
    v = synfire_run.get_output_pop_voltage()
    spikes = synfire_run.get_output_pop_spikes()

    print len(spikes[0])
    print len(spikes[1])
    plot_utils.plot_spikes(spikes[0], spikes[1])
    plot_utils.heat_plot(v[0], title="v1")
    plot_utils.heat_plot(gsyn[0], title="gysn1")
    plot_utils.heat_plot(v[1], title="v2")
    plot_utils.heat_plot(gsyn[1], title="gysn2")
Example #5
0
    pg_pop1.record("spikes")
    pg_pop2.record("spikes")

    sim.run(simtime)

    neo = pg_pop1.get_data("spikes")
    spikes1 = neo_convertor.convert_spikes(neo)
    neo = pg_pop2.get_data("spikes")
    spikes2 = neo_convertor.convert_spikes(neo)

    sim.end()

    return (spikes1, spikes2)


class TestPoisson(BaseTestCase):
    def test_run(self):
        (spikes1, spikes2) = do_run(self._test_seed)
        self.assertEquals(19, len(spikes1))
        self.assertEquals(24, len(spikes2))


if __name__ == '__main__':
    (spikes1, spikes2) = do_run()
    print(len(spikes1))
    print(spikes1)
    print(len(spikes2))
    print(spikes2)
    plot_utils.plot_spikes([spikes1, spikes2])
Example #6
0
    post_spikes = post_pop.getSpikes(compatible_output=True)

    p.end()

    return (weights, pre_spikes, post_spikes)


class stdp_example(BaseTestCase):
    def test_run(self):
        (weights, pre_spikes, post_spikes) = do_run()
        try:
            self.assertLess(140, len(pre_spikes))
            self.assertGreater(170, len(post_spikes))
            self.assertLess(80, len(post_spikes))
            self.assertGreater(100, len(post_spikes))
            self.assertLess(750, len(weights))
            self.assertGreater(850, len(weights))
        except Exception as ex:
            # Just in case the range failed
            raise SkipTest(ex)


if __name__ == '__main__':
    (weights, pre_spikes, post_spikes) = do_run()
    print len(pre_spikes)
    print len(post_spikes)
    plot_utils.plot_spikes(pre_spikes, title="pre-synaptic")
    plot_utils.plot_spikes(post_spikes, title="post-synaptic")
    print len(weights)
    print("Weights:", weights)
Example #7
0
    return noise_spike_times, s_pop_spikes, s_pop_voltages


class TestIfCurExpSingleNeuron(BaseTestCase):
    """
    tests the get spikes given a simulation at 0.1 ms time steps
    """
    def test_single_neuron(self):
        results = do_run()
        (noise_spike_times, s_pop_spikes, s_pop_voltages) = results
        try:
            self.assertLess(800, len(noise_spike_times))
            self.assertGreater(900, len(noise_spike_times))
            self.assertLess(2, len(s_pop_spikes))
            self.assertGreater(25, len(s_pop_spikes))
        except Exception as ex:
            # Just in case the range failed
            raise SkipTest(ex)


if __name__ == '__main__':
    results = do_run()
    (noise_spike_times, s_pop_spikes, s_pop_voltages) = results
    print noise_spike_times
    print len(noise_spike_times)
    print s_pop_spikes
    print len(s_pop_spikes)
    print s_pop_voltages
    plot_utils.plot_spikes([noise_spike_times, s_pop_spikes])
    plot_utils.line_plot(s_pop_voltages, title="s_pop_voltages")