Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Added example for collab submission
Browse files Browse the repository at this point in the history
  • Loading branch information
rowleya committed Sep 28, 2017
1 parent 0c71fe1 commit a3fb2fc
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions synfire/synfire_collab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""
Synfire chain example
"""
import spynnaker8 as sim
from spynnaker8.utilities import neo_convertor

# number of neurons in each population
n_neurons = 100
n_populations = 10
weights = 0.5
delays = 17.0
simtime = 1000

sim.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)

spikeArray = {'spike_times': [[0]]}
stimulus = sim.Population(1, sim.SpikeSourceArray, spikeArray,
label='stimulus')

chain_pops = [
sim.Population(n_neurons, sim.IF_curr_exp, {}, label='chain_{}'.format(i))
for i in range(n_populations)
]
for pop in chain_pops:
pop.record("spikes")

connector = sim.FixedNumberPreConnector(10)
for i in range(n_populations):
sim.Projection(chain_pops[i], chain_pops[(i + 1) % n_populations],
connector,
synapse_type=sim.StaticSynapse(weight=weights,
delay=delays))

sim.Projection(stimulus, chain_pops[0], sim.AllToAllConnector(),
synapse_type=sim.StaticSynapse(weight=5.0))

sim.run(simtime)
# None PyNN method which is faster
# spikes = [pop.spinnaker_get_data("spikes") for pop in chain_pops]

# Pynn method and support method
neos = [pop.get_data("spikes") for pop in chain_pops]
spikes = map(neo_convertor.convert_spikes, neos)

sim.end()


if __name__ == '__main__':
try:
import pylab
pylab.figure()
pylab.xlabel('Time (ms)')
pylab.ylabel('Neuron')
pylab.title('Spikes Sent By Chain')
offset = 0
for pop_spikes in spikes:
pylab.plot(
[i[1] for i in pop_spikes],
[i[0] + offset for i in pop_spikes], "."
)
offset += n_neurons
pylab.savefig("results.png")
except Exception as ex:
print ex
print spikes

0 comments on commit a3fb2fc

Please sign in to comment.