# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: sPyNNakerGit
#     language: python
#     name: spynnakergit
# ---

# +
import spynnaker8 as p
import time
from matplotlib import pyplot as plt
import numpy as np
import spynnaker8.spynnaker_plotting as pl
import spynnaker8.utilities.neo_convertor as convert
from pyNN.utility.plotting import Figure, Panel

start_time = time.time()

#time of simulation
TotalDuration = 100.0

#parameters
a = 0.03
b = -2
c = -50
d = 100

#Constant current
current_pulse = 250
current_pulse = current_pulse+100

#Number of output neurons 
NumYCells = 10

#Model used
model_Izh = p.Izhikevich

'''Starting the Spinnaker Simulation'''
p.setup(timestep=0.1,min_delay=1.0,max_delay=14.0)
#number of neurons per core
p.set_number_of_neurons_per_core(p.SpikeSourceArray,50)

#setting up the parameters for Izh
cell_params = {'a':a, 'b':b, 'c':c, 'd':d,'i_offset':current_pulse}
y_Izh_population = p.Population(NumYCells, model_Izh(**cell_params),label='Izh_neuron_input')

#recording the spikes and voltage
y_Izh_population.record(["spikes","v"])

#running simulation for total duration
p.run(TotalDuration)

#extracting the membrane potential data in millivolts
y_izh_data = y_Izh_population.get_data(["v","spikes"])

Figure(
    #raster plot of the presynaptic neuron spike times
    Panel(y_izh_data.segments[0].spiketrains,yticks=True,markersize=0.4, xlim=(0,TotalDuration)),
    title="Izh").save("Izh_output.png")
plt.show()

#release spinnaker machine
p.end()

# +
import spynnaker8 as p
import time
from matplotlib import pyplot as plt
import numpy as np
import spynnaker8.spynnaker_plotting as pl
import spynnaker8.utilities.neo_convertor as convert
from pyNN.utility.plotting import Figure, Panel

start_time = time.time()

#time of simulation
TotalDuration = 100.0

#parameters
a = 0.03
b = -2
c = -50
d = 100

#Constant current
current_pulse = 250
current_pulse = current_pulse+100

#Number of output neurons 
NumYCells = 10

#Model used
model_Izh = p.Izhikevich

'''Starting the Spinnaker Simulation'''
p.setup(timestep=0.1,min_delay=1.0,max_delay=14.0)
#number of neurons per core
p.set_number_of_neurons_per_core(p.SpikeSourceArray,50)

#setting up the parameters for Izh
cell_params = {'a':a, 'b':b, 'c':c, 'd':d,'i_offset':current_pulse}
y_Izh_population = p.Population(NumYCells, model_Izh(**cell_params),label='Izh_neuron_input')

#recording the spikes and voltage
y_Izh_population.record(["spikes","v"])

#running simulation for total duration
p.run(TotalDuration)

#extracting the membrane potential data in millivolts
# y_izh_data = y_Izh_population.get_data(["v","spikes"])
data = y_Izh_population.get_data().segments[0]
vm = data.filter(name="v")[0]
Figure(
    Panel(vm, ylabel="Membrane potential (mV)"),
    Panel(data.spiketrains, xlabel="Time (ms)", xticks=True)
).save("simulation_results.png")

# Figure(
#     #raster plot of the presynaptic neuron spike times
#     Panel(y_izh_data.segments[0].spiketrains,yticks=True,markersize=0.4, xlim=(0,TotalDuration)),
#     title="Izh").save("Izh_output.png")
# plt.show()

#release spinnaker machine
p.end()
# -



StarcoderdataJupyterScriptsDedupFiltered