import numpy as np
import nest
import shelve
import matplotlib.pyplot as plt
nest.Install('hh_motor_neuron_module')
neuron=nest.Create('hh_motor_neuron_nestml',1) #{'I_e':1000})
scg1 = nest.Create("step_current_generator", 1, params={
"amplitude_times": [1000],
"amplitude_values": [2000],
})
mm1 = nest.Create("multimeter", 1, params={
"interval": .1,
"start": 0,
"stop": 1000,
"record_from": ["I"],
})
multimeter = nest.Create("multimeter", params={'record_from':['V_m'],'interval': .1})
spikerecorder = nest.Create("spike_recorder")
spike_times = nest.GetStatus(spikerecorder, keys='events')[0]['times']
nest.Connect(multimeter, neuron)
nest.Connect(neuron, spikerecorder)
nest.Connect(scg1, neuron)
nest.Connect(mm1, scg1)
sim_time = 1000.0 # Simulation time in milliseconds
dt = 0.1 # Simulation time step in milliseconds
nest.Simulate(sim_time)
fig, ax = plt.subplots(nrows=2)
ax[0].plot(multimeter.get("events")["times"], multimeter.get("events")["V_m"])
ax[1].plot(mm1.get("events")["times"], mm1.get("events")["I"])
ax[0].scatter(spike_times, np.zeros_like(spike_times), marker="d", c="orange", alpha=.8, zorder=99)
ax[0].set_ylabel("v [mV]")
ax[1].set_ylabel("I")
ax[-1].set_xlabel("Time [ms]")
fig.show()
plt.show(block=True)
this is the code with injecting I_e that generates asysnchronous outputs between spikes and AP:
import numpy as np
import nest
import shelve
import matplotlib.pyplot as plt
nest.Install('hh_motor_neuron_module')
neuron=nest.Create('hh_motor_neuron_nestml',1, {'I_e':2000})
multimeter = nest.Create("multimeter", params={'record_from':['V_m'],'interval': .1})
spikerecorder = nest.Create("spike_recorder")
spike_times = nest.GetStatus(spikerecorder, keys='events')[0]['times']
nest.Connect(multimeter, neuron)
nest.Connect(neuron, spikerecorder)
sim_time = 1000.0 # Simulation time in milliseconds
dt = 0.1 # Simulation time step in milliseconds
nest.Simulate(sim_time)
dmm = multimeter.get()
Vms = dmm["events"]["V_m"]
ts = dmm["events"]["times"]
plt.figure(1)
plt.plot(ts, Vms)
events = spikerecorder.get("events")