Skip to content

Commit

Permalink
duplicate pops
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Jul 15, 2024
1 parent 14076df commit c07c5cd
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions synfire/self_synfire.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (c) 2016 The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and

"""
Synfire chain example
"""
import matplotlib.pyplot as plt
import pyNN.spiNNaker as sim
import pyNN.utility.plotting as plot

# number of neurons in each population
n_neurons = 1000
simtime = 600
pops = 50

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

spikeArray = {'spike_times': [[0]]}
stimulus = sim.Population(1, sim.SpikeSourceArray, spikeArray,
label='stimulus')
injectionConnection = [(0, 0)]
chainConnection = [(n_neurons-1, 0)]
for i in range(n_neurons-1):
chainConnection.append((i, i+1))

for i in range(pops):
pop = sim.Population(n_neurons, sim.IF_curr_exp, {}, label=f'chain{i}')
pop.record("spikes")
#pop.record(["spikes", "v"])
sim.Projection(stimulus, pop,
sim.FromListConnector(injectionConnection),
sim.StaticSynapse(weight=5, delay=1))
sim.Projection(pop, pop,
sim.FromListConnector(chainConnection),
sim.StaticSynapse(weight=5, delay=1))

sim.run(simtime)
neo = pop.get_data(variables=["spikes"])
#neo = pop.get_data(variables=["spikes", "v"])
spikes = neo.segments[0].spiketrains
# print(spikes)
# v = neo.segments[0].filter(name='v')[0]
# print(v)
sim.end()

plot.Figure(
# plot voltage for first ([0]) neuron
# plot.Panel(v, ylabel="Membrane potential (mV)",
# data_labels=[pop.label], yticks=True, xlim=(0, simtime)),
# plot spikes
plot.Panel(spikes, yticks=True, markersize=5, xlim=(0, simtime)),
title="Self Synfire Example",
annotations="Simulated with {}".format(sim.name())
)
plt.show()

0 comments on commit c07c5cd

Please sign in to comment.