extracellular stimulation

Anything that doesn't fit elsewhere.
Post Reply
m_nadimi
Posts: 8
Joined: Wed Jan 31, 2024 8:57 am

extracellular stimulation

Post by m_nadimi »

Good questions. Your instructor/advisor hasn't answered them, or did you ask? They usually don't bite. And if they do, shame on them.
Should the extracellular potential be added to all of these compartments or just nodes of ranvier?
All compartments, unless your conceptual model includes wrapping the myelinated sections in tinfoil and grounding the tinfoil. (don't laugh too hard; one of the strengths of computational modeling is that it allows one to try things that would be impossible or impractical in the real world)
I see from the posts in the forum that for the extracellular stimulation, Vector play class should be used.
Could be used. It's a convenient way to force e_extracellular to follow an arbitrary time course. There are other ways to drive e_extracellular.
My question is that this vector is the electric potential signal in time?
Yes. You'll need a vector that contains the time values, and for each compartment in your model you'll need another vector that contains the local extracellular potential values--unless you know that the normalized time course of extracellular potential follows the same waveform at all points in your model (which it should be if there is only one source of stimulus current, and the extracellular medium is purely resistive), in which case you could use xtra.mod and then just use one pair of vectors to drive its global stimulus current).
I have constant values for each point in space
As expected.
I should multiply it by time?
No. Those values are the values of extracellular potential at specific points in space produced by a constant stimulus current. In the usual experimental protocol, the stimulus current is off except during a time interval on the order of 0.1 to 1 ms. When the stimulus is off, the potential everywhere should be 0. That really should have been explained to you. If you don't have hands-on experience with extracellular stimulation, it would be helpful to read about how it is done (should be able to discover experimental protocols in papers or online), or at least talk with an experimentalist who can describe it to you.
this electric potentials should be added for each compartment separately or can a text file containing all extracellular potentials be loaded once?
How did McIntyre & Grill implement extracellular stimulation? (code available from modeldb.science, not that you should necessarily do what they did). If you want to see another example of how to implement extracelluar stimulation, get https://www.neuron.yale.edu/ftp/ted/neu ... sphere.zip
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: extracellular stimulation

Post by ted »

Oops, instead of replying to a copy of your original post, I edited it, inserting my replies. How careless of me; done when I was hurrying to get to the point but not cautious about how it was done. But at least I didn't destroy your questions, and perhaps my replies will be helpful to you and others.
m_nadimi
Posts: 8
Joined: Wed Jan 31, 2024 8:57 am

Re: extracellular stimulation

Post by m_nadimi »

Thanks for your answer. I'm starting to model simple neuron and then step by step make it more complex. Right now, I'm using the stimsphere code example. When I run the downloaded example directly as a .py file, it works fine. However, when I use the code below, it doesn't work correctly and just outputs a low pulse.

The main changes I've made are: neuron and pt3d definitions through Python file
I also applied current clamp through nrngui.
I was wondering why I'm not seeing an action potential (AP). I think I might be making mistakes somewhere.
Here’s the code I'm using:

Code: Select all

from neuron import h, gui, rxd
import matplotlib.pyplot as plt

from neuron.units import ms, mV

# h.load_file("stdrun.hoc")
path = "neuron/stimsphere/stimsphere"
neuron_extracellular_file = f"{path}/x86_64/libnrnmech.so"
h.nrn_load_dll(neuron_extracellular_file)
# h.load_file(f"{path}/sphere.hoc")

somaR = h.Section(name="somaR")
somaL = h.Section(name="somaL")
for sec in h.allsec():
    sec.diam = 5
    sec.L = 5

h.define_shape()
for i, sec in enumerate(h.allsec()):
    sec.pt3dclear()
    sec.pt3dadd(0, 0, 5 * (i), 5)
somaL.connect(somaR, 0, 1)

h.tstop = 500
NSEG = 15  # used by discretize() below

for sec in h.allsec():
    sec.insert("extracellular")
    sec.insert("xtra")
    sec.insert("hh")


def discretize(sec, ns, dedx):
    sec.nseg = ns
    # link extracellular and xtra
    for seg in sec:
        seg.xtra._ref_im = seg._ref_i_membrane
        seg.xtra._ref_ex = seg._ref_e_extracellular
    for seg in sec:
        xloc = (sec.diam3d(0) / 2) * seg.x
        seg.xtra.rx = 1e-9 * dedx * xloc


for sec in h.allsec():
    discretize(sec, NSEG, 1)

gvec = h.Vector(6)  # gradient--0 when field off, nonzero when on
tvec = h.Vector(6)
gvec.play(h._ref_is_xtra, tvec, 1)  # interpolated play


def makestim(ton, dur, grad):
    tvec.from_python([0, ton, ton, ton + dur, ton + dur, ton + dur + 1])
    gvec.from_python([0, 0, grad * 1e3, grad * 1e3, 0, 0])


makestim(1, 100, 4)

t = h.Vector().record(h._ref_t)
v = h.Vector().record(somaR(0)._ref_v)

h.finitialize(-80 * mV)
h.continuerun(10 * ms)
Last edited by m_nadimi on Tue Jul 02, 2024 5:41 am, edited 1 time in total.
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: extracellular stimulation

Post by ted »

First thing to check: what are the anatomical and biophysical properties of your model cell? What does
somaL.psection()
tell you? and how about somaR.psection()?
m_nadimi
Posts: 8
Joined: Wed Jan 31, 2024 8:57 am

Re: extracellular stimulation

Post by m_nadimi »

Thank you for your response.

While checking h.psection, I found that the length was incorrect due to a misuse of pt3dadd. Initially, I was using a single coordinate for the entire section. I corrected this by using 21 points, as specified in the hoc file.

However, I still do not see an action potential, and there is no noticeable difference in the psection output between somaR and somaL in both versions of the code.
The outputs of h.psection() are as below:
My implementation:
somaR { nseg=15 L=2.5 Ra=35.4
/*location 0 attached to cell 0*/
/* First segment only */
insert hh { gnabar_hh=0.12 gkbar_hh=0.036 gl_hh=0.0003 el_hh=-54.3}
insert na_ion { ena=50}
insert k_ion { ek=-77}
insert xtra { rx_xtra=8.33333e-11 x_xtra=0 y_xtra=0 z_xtra=0}
insert extracellular { xraxial=1e+09 xg=1e+09 xc=0 e_extracellular=0}
insert capacitance { cm=1}
insert morphology { diam=4.99345}
}
from main code:
somaR { nseg=15 L=2.5 Ra=35.4
/*location 0 attached to cell 0*/
/* First segment only */
insert xtra { rx_xtra=8.33333e-11 x_xtra=0 y_xtra=0 z_xtra=0}
insert extracellular { xraxial=1e+09 xg=1e+09 xc=0 e_extracellular=0}
insert hh { gnabar_hh=0.12 gkbar_hh=0.036 gl_hh=0.0003 el_hh=-54.3}
insert na_ion { ena=50}
insert k_ion { ek=-77}
insert capacitance { cm=1}
insert morphology { diam=4.99345}
m_nadimi
Posts: 8
Joined: Wed Jan 31, 2024 8:57 am

Re: extracellular stimulation

Post by m_nadimi »

My problem is solved.
somaL and somaR were in the same locations (I missed the negative sign).
I have a conceptual question (Sorry for asking a lot)
By setting a pulse duration of 100 ms, I see AP generation. However, if I reduce the pulse width to 0.1 ms, APs are not generated. Is this expected behavior, or is there a way to fix this issue? The current time step is set to 0.025 ms.
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: extracellular stimulation

Post by ted »

By setting a pulse duration of 100 ms, I see AP generation. However, if I reduce the pulse width to 0.1 ms, APs are not generated. Is this expected behavior
To help guide my answer, it would be useful to know if your background is primarily in physics/math/engineering, or in biology.
m_nadimi
Posts: 8
Joined: Wed Jan 31, 2024 8:57 am

Re: extracellular stimulation

Post by m_nadimi »

My background is electrical engineering.
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: extracellular stimulation

Post by ted »

It is the rare EE major that has much reading, classroom, or hand-on exposure to neurophysiology, and in particular practical aspects of stimulating excitable tissue (nerve, muscle). That's something you'll have to correct sooner or later if you plan to work at the interface between engineering and neuroscience. But here's something to help you answer your own question.

As you probably know, action potentials are generated by the opening and closing of voltage-gated ion channels in cell membranes--processes that have dynamics on the order of milliseconds. To trigger a spike, you must drive membrane potential away from resting potential in a positive direction, and this perturbation must be big enough and fast enough or there won't be a spike. [why "fast enough"?]

How do you change membrane potential? Change the charge that is stored in membrane capacitance. How do you do that? By forcing charge to enter the cell. This means causing current to enter the cell. Reduce the duration of current flow, and you reduce the total charge that enters the cell. And what does that do to the resulting perturbation of membrane potential?

So if you reduce the duration of current flow, what can you do to the stimulus to ensure that the perturbation of membrane potential is big enough to trigger a spike?
m_nadimi
Posts: 8
Joined: Wed Jan 31, 2024 8:57 am

Re: extracellular stimulation

Post by m_nadimi »

Thanks for explanation.

So in DBS, which the pulses are short, the high frequency is important to the AP generation.
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: extracellular stimulation

Post by ted »

in DBS, which the pulses are short, the high frequency is important to the AP generation.
Stimulus pulse duration is important, but you'll never guess why unless you take the time to learn more about the mechanistic basis of cellular excitability. And that should be covered in a good introductory course in neurophysiology, or any serious textbook on the topic.
m_nadimi
Posts: 8
Joined: Wed Jan 31, 2024 8:57 am

Re: extracellular stimulation

Post by m_nadimi »

Thanks for your answer and also for your concern.
I already know the mechanism: with a short pulse, there isn’t enough time for the membrane to depolarize and reach the activation threshold.

However, in DBS, the intervals between pulses are also short, so each pulse effect will be accumulated, leading to the activation threshold being reached.

I have another implementation question: What is the best way to apply the periodic waveform? I tried using vector play and created a waveform for 1 second. I’m not sure if this is the right way.

I also noticed in the forum that there’s an fsquare.mod that can be used. Is that correct?
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: extracellular stimulation

Post by ted »

I already know the mechanism: with a short pulse, there isn’t enough time for the membrane to depolarize and reach the activation threshold.
True, but that's easily overcome by increasing stimulus amplitude, and it's only half of the story. A longer duration extracellular pulse can (1) reduce excitability in depolarized neurites by inactivating spike sodium channels and activating spike potassium channels, and (2) increase excitability in hyperpolarized neurites by lowering baseline inactivation of sodium channels and baseline activation of potassium channels. Potential consequences include altering the effective location of spike initiation in the intended targets of stimulation, and promoting spiking in unintended targets. Also, in real world applications, electrode life may be shortened and tissue reaction increased because (1) means that more total charge must be applied to trigger each spike.
in DBS, the intervals between pulses are also short, so each pulse effect will be accumulated, leading to the activation threshold being reached.
As long as activation happens before unintended effects occur.
What is the best way to apply the periodic waveform? I tried using vector play and created a waveform for 1 second. I’m not sure if this is the right way.
Vector.play works well but requires user-written code to fill a pair of vectors with appropriate values. Vector.play into e_extracellular doesn't scale well because each segment will need its own vector for the time course of local e_extracellular. If the extracellular medium is assumed to be linear and purely resistive, a much easier and more efficient approach can be used.
I also noticed in the forum that there’s an fsquare.mod that can be used. Is that correct?
Any waveform that can be specified in closed algebraic form can be produced by NMODL code and used to drive the "is" global variable in the xstim or xtra density mechanism (both of which are described elsewhere). fsquare produces a square wave (see https://www.neuron.yale.edu/ftp/ted/neuron/fsquare.zip), but other duty cycles are possible, as are other waveforms including sine, rectified sine, swept sine.
Post Reply