Out of range error (when applying high-voltage pulses)

Anything that doesn't fit elsewhere.
Post Reply
jxk
Posts: 5
Joined: Wed Jan 17, 2024 4:29 am

Out of range error (when applying high-voltage pulses)

Post by jxk »

Hi,
I am running a model by Cameron McIntyre of an axon (3810 from Model DB) which is stimulated by extracellular voltage pulses(Python + Neuron). Recently, when using large amplitude pulses I get the following error:

exp(703.768) out of range, returning exp(700)
exp(707.553) out of range, returning exp(700)
exp(711.301) out of range, returning exp(700)
exp(715.013) out of range, returning exp(700)
No more errno warnings during this execution

I added code in Python to specify voltage stimulation. When the voltage is greater than 100V, I will get the above error. This is similar to the issue in the following post.
ny wrote: Fri Feb 25, 2011 7:24 am Hi,
I am running a model by Cameron McIntyre of an axon which is stimulated by extracellular voltage pulses. Recently, when using large amplitude pulses I get the following error:

exp(700.68) out of range, returning exp(700)
exp(711.563) out of range, returning exp(700)
exp(721.082) out of range, returning exp(700)
exp(729.442) out of range, returning exp(700)

I have read other posts on the forum and I have checked the Axnode.mod mechanism and it uses "vtrap" functions to check for zero denominators.
Can you help?
Nada
Especially, when I use the method in the post to modify the vtrap function to the following form:

FUNCTION vtrap(x,y) {
if (fabs(x/y) > 1e-6) {
vtrap = x/(exp(x/y) - 1)
} else {
vtrap = y*(1 - x/y/2) : from Taylor's series
}
}

The above error still exists.
Can anyone help?
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Out of range error (when applying high-voltage pulses)

Post by ted »

I hope you get an "out of range" error when the stimulus is 100 V. If you do this to living tissue, you'll fry something.
jxk
Posts: 5
Joined: Wed Jan 17, 2024 4:29 am

Re: Out of range error (when applying high-voltage pulses)

Post by jxk »

Sorry, I didn't explain the problem clearly.

For some special reasons, I need to apply high-voltage short pulses to living tissue to observe the production of action potentials in nearby muscles while treating the local tissue or organ.

Therefore, is there a way to solve this "out of range" error? Thanks.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Out of range error (when applying high-voltage pulses)

Post by ted »

As I recall, the original implementation by McIntyre & Grill didn't actually perturb extracellular potential. Instead, they used the "activating function" approach in which the effect of extracellular stimululation on the axon is represented by injecting a current into each compartment (segment). Is that what the code you're using is doing?
jxk
Posts: 5
Joined: Wed Jan 17, 2024 4:29 am

Re: Out of range error (when applying high-voltage pulses)

Post by jxk »

Similar to McIntyre et al., I applied a voltage to each compartment (segment) to represent extracellular stimulation.

Here is partial python code:

Code: Select all

# Import the voltage of each compartment(data[:, 1],all around 500mV)
data = np.loadtxt('xxx.txt', dtype=np.float32)
amplitude = 100

# stimulation start at 1ms, 100us monopolar pulse
for i in range(int(1 / para.dt) + 1,int(1.1 / para.dt) + 1):
    tmp[0, i] = 1
# Amplify the voltage of each compartment
for i in range(para.axontotal):
    Ve[i, :] = amplitude * tmp[0, :] * data[i, 1]

# Ve is the externally imported voltage stimulus
VectorList = [h.Vector().from_python(Ve[i, :]) for i in range(Ve.shape[0])]

# segment initialization
node = [h.Section(name='node[%d]' % i) for i in range(para.axonnodes)]
func.initial_node(node)

sections = [node[0]]
for i in range(para.axontotal - 1):
    sections.append(sections[i].children()[0])
for i in range(para.axontotal):
    VectorList[i].play(sections[i](0.5)._ref_e_extracellular, tvec,True)
If possible, could you help me find out what the problem is? I can email you the relevant documents.
Thanks.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Out of range error (when applying high-voltage pulses)

Post by ted »

I will need to be able to reproduce the problem. Please zip up the source code and email it to
ted dot carnevale at yale dot edu
and I will tell you what I find out.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Out of range error (when applying high-voltage pulses)

Post by ted »

Similar to McIntyre et al., I applied a voltage to each compartment (segment) to represent extracellular stimulation.
But the source code provided by McIntyre et al. (available at modeldb.science/3810) doesn't apply "a voltage to each compartment." Instead, it uses _intracelluar_ stimulation by current injection into a single compartment, and the "out of range" message appears if the 0.1 ms duration stimulus current exceeds about 830 nA. An 825 nA current pulse drives local membrane potential to about 3.8 V after 0.01 ms, and about 6.3 V after 0.1 ms--and that's across a membrane that is only about 100 Angstroms thick (1/100th of a micron). That seems unrealistically large, since the _extracellular_ potential gradient used to induce electroporation is about 3 orders of magnitude smaller (it's about 0.8 V/um = 8 mV/100 Angstroms), and the transmembrane potential that elicits electroporation is on the order of 1 V (see
Shi J. et al.
A Review on Electroporation-Based Intracellular Delivery
Molecules 23:3044, 2018
PMID: 30469344
PMCID: PMC6278265
DOI: 10.3390/molecules23113044
).

The code you sent does not implement extracellular stimulation, and the code example in your post on the Forum doesn't disclose much, so I can't really replicate what you are observing or advise you how to deal with it. Modeling studies of peripheral nerve, spinal cord, retina, and brain that I have seen are consistent with the idea that extracellular potential gradients sufficient to trigger spikes are far below the level that would induce electroporation, or produce numerical overflow in computational simulations. If your model involves driving e_extracellular, and the resulting extracellular potential gradient is large enough to cause numerical overflow, the question is why, and the answer lies somewhere in your code that drives e_extracellular, or the values that are used to drive it, or both.

It doesn't seem likely that such extreme potential gradients are relevant in clinical or laboratory practice. For some time now, equipment used to stimulate peripheral nerves via (skin) surface electrodes, e.g. to measure nerve conduction velocity or elicit of F waves or H reflexes, has been implemented as a current source, not as a voltage source. The open circuit voltage generated by such equipment may be on the order of 100 V, but the actual delivered current is limited by the equipment itself and by the impedance at the electrode-skin interface. Furthermore, the distance between the electrodes and the nerve is generally on the order of 1 cm, so a substantial amount of that current never gets near the nerve, but instead is shunted away by the considerable volume of (highly conductive) tissue that lies between nerve and the skin under the stimulating electrodes. Consequently the extracellular potential gradients in the nerve bundle itself will be smaller than one might expect from the rough (over)estimate
(open circuit voltage generated by the stimulator)/(distance from electrode to nerve) = 100 V/cm = 0.01 V/um

Similar considerations apply to the use of sharp metal electrodes to inject current directly into tissue near a nerve bundle. The electrode tip necessarily has a small surface area, so the electrode-tissue interface presents a high series resistance that can cause a large voltage drop between the output of the stimulator and the tissue.

Revised 20240128 NTC
jxk
Posts: 5
Joined: Wed Jan 17, 2024 4:29 am

Re: Out of range error (when applying high-voltage pulses)

Post by jxk »

Thanks for your detailed explanation, I will fully consider your suggestion and modify the model.

However, I have one more question. When you say that my code does not implement extracellular stimulation, do you mean that there is a problem with the way I apply stimulation or something else? But I was able to generate a normal action potential at low voltages.

Image
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Out of range error (when applying high-voltage pulses)

Post by ted »

you say that my code does not implement extracellular stimulation
Not true. Here's what I actually wrote:
The code you sent does not implement extracellular stimulation, and the code example in your post on the Forum doesn't disclose much
The first part of that is
The code you sent does not implement extracellular stimulation
And that's true. You emailed me a zip file that contained only a slight modification of the AXNODE.mod file used by McIntyre et al., which specifies the properties of the ion channels used in their model. Nothing about extracellular stimulation in that.

The second part is
the code example in your post on the Forum doesn't disclose much
And that's also true. The example looks like you're trying to set up Vector.play() to drive e_extracellular, but it involves many variables that aren't defined, and it omits all the code that sets up the model axon, specifies the variation of extracellular potential in space, and executes a simulation. There's no way to just look at it and say "I see how this works, and can visualize how the extracellular stimulus evolves with time over the length of the model axon." Are you reusing the "model specification code" (the code that sets up model topology, geometry, and biophysics) that McIntyre et al. used, or did you rewrite it in Python? If you did rewrite it, how do you know that the model it produces is identical to the model produced by executing the McIntyre et al. model specification code?). And without being able to execute your code, I can't perform the interactive tests that are needed to verify that your code is doing what you think it is doing. Does the extracellular stimulus even make sense--does it vary in space and time in a way that is physically realizable? I can't even tell if e_extracellular in every segment of every section is driven by the stimulus.

The figure in your most recent post shows what looks like an action potential that is preceded by a large stimulus artifact and followed by a prolonged depolarization. That doesn't tell me anything about whether your code is doing what it should.
jxk
Posts: 5
Joined: Wed Jan 17, 2024 4:29 am

Re: Out of range error (when applying high-voltage pulses)

Post by jxk »

Hi, ted,there may have been some misunderstanding.
You emailed me a zip file that contained only a slight modification of the AXNODE.mod file used by McIntyre et al., which specifies the properties of the ion channels used in their model. Nothing about extracellular stimulation in that.
I have sent you a new email.

I'm sorry for the trouble.
Post Reply