Extracellular time varying input

Anything that doesn't fit elsewhere.
Post Reply
m.capogrosso
Posts: 8
Joined: Tue Jan 25, 2011 12:13 pm

Extracellular time varying input

Post by m.capogrosso »

Hi Ted, and Hi to all.

I'm a Phd student,
I'm working on network model. I wish to stimulate fibers and somas using the built in extracellular mechanism.
I managed to stimulate a fiber nodes sections with a single pulse of width pwd using the cvode.event code:

Code: Select all

 
proc init(){	finitialize(-78)          
		fih = new FInitializeHandler(0, "set_e_ext(0)")
    	}

proc set_e_ext() {
 if ($1 == 0) {
    	   for nc = 0, nnode-1 {
 	       	   node[nc] {
  		   e_extracellular = 0 
		   	}
		   }
		   
	cvode.event(del, "set_e_ext(1)") 
	} else if ($1 == 1) { 
     	    for nc = 0, nnode-1 {
     	    	node[nc] {
     	       	     e_extracellular = V.x[nc] 
   		   }
		   	}
	cvode.event(del + pwd, "set_e_ext(2)")
		} else if ($1 == 2){
      	  for nc = 0, nnode-1 {
	      	   node[nc] {
		   	    e_extracellular = 0 
  				}
		}
		cvode.event(0, "set_e_ext(0)")
    		}
}
where V.x[nc] is a vector taken from an ASCII file. In this way I generated a single square pulse of width pwd.
Now I wish to stimulate the fiber with a sinusoidal or better with a square wave of a given frequency, pulse width and amplitude.

Is this possible using the extracellular mechanism?

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

Re: Extracellular time varying input

Post by ted »

Before I answer your question, here's a recommendation and a question for you:

It's good to see another NEURON user employing the FInitializeHandler class. I would suggest that instead of

Code: Select all

 proc init(){	finitialize(-78)          
		fih = new FInitializeHandler(0, "set_e_ext(0)")
    	}
you just declare

Code: Select all

fih = new FInitializeHandler(0, "set_e_ext(0)")
at the "top level" of the hoc interpreter, i.e. outside of any proc or func, and certainly not inside an init() proc.

Here's why: as the documentation of the FInitializeHandler class mentions, one of the motivations for adding this class to NEURON was to reduce the need for users to create custom versions of the standard run system's proc init(), but the code in your post begins with a completely unnecessary custom proc init(). Reviewing the documentation of the FInitializeHandler class in the Programmer's Reference, I see why this might have happened: the documentation provides four different examples of how to use the FInitializeHandler class, and the last example embeds the class in the init procedure of a template (a class definition). This is guaranteed to be a source of confusion for users who are not familiar with the details of templates in NEURON. Without going into all the gory details, here are the key points:
1. The proc init() inside the Test template of that example has nothing whatever to do with the standard run system's proc init(). The fih created inside the Test template's proc init() has nothing whatever to do with the three objrefs called fih[0], fih[1], and fih[2] which were created by executing statements at the "top level" of the hoc interpreter (the hoc interpreter is a stack-based interpreter, and any statement that lies outside of a proc, func, or class is at the top level of the interpreter's stack).
2. The only time it might be useful to create an instance of the FInitializeHandler class inside a procedure called "init" is when that procedure is part of a template. And this will be a rare occurrence. Most templates have no need to create an instance of the FInitializeHandler class.
3. In almost all instances, when it is useful to create an instance of the FInitializeHandler class, this can be done at the top level of the hoc interpreter--as was done for fih[0]...fih[2] in the Programmer's Reference example.

Next, a couple of questions for you. First, it looks like you're trying to stimulate a myelinated axon, but the myelinated internodes are not exposed to the extracellular field. Are you sure this is a reasonable assumption? The specific conductance and capacitance of myelin may be small compared to the properties of nodal membrane, but internodal distances can be hundreds of times longer than the length of a node. Second, what are you going to do about nonmyelinated sections such as dendrites?

Finally, your question:
I wish to stimulate the fiber with a sinusoidal or better with a square wave of a given frequency, pulse width and amplitude.
There are several ways to do this, but determining which is best for your application depends on details of what you want to do. For example, it's easy to generate a sequence of rectangular pulses with the event delivery system, but that might not scale well as model complexity increases. How big a net are you thinking about implementing?
m.capogrosso
Posts: 8
Joined: Tue Jan 25, 2011 12:13 pm

Re: Extracellular time varying input

Post by m.capogrosso »

Hi Ted,
First thanks for the clever explanation of the FInitializeHandler class, I will update my code as you suggests.
Now I come to you questions:
First, it looks like you're trying to stimulate a myelinated axon, but the myelinated internodes are not exposed to the extracellular field. Are you sure this is a reasonable assumption?
I took the code from a model that i built just for myelinated fibers. I was not interested in frequency effects of any sort because I wanted just to replicate some experimental measures that we had, and in those experiments we were stimulating fibers with a single monopolar square pulse. The output of the model was just the number of fibers recruited. Therefore for this very first approximation I just modeled the myelin as a perfect insulator like this:

Code: Select all

 for i=0, nnode paranode[i] {
      nseg = 11
      diam = (D-m)  //AXON diameter
      L = 100*D //FIBER diameter
      Ra = 70 //MRG
      cm=10e-20
      insert extracellular
      e_extracellular=0
    }
Just leaving the default parameters for xc and xg.
Now I'm going to model a Newtork made of 12 cells. Geometrically reallistic.
Second, what are you going to do about nonmyelinated sections such as dendrites?
I'm planning to do something like this:

Code: Select all

forsec "dendrite" {
       nseg = 5
       Ra = 200
       cm = 2 
       insert pas
       g_pas = 0.0002
       e_pas = -70.0 
        insert extracellular{
      xg[0]=1e10
      xg[1]=1e10
      xc[0]=0
      xc[1]=0
      xraxial[0]=1e20
      xraxial[1]=1e20
      e_extracellular=0
      }
}
Where I will replace e_extracellular with the proper value of the external field taken from an interpolation of the 3d results obtained with a FEM simulation.

Now the second question:
How big a net are you thinking about implementing?
As I told you there are 12 cells, evevery one has an order of 100 dendrite segments, 1 soma, 20 paranodes and 20 nodes for the myelinated axons.

And all these sections must be exposed to an external field this time, because I'm going to simulate a non perfect insulator myelin for the paranodes. And moreover I have to reproduce a situation in which we stimulate with square pulses at 100 Hz with width of the order of 10 ms
I'm planning to run the stimulation for at least 1000 ms to see the behavior of the Network. I've already tested with all the extracelluar mehanisims and it is very slow, But I have no rush, and I need precision :)
ted
Site Admin
Posts: 6296
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extracellular time varying input

Post by ted »

m.capogrosso wrote:
First, it looks like you're trying to stimulate a myelinated axon, but the myelinated internodes are not exposed to the extracellular field. Are you sure this is a reasonable assumption?
. . .
for this very first approximation I just modeled the myelin as a perfect insulator
So the assumption is OK.
Now I'm going to model a Newtork made of 12 cells. Geometrically reallistic.
. . .
. . . I will replace e_extracellular with the proper value of the external field taken from an interpolation of the 3d results obtained with a FEM simulation.
. . .
. . . there are 12 cells, evevery one has an order of 100 dendrite segments, 1 soma, 20 paranodes and 20 nodes for the myelinated axons.

And all these sections must be exposed to an external field
You can probably continue to use the approach you are now using. Make sure that you change e_extracellular at each internal node of each section, i.e. at the beginning and end of each pulse

Code: Select all

forall {
  for (x,0) set e_extracelluar(x) to the correct new value
}
That's a lot of hoc code to execute in the middle of a simulation, but it only happens once for every 10/dt fadvances, so I doubt that run time will suffer much.

Alternatively you could use the approach that I developed and implemented in http://www.neuron.yale.edu/ftp/ted/neur ... d_rec.zip , which assumes that the extracellular potential in each segment j is the product of a local scale factor rx_j and a global variable is_j. Model setup involves a bit more overhead because a few extra hoc statements must be executed to assign the rx_j values and link each e_extracellular by a pointer to the corresponding rx*is, but this is all repaid during simulation execution, because compiled code automatically sets e_extracellular in each segment j to the product rx_j*is_j.

Both approaches are equally accurate within their appropriate domains. The first approach is best suited for situations in which the field changes abruptly at intervals that are long compared to the integration time step dt. If the field is a continuous function of time, the second approach will be much faster. However, the second approach is limited to situations in which the extracellular medium is purely resistive, or is well approximated by a resistive medium. The first approach will work even if the medium has significant reactance, assuming that this was taken into account during the calculation of the extracellular field.
m.capogrosso
Posts: 8
Joined: Tue Jan 25, 2011 12:13 pm

Re: Extracellular time varying input

Post by m.capogrosso »

However, the second approach is limited to situations in which the extracellular medium is purely resistive, or is well approximated by a resistive medium
Unfortunately this is not the case, because my networks are located in highly anisotropic structures. So I think I should probably use the e_extracellular approach.

Now, Getting back to my principal question, you said:
For example, it's easy to generate a sequence of rectangular pulses with the event delivery system
Can you please tell me where I can find a detailed description of how to do so?
Do I have to put the cvode_event within a for or something? or there is a more "elegant" way to achieve a train of identical square pulses?

thanks for all the help
ted
Site Admin
Posts: 6296
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extracellular time varying input

Post by ted »

m.capogrosso wrote:
However, the second approach is limited to situations in which the extracellular medium is purely resistive, or is well approximated by a resistive medium
Unfortunately this is not the case, because my networks are located in highly anisotropic structures.
Anisotropic has nothing to do with whether the medium is resistive, i.e. linear. If the medium is resistive, the potential at any point xyz at any time is the weighted sum of all currents that are being injected into the medium at that time. Each weight is the transfer resistance between xyz and the corresponding current source.
For example, it's easy to generate a sequence of rectangular pulses with the event delivery system
Can you please tell me where I can find a detailed description of how to do so?
I'll see if I can find an example.
ted
Site Admin
Posts: 6296
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extracellular time varying input

Post by ted »

m.capogrosso
Posts: 8
Joined: Tue Jan 25, 2011 12:13 pm

Re: Extracellular time varying input

Post by m.capogrosso »

Thaks fo the example you found! :)
Anisotropic has nothing to do with whether the medium is resistive, i.e. linear. If the medium is resistive, the potential at any point xyz at any time is the weighted sum of all currents that are being injected into the medium at that time. Each weight is the transfer resistance between xyz and the corresponding current source.
Ok Now I really got It, you are saying that the other mechanisms is able to replace the extracellular if the outer media is purely resistive and wave effects could be neglected. Yes this have nothing to do with anisotropy. However I don't understand one thing. I use COMSOL to extract the electric potential distribution into anisotropic media, and fibers and dendrites often crosses several media. If I took the voltage distributions from COMSOL how do I link these results with the other model? I mean, do I still have to define an rx_j for each segment?, and if so, I imagine that the rx_j should be the same as the media that surrounds the segment.
Am I right?
ted
Site Admin
Posts: 6296
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extracellular time varying input

Post by ted »

m.capogrosso wrote:do I still have to define an rx_j for each segment?
Yes. The transfer resistances are used to calculate the extracellular potential at the location of each segment center.
Post Reply