Questions about the extracellular mechanism and the syntax of NMODL

NMODL and the Channel Builder.
Post Reply
Christine Chung
Posts: 17
Joined: Fri May 03, 2019 2:41 am

Questions about the extracellular mechanism and the syntax of NMODL

Post by Christine Chung »

Hello, I'm trying to interpret hoc and NMODL files and have questions about some codes.
The sentences below are the codes that I want to ask.

This code came from https://senselab.med.yale.edu/modeldb/s ... 589#tabs-1 ModelDB: Modulation of hippocampal rhythms by electric fields and network topology (Berzhanskaya et al. 2013).

First, this is a part of code on the mod file.

Code: Select all

COMMENT
This mechanism is intended to be used in conjunction 
with the extracellular mechanism.  Pointers specified 
at the hoc level must be used to connect the 
extracellular mechanism's e_extracellular and i_membrane 
to this mechanism's ex and im, respectively.

xtra does three useful things:

1. Serves as a target for Vector.play() to facilitate 
extracellular stimulation.  Assumes that one has initialized 
a Vector to hold the time sequence of the stimulus current.
This Vector is to be played into the GLOBAL variable is 
(GLOBAL so only one Vector.play() needs to be executed), 
which is multiplied by the RANGE variable rx ("transfer 
resistance between the stimulus electrode and the local 
node").  This product, called ex in this mechanism, is the 
extracellular potential at the local node, i.e. is used to 
drive local e_extracellular.

2. Reports the contribution of local i_membrane to the 
total signal that would be picked up by an extracellular 
recording electrode.  This is computed as the product of rx, 
i_membrane (called im in this mechanism), and the surface area 
of the local segment, and is reported as er.  The total 
extracellularly recorded potential is the sum of all er_xtra 
over all segments in all sections, and is to be computed at 
the hoc level, e.g. with code like

func fieldrec() { local sum
  sum = 0
  forall {
    if (ismembrane("xtra")) {
      for (x) sum += er_xtra(x)
    }
  }
  return sum
}

Bipolar recording, i.e. recording the difference in potential 
between two extracellular electrodes, can be achieved with no 
change to either this NMODL code or fieldrec(); the values of 
rx will reflect the difference between the potentials at the 
recording electrodes caused by the local membrane current, so 
some rx will be negative and others positive.  The same rx 
can be used for bipolar stimulation.

Multiple monopolar or bipolar extracellular recording and 
stimulation can be accommodated by changing this mod file to 
include additional rx, er, and is, and changing fieldrec() 
to a proc.

3. Allows local storage of xyz coordinates interpolated from 
the pt3d data.  These coordinates are used by hoc code that 
computes the transfer resistance that couples the membrane 
to extracellular stimulating and recording electrodes.


Prior to NEURON 5.5, the SOLVE statement in the BREAKPOINT block 
used METHOD cvode_t so that the adaptive integrators wouldn't miss 
the stimulus.  Otherwise, the BREAKPOINT block would have been called 
_after_ the integration step, rather than from within cvodes/ida, 
causing this mechanism to fail to deliver a stimulus current 
when the adaptive integrator is used.

With NEURON 5.5 and later, this mechanism abandons the BREAKPOINT 
block and uses the two new blocks BEFORE BREAKPOINT and  
AFTER BREAKPOINT, like this--

BEFORE BREAKPOINT { : before each cy' = f(y,t) setup
  ex = is*rx*(1e6)
}
AFTER SOLVE { : after each solution step
  er = (10)*rx*im*area
}

This ensures that the stimulus potential is computed prior to the 
solution step, and that the recorded potential is computed after.
ENDCOMMENT

NEURON {
	SUFFIX xtra
	RANGE rx, er, coeff, recx
	RANGE x, y, z
	GLOBAL is
	POINTER im, ex
}

PARAMETER {
	: default transfer resistance between stim electrodes and axon
        coeff=1
	recx=1 :ext rex given eld pos
	rx = 1 (megohm) : mV/nA
	x = 0 (1) : spatial coords
	y = 0 (1)
	z = 0 (1)
}

ASSIGNED {
	v (millivolts)
	is (milliamp)
	ex (millivolts)
	im (milliamp/cm2)
	er (microvolts)
	area (micron2)
}

INITIAL {
	ex = is*rx*coeff*(1e6)
	er = (10)*recx*im*area
: this demonstrates that area is known
}

: With NEURON 5.5 and later, abandon the BREAKPOINT block
: and instead use BEFORE BREAKPOINT and AFTER BREAKPOINT

BREAKPOINT { : before each cy' = f(y,t) setup
	:ex = is*rx*(1e6)
	:er = (10)*rx*im*area
	:print "ex", ex
	:print "er", er
}

PROCEDURE f() {
	: 1 mA * 1 megohm is 1000 volts
	: but ex is in mV
	ex = is*rx*(1e6)
	er = (10)*recx*im*area
}

BEFORE BREAKPOINT { : before each cy' = f(y,t) setup
 	ex = is*rx*coeff*(1e6)
}
AFTER SOLVE { : after each solution step
 	er = (10)*recx*im*area
}
Moreover, this is a piece of code on a hoc file.

The array of mobj stores the external field for all the points created at the neuron morphology.

Code: Select all

mobj.x[i][j] = (efield)*((cos(thetad)*y)+(sin(thetad)*x))
user5[i].coeff_xtra((0+(2*j-1)/((2*nseg))))=mobj.x[i][j]*0.00002
With these fragment of code, could you please tell me the specific meaning of ex_xtra and er_xtra? Also with ex_xtra and er_xtra, which variable stores the extracellular potential?

I also have questions about the basic syntax of NMODL in declaration. With this example,

Code: Select all

NEURON {
	SUFFIX xtra
	RANGE rx, er, coeff, recx
	RANGE x, y, z
	GLOBAL is
	POINTER im, ex
}
I would be thankful if you could tell me the difference between RANGE, GLOBAL, and POINTER and their brief meanings.
Thank you for reading my post.
ted
Site Admin
Posts: 5919
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Questions about the extracellular mechanism and the syntax of NMODL

Post by ted »

could you please tell me the specific meaning of ex_xtra and er_xtra? Also with ex_xtra and er_xtra, which variable stores the extracellular potential?
Read items 1 and 2 in the COMMENT block at the very start of the file.
tell me the difference between RANGE, GLOBAL, and POINTER
A RANGE variable may have a different value in each compartment (segment). If foo is a RANGE variable that belongs to some mechanism bar, then for each segment that has the mechanism bar there will be a unique chunk of computer memory (enough for a single floating point number) set aside to hold the corresponding value of foo. If N segments have bar, there will be N instances of foo so N chunks of memory will be used to store the values of foo.
A GLOBAL variable has the same value everywhere. If foo is a GLOBAL variable that belongs to some mechanism bar, then no matter how many segments have the mechanism bar, all will share the same value of foo. If N segments have bar, there will be only one value of foo, so only one chunk of memory will be used.
In NMODL, a POINTER variable refers to a variable that is external to (i.e. exists "outside" of) the block of memory that holds a compiled mechanism. Delcaring that some variable is a POINTER allows the code in an NMODL-specified mechanism to access an external variable directly, avoiding the delay that would be imposed by executing assignment statements in hoc or Python. A statement in hoc or Python is used to set up the link between the NMODL variable and the external variable.
In this particular case, POINTERs are used to allows xtra to quickly set the value of e_extracellular and discover the value of local transmembrane current.
Christine Chung
Posts: 17
Joined: Fri May 03, 2019 2:41 am

Re: Questions about the extracellular mechanism and the syntax of NMODL

Post by Christine Chung »

Thank you for your reply, but I'm still confused even after reading the comments. I am trying to initially compute the potential of the neuron segments by COMSOL and then insert the data I produced into this code. Then in what variable (ex_xtra or er_xtra), should I insert the data of potential I've computed?

I have one last question and from this code below, could you explain the difference between the range variable of recx and rx?

Code: Select all

PARAMETER {
	: default transfer resistance between stim electrodes and axon
    	coeff=1
	recx=1 :ext rex given eld pos
	rx = 1 (megohm) : mV/nA
	x = 0 (1) : spatial coords
	y = 0 (1)
	z = 0 (1)
}

PROCEDURE f() {
	ex = is*rx*(1e6)
	er = (10)*recx*im*area
}
ted
Site Admin
Posts: 5919
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Questions about the extracellular mechanism and the syntax of NMODL

Post by ted »

I am trying to initially compute the potential of the neuron segments by COMSOL and then insert the data I produced into this code. Then in what variable (ex_xtra or er_xtra), should I insert the data of potential I've computed?
You don't. xtra is based on transfer resistance between the stimulating electrodes and the surface of the cell. It assumes that the extracellular medium is linear and not dispersive--in other words, the medium is purely resistive. If your COMSOL simulation of extracellular potential made the same assumption, you can use it to calculate the transfer resistances between the stimulating electrodes and the compartments of the model cell. Re-read comment 1 at the start of the file.
I have one last question and from this code below, could you explain the difference between the range variable of recx and rx?
Yes. rx is part of the original xtra.mod file that I wrote. Specifically, it is the transfer resistance between the stimulating/recording electrode and the extracellular surface of a compartment of a model cell. recx is not part of the xtra.mod file that I wrote; clearly it was added by somebody else. I have no idea what other changes somebody else might have made to the code you're using and can't say whether any part of it works properly or not.
ted
Site Admin
Posts: 5919
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Questions about the extracellular mechanism and the syntax of NMODL

Post by ted »

It assumes that the extracellular medium is linear and not dispersive--in other words, the medium is purely resistive.
Which implies that the extracellular potential at any point at any instant in time is proportional to the stimulus current at that time. The proportionality factor, which is called the transfer resistance, depends on the anatomical and electrical properties of the extracellular medium, and the shape, location, and orientation of the stimulating electrode(s).
Post Reply