Hi Atiye,

 

You need to read out the spike times *after* the simulation, i.e., move

 

spike_times = nest.GetStatus(spikerecorder, keys='events')[0]['times']

 

after

 

nest.Simulate(sim_time)

 

For tuning ionic currents, you may want to look at

 

https://www.ebrains.eu/tools/interactive-workflows-for-cellular-level-modeling

 

This is rather outside the scope of NEST, where the focus is more on simulating network dynamics.

 

Best,

Hans Ekkehard

 

 

-- 

 

Prof. Dr. Hans Ekkehard Plesser

 

Department of Data Science

Faculty of Science and Technology

Norwegian University of Life Sciences

PO Box 5003, 1432 Aas, Norway

 

Phone +47 6723 1560

Email hans.ekkehard.plesser@nmbu.no

Home http://arken.nmbu.no/~plesser

 

 

 

From: atiye nejadebrahim <atiye.nejadebrahim@yahoo.com>
Date: Wednesday, 23 August 2023 at 11:58
To: NEST User Mailing List <users@nest-simulator.org>
Subject: [NEST Users] Re: asynchronicity between spikes and firing pattern

Det er ikke ofte du mottar e-post fra atiye.nejadebrahim@yahoo.com. Finn ut hvorfor dette er viktig.

Thank you Professor Plesser for your comprehensive explanation; that was very helpful. when I changed sodium and pottassium conductance, downward flanks appeared without any need to define reset potential. since I have several ion channels, can you recommend me a package compatible to nest to optimize ions conductance?tuning by hand doesn't look like reasonable. 

Thank you Charl for your point. 

Just I still have problem with not showing spikes in the bellowed code. I changed "amplitude_times" to 10 or even more. Is something wrong in my code? 

 

    

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": [10],

  "amplitude_values": [5000],

})

 

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)

 

 

 

 

 

On Wednesday, August 23, 2023 at 08:50:23 AM GMT+2, Hans Ekkehard Plesser <hans.ekkehard.plesser@nmbu.no> wrote:

 

 

 

Hi!

 

Just a comment on the spike emission for Hodgkin-Huxley models. This is a non-trivial topic that requires the modeller to make a choice of what they want. Remember that the original Hodgkin-Huxley model is not a model of a neuron but a model for spike propagation down the squid axon. In this model, there is no such thing as a singular spike  in the sense we use it commonly when discussing integrate-and-fire point neuron models.

 

In the HH model, under certain conditions, we have a rapidly rising Na current depolarizing the membrane up to around +30 mV, followed by a rapidly activating K current repolarizing the memrane again towards -70 mV. The resulting memrane potential excursion looks like a spike, but the dynamics are entirely continuous and described by the HH ODEs. These ODEs also incorporate the refractory mechanism. If one creates a chain of HH-compartments, activation will thus travel one way, again as an entirely continuous process. Only when the activation reaches an axon terminal will something new happen: exocytosis of transmitter substances into the synaptic cleft.

 

In typical point-neuron models, on the other hand, we have on the one hand the sub-threshold membrane potential dynamics, described by continuous ODEs, and some threshold condition. When the threshold condition is met, we say the neuron emits a spike (in the sense of a singular event causing exocytosis at axon terminals) and typically some reset mechanism applies, followed by some refractory mechanism.

 

When we now force the HH model into this point-neuron framework subthreshold dynamics + threshold mechanism + reset + refractoriness, the modeller needs to make choices. For the subthreshold dynamics, one will usually use the HH equations, since this is a HH model, after all.

 

For the threshold mechanism, various choices would be possible, but somehow one needs to detect the fast rise followed by fast fall of the membrane potential. In the built-in hh_psc_alpha model, this is done by

 

    else if ( S_.y_[ State_::V_M ] >= 0 and U_old > S_.y_[ State_::V_M ] ) // ( threshold and maximum )

 

The first criterion makes sure that we are well into the rising flank of the Na-driven depolarization, the second that we have just passed the maximum of that excursion.

 

For the reset, hh_psc_alpha does nothing, which makes sense, since the subthreshold HH dynamics have the reset built in—the K current.

 

For refractoriness, hh_psc_alpha has a fixed refractory time (2 ms by default). In this model, the only effect of refractoriness is that it prohibits spiking. The subthreshold dynamics evolve freely during refractoriness. This again makes sense, since the HH dynamics have refractoriness built in. This is different in iaf-models, where the membrane potential is typically clamped to a reset potential during refractoriness.

 

Now the latter point raises the question of why hh_psc_alpha has an explicit refractory mechanism even though the HH-dynamics include refractory effects already. The reason is technical.  Given that the Na-current will push the membrane potential to around +30 mV, it will take several time steps before the K-current will pull the potential to below 0 mV again. Then, if

 

S_.y_[ State_::V_M ] >= 0 and U_old > S_.y_[ State_::V_M ]

 

is the criterion for spike emission, a spike would be emitted for every time step during the downward flank of the membrane potential excursion until V_m < 0 again. This might be the effect you see. The refractory period in NEST's hh_psc_alpha simply suppresses these spikes during the downward flank.

 

A better criterion could be to not just compare V_m at two points in time but at three time steps to look for an actual maximum.

 

Best regards,

Hans Ekkehard

 

 

-- 

 

Prof. Dr. Hans Ekkehard Plesser

 

Department of Data Science

Faculty of Science and Technology

Norwegian University of Life Sciences

PO Box 5003, 1432 Aas, Norway

 

Phone +47 6723 1560

Email hans.ekkehard.plesser@nmbu.no

Home http://arken.nmbu.no/~plesser

 

 

 

From: Charl Linssen <nest-users@turingbirds.com>
Date: Tuesday, 22 August 2023 at 17:05
To: users@nest-simulator.org <users@nest-simulator.org>
Subject: [NEST Users] Re: asynchronicity between spikes and firing pattern

Hi,

 

No problem. The step current generator isn't showing any effect, because the first timepoint of the current generator (in ``amplitude_times``) is set to 1000, and you're also simulating for 1000 ms, so the simulation ends too soon (or the amplitude timepoint should be set earlier).

 

As for the spiking behaviour, this is because of the way the NESTML model is formulated. When the neuron reaches threshold, a spike is emitted, but the membrane potential is not reset to a large negative value (like E_L), so it stays above threshold and the condition remains active, triggering more spikes to be emitted. You can add the reset to make this issue go away. If this reset is undesirable (because it does not match the way your model should behave), the test that finds the peak in V_m should be improved, for instance by storing one more "old" version of V_m as the model currently does on line 197.

 

Hope this helps!

 

Yours,

Charl

 

 

On Tue, Aug 22, 2023, at 15:47, atiye nejadebrahim wrote:

 

Hello Hans, 

This is the scripts with step_current_generator that can't generate spikes:

 

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")

the .nestml neuron model is attached. however it is clear in 'hh_psc_alpha' model, too. 

 

On Tuesday, August 22, 2023 at 03:33:35 PM GMT+2, Hans Ekkehard Plesser <hans.ekkehard.plesser@nmbu.no> wrote:

 

 

 

Hello Atiye,

 

Please post a script that reproduces the behavior you describe. Without it, it is impossible to provide good advice.

 

Best,

Hans Ekkehard

 

-- 

 

Prof. Dr. Hans Ekkehard Plesser

 

Department of Data Science

Faculty of Science and Technology

Norwegian University of Life Sciences

PO Box 5003, 1432 Aas, Norway

 

Phone +47 6723 1560

Email hans.ekkehard.plesser@nmbu.no

Home http://arken.nmbu.no/~plesser

 

 

 

From: atiye nejadebrahim <atiye.nejadebrahim@yahoo.com>
Date: Tuesday, 22 August 2023 at 14:12
To: NEST User Mailing List <users@nest-simulator.org>
Subject: [NEST Users] asynchronicity between spikes and firing pattern

Some people who received this message don't often get email from atiye.nejadebrahim@yahoo.com. Learn why this is important

Dear All,  

I made a HH neuron model and I can get an action potential from it. but it seems there is a problem in spikes. Action potential shape show one spike, but spike recorder shows several spikes and there is not any synchronicity between them. can you help me why? 

my second question is about spike generation, when I use I_e current for injecting current to the neuron, I can record spikes, but when I use step current generators, no spike shows. can you help me why?

Thank you for your consideration. 

Best, 

Atiyeh 

Inline image

 

 

Dear All,  

I made a HH neuron model and I can get an action potential from it. but it seems there is a problem in spikes. Action potential shape show one spike, but spike recorder shows several spikes and there is not any synchronicity between them. can you help me why? 

my second question is about spike generation, when I use I_e current for injecting current to the neuron, I can record spikes, but when I use step current generators, no spike shows. can you help me why?

Thank you for your consideration. 

Best, 

Atiyeh 

 

 

_______________________________________________

NEST Users mailing list -- users@nest-simulator.org

To unsubscribe send an email to users-leave@nest-simulator.org

_______________________________________________

NEST Users mailing list -- users@nest-simulator.org

To unsubscribe send an email to users-leave@nest-simulator.org

 

 

Attachments:

·         hh_motor_neuron.nestml

 

_______________________________________________
NEST Users mailing list -- users@nest-simulator.org
To unsubscribe send an email to users-leave@nest-simulator.org