Precomputed waveform for extracellular stimulus

Anything that doesn't fit elsewhere.
Post Reply
vjs347
Posts: 9
Joined: Mon Oct 26, 2015 4:10 pm

Precomputed waveform for extracellular stimulus

Post by vjs347 »

Hello Ted,

I'm using the model files posted by you at http://www.neuron.yale.edu/ftp/ted/neur ... nd_rec.zip for extracellular stimulation of a myelinated axon. The stim.hoc file here allows me to apply a stimulus stored as a vector with another vector encoding time. Now I want to apply a pre computed waveform (Stored as vector with each values corresponding to onset time of stimuli) using Iclamp3 library files from https://www.neuron.yale.edu/neuron/stat ... istrib.zip.

In order to do this, I have a pointprocess created for Iclamp3 and the code looks something like this,

Code: Select all

//Begin PointProcessManager
{
load_file("pointman.hoc")
}
{
**Location of electrode** ocbox_ = new PointProcessManager(0)
}
{object_push(ocbox_)}
{
mt.select("Ipulse3") i = mt.selected()
ms[i] = new MechanismStandard("Ipulse3")
ms[i].set("dur", 1, 0)
ms[i].set("amp", 10, 0)
mt.select("Ipulse3") i = mt.selected() maction(i)
hoc_ac_ = 0.5
sec.sec move() d1.flip_to(0)
}
{object_pop() doNotify()}
{
ocbox_ = ocbox_.v1
ocbox_.map("PointProcessManager", 243, 481, 208.32, 316.8)
}
//End PointProcessManager
But I can't seem to figure out how to declare the electrode location in the point process. Could you throw some light on this? It would be very helpful. As far as I know, the extracellular library computes the transfer resistance between the location of stimulus in extracellular medium to all the nodes/points along the fiber which have xtra mechanism specified.

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

Re: Precomputed waveform for extracellular stimulus

Post by ted »

I can't seem to figure out how to declare the electrode location in the point process. Could you throw some light on this? It would be very helpful. As far as I know, the extracellular library computes the transfer resistance between the location of stimulus in extracellular medium to all the nodes/points along the fiber which have xtra mechanism specified.
It is time to correct three misunderstandings.

First, NEURON is not a Poisson solver. It offers no way to represent the electrical properties of a conductive medium. It provides no way to represent any current source or sink that may exist in a conductive medium.

Second, there is no "extracellular library". There is an extracellular "mechanism" which merely adds equations that represent one or more concentric layers around the cable that results from creating and connecting sections. Furthermore, the extracellular mechanism is not a surrogate for a conductive medium.

Third, NEURON's "point processes" were devised as a means for representing spatially localized signal sources that deliver current directly to the interior of a section. Period. Even if NEURON provided a way to represent the extracelluar medium, point processes couldn't inject current into it.


Now let's turn to what you're trying to do. You want to simulate the effect of a series of rectangular current pulses applied to a resistive medium, and you have a Vector that contains a sequence of times at which the pulses start. Is that correct?
vjs347
Posts: 9
Joined: Mon Oct 26, 2015 4:10 pm

Re: Precomputed waveform for extracellular stimulus

Post by vjs347 »

ted wrote:
I can't seem to figure out how to declare the electrode location in the point process. Could you throw some light on this? It would be very helpful. As far as I know, the extracellular library computes the transfer resistance between the location of stimulus in extracellular medium to all the nodes/points along the fiber which have xtra mechanism specified.
It is time to correct three misunderstandings.

First, NEURON is not a Poisson solver. It offers no way to represent the electrical properties of a conductive medium. It provides no way to represent any current source or sink that may exist in a conductive medium.

Second, there is no "extracellular library". There is an extracellular "mechanism" which merely adds equations that represent one or more concentric layers around the cable that results from creating and connecting sections. Furthermore, the extracellular mechanism is not a surrogate for a conductive medium.

Third, NEURON's "point processes" were devised as a means for representing spatially localized signal sources that deliver current directly to the interior of a section. Period. Even if NEURON provided a way to represent the extracelluar medium, point processes couldn't inject current into it.
Thanks for your response Ted. I'm very new to Neuron community and may take time to get the basics right. I appreciate your time to explain the above pointers.
Now let's turn to what you're trying to do. You want to simulate the effect of a series of rectangular current pulses applied to a resistive medium, and you have a Vector that contains a sequence of times at which the pulses start. Is that correct?
Yes, that's absolutely what I am trying to do.
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Precomputed waveform for extracellular stimulus

Post by ted »

vjs347 wrote:
ted wrote:. . . NEURON is not a Poisson solver. It offers no way to represent the electrical properties of a conductive medium. It provides no way to represent any current source or sink that may exist in a conductive medium.
. . . There is an extracellular "mechanism" which merely adds equations that represent one or more concentric layers around the cable that results from creating and connecting sections. Furthermore, the extracellular mechanism is not a surrogate for a conductive medium.
. . . Even if NEURON provided a way to represent the extracelluar medium, point processes couldn't inject current into it.
So we're stuck having to represent extracellular stimulation either by inserting extracellular into sections and then modulating e_extracellular potential in the course of a simulation, or using the "activating function" approach (approximating the effect of the extracellular field by injecting current into each compartment). Just mentioning this here for the benefit of others who may read this thread in the future.
You want to simulate the effect of a series of rectangular current pulses applied to a resistive medium, and you have a Vector that contains a sequence of times at which the pulses start. Is that correct?
Yes, that's absolutely what I am trying to do.
Then the easiest way to proceed is to use the same approach that is used by the files in extracellular_stim_and_rec.zip. Everything related to constructing the stimulus waveform is contained in the file stim.hoc, which is loaded by the statement
load_file("stim.hoc")
in initxstim.hoc. You need to create a new file called vstim.hoc that does these things:
1. reads your file that contains the sequence of stimulus start times
2. uses that information to construct a pair of Vectors called stim_amp and stim_time that define the stimulus waveform.

Then you need to change the statement
load_file("stim.hoc")
in initxstim.hoc to

Code: Select all

// load_file("stim.hoc")
load_file("vstim.hoc") // reads stimulus times from a file and constructs stim vectors
and you'll be ready to go.

I have already made such a vstim.hoc file and will email it to you, along with a file that contains some example stimulus times.
vjs347
Posts: 9
Joined: Mon Oct 26, 2015 4:10 pm

Re: Precomputed waveform for extracellular stimulus

Post by vjs347 »

Then the easiest way to proceed is to use the same approach that is used by the files in extracellular_stim_and_rec.zip. Everything related to constructing the stimulus waveform is contained in the file stim.hoc, which is loaded by the statement
load_file("stim.hoc")
in initxstim.hoc. You need to create a new file called vstim.hoc that does these things:
1. reads your file that contains the sequence of stimulus start times
2. uses that information to construct a pair of Vectors called stim_amp and stim_time that define the stimulus waveform.

Then you need to change the statement
load_file("stim.hoc")
in initxstim.hoc to

Code: Select all

// load_file("stim.hoc")
load_file("vstim.hoc") // reads stimulus times from a file and constructs stim vectors
and you'll be ready to go.

I have already made such a vstim.hoc file and will email it to you, along with a file that contains some example stimulus times.
Thanks a lot Ted. The codes worked perfectly and I was able to use them with my existing files. Your help and time is truly appreciated.
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Precomputed waveform for extracellular stimulus

Post by ted »

Terrific! When it comes time to publish your work, please be sure to cite NEURON.
One of these two will do nicely:

Carnevale, N.T. and Hines, M.L. The NEURON Book. Cambridge, UK: Cambridge University Press, 2006.

Hines, M.L. and Carnevale, N.T. The NEURON simulation environment. Neural Computation 9:1179-1209, 1997.
vjs347
Posts: 9
Joined: Mon Oct 26, 2015 4:10 pm

Re: Precomputed waveform for extracellular stimulus

Post by vjs347 »

ted wrote:Terrific! When it comes time to publish your work, please be sure to cite NEURON.
One of these two will do nicely:

Carnevale, N.T. and Hines, M.L. The NEURON Book. Cambridge, UK: Cambridge University Press, 2006.

Hines, M.L. and Carnevale, N.T. The NEURON simulation environment. Neural Computation 9:1179-1209, 1997.
Sure thing Ted. We will cite Neuron and acknowledge your help.
vjs347
Posts: 9
Joined: Mon Oct 26, 2015 4:10 pm

Re: Precomputed waveform for extracellular stimulus

Post by vjs347 »

Hey Ted, I seem to have found a bug in the vstim.hoc code you sent me. Whenever I try to change the value of amplitude/duration from the GUI generated from vstim.hoc, the stim_amp and stim_time keeps getting populated with junk values. i.e. zero stimulus values in stim_amp, and time indexes in stim_time. Do you think its the problem with the while loop in the code?
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Precomputed waveform for extracellular stimulus

Post by ted »

vjs347 wrote:Whenever I try to change the value of amplitude/duration from the GUI generated from vstim.hoc, the stim_amp and stim_time keeps getting populated with junk values
The stim_time Vector needs to be completely rebuilt every time proc stim_waveform() is called. In stim_waveform() change

Code: Select all

stim_time.append($o1, $o1) // now contains 2*num values
to

Code: Select all

//  stim_time.append($o1, $o1) // now contains 2*num values
  stim_time = $o1.c
  stim_time.append($o1) // now contains 2*num values
vjs347
Posts: 9
Joined: Mon Oct 26, 2015 4:10 pm

Re: Precomputed waveform for extracellular stimulus

Post by vjs347 »

ted wrote:
vjs347 wrote:Whenever I try to change the value of amplitude/duration from the GUI generated from vstim.hoc, the stim_amp and stim_time keeps getting populated with junk values
The stim_time Vector needs to be completely rebuilt every time proc stim_waveform() is called. In stim_waveform() change

Code: Select all

stim_time.append($o1, $o1) // now contains 2*num values
to

Code: Select all

//  stim_time.append($o1, $o1) // now contains 2*num values
  stim_time = $o1.c
  stim_time.append($o1) // now contains 2*num values
Thanks for the response Ted. That seems to solve the problem of having junk values in the stim vectors. If I run the stimulus with default AMP/DUR values, the simulation runs perfectly. Now when I change the amplitude from GUI, the new vector generated is correct. But running the simulation doesn't elicit the stimulus. i.e. the membrane potential along the axon is flat.

I'm not sure why this is happening since the vector generated is correct and the function calling the interpolated play is the same.
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Precomputed waveform for extracellular stimulus

Post by ted »

Everything works fine with the "original" stimulus, but if you change the pulse times, durations, or amplitudes, the stimulus vanishes?
If yes, then Vector.play has been broken, which suggests that some operation affecting stim_amp has made this objref point to a different instance of the Vector class than it originally did. Vector.sort seems the most likely culprit. Make the following changes, then see if the problem has gone away.

Change
ATTACHED__ = 0
to
// ATTACHED__ = 0

In proc attach_stim() change

Code: Select all

    if (ATTACHED__ == 0) {  // don't bother if stim is already attached to something
      if (ismembrane("xtra")) {
        stim_amp.play(&is_xtra, stim_time, 1) // "interpolated" play
        ATTACHED__ = 1
      }
    }
to

Code: Select all

//    if (ATTACHED__ == 0) {  // don't bother if stim is already attached to something
      if (ismembrane("xtra")) {
        stim_amp.play(&is_xtra, stim_time, 1) // "interpolated" play
//        ATTACHED__ = 1
      }
//    }
Post Reply