Extracellular stimulation and recording

A collection of noteworthy items selected by our moderators from discussions about making and using models with NEURON.

Moderators: ted, wwlytton, tom_morse

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

Extracellular stimulation and recording

Post by ted »

One approach to extracellular stimulation is to introduce, into the cable equation, a current term that is proportional to the second spatial derivative of the extracellular field. This is essentially the "activating function" method described by Rattay
Rattay F (1986): Analysis of models for external stimulation of axons.
IEEE Trans. Biomed. Eng. BME-33:(10) 974-977
It is the approach taken by McIntyre and Grill in their paper "Extracellular stimulation of central neurons: influence of stimulus waveform and frequency on neuronal output" JNP 88:1592-1604, 2002.

Another method is to assume that the extracellular medium is linear, in which case the coupling between stimulating electrode(s) and locations in space can be represented by transfer impedances. The extracellular potential at a point x,y,z produced by stimulus currents applied through any number of electrodes is then

Code: Select all

Vo(x,y,z) = SUMMA Z_j(x,y,z) I_j         Eq. 1
                       j
where I_j is the current delivered by the jth electrode, and Z_j(x,y,z) is the transfer impedance between the jth electrode and the point at (x,y,z) (i.e. the potential at x,y,z that results when 1 unit of current is applied to electrode j and the currents applied by all other electrodes is 0).

Of course, linearity also implies that the extracellular potential recorded by electrode j is composed of the weighted integral of the membrane current over the surface of the cell (weighted by local membrane area and transfer impedance between each point on the cell and the location of the recording electrode). For a spatially discretized model cell, this reduces to the weighted sum

Code: Select all

V_j = SUMMA Z_k I_k         Eq. 2
                k
where V_j is the potential observed by electrode j, the k are the indices of the model's compartments, and the I_k are the _net_ currents (not current densities) contributed by each compartment in the model.

If the reactive (capacitive) component of Z can be ignored, then Eq. 1 and 2 are easily implemented via simple multiplications.

The approach outlined by Equations 1 and 2 is illustrated in this file
http://www.neuron.yale.edu/ftp/ted/neur ... nd_rec.zip
which contains complete working implementations of extracellular stimulation and recording of a single neuron model, and could serve as a starting point for a model that involves multiple cells.


To implement either of these approaches in NEURON, one must:
--determine the locations of the nonzero area nodes in a model (i.e. the segment centers). This is easy enough, if somewhat tedious, for a stylized (L, diam) specification of model geometry. For geometries defined by the pt3d method, interpolating node locations from the pt3d data is straightforward (see the zip file).
--force some variable (an activation function current, or e_extracellular) in each segment to follow an appropriate time course. This can be done with an analytical function computed by code in a Point Process, an event handler, or with the Vector class's play() method. See the above links for examples.
aschneid42
Posts: 2
Joined: Fri Feb 09, 2018 5:11 pm

Re: Extracellular stimulation and recording

Post by aschneid42 »

Is there a example of how to implement this from Python, using NEURON as an extended module?

Oh I found it: https://github.com/LFPy/LFPy
ted
Site Admin
Posts: 6316
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extracellular stimulation and recording

Post by ted »

Clever, but you missed this implementation of extracellular recording:
Parasuram H, Nair B, D`Angelo E, Hines M, Naldi G, Diwakar S (2016)
Computational modeling of single neuron extracellular electric potentials and network Local Field Potentials using LFPsim
Front. Comput. Neurosci. 10:65
https://www.ncbi.nlm.nih.gov/pubmed/27445781

Its source code is available from ModelDB
https://senselab.med.yale.edu/modeldb/S ... del=190140
JustasB
Posts: 28
Joined: Tue Dec 08, 2015 8:17 pm
Location: Tempe, AZ, USA
Contact:

Re: Extracellular stimulation and recording

Post by JustasB »

For those looking for a Python-based, MPI/parallel NEURON compatible version LFPsim described in Parasuram et. al. (2016), take a look at LFPsimpy.
ted
Site Admin
Posts: 6316
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extracellular stimulation and recording

Post by ted »

LFPsimpy is a welcome addition to the tools that can be used to calculate extracellular potentials generated by the activity of model neurons!

Note to others who may read this thread:

LFPsim and LFPsimpy implement calculation of extracellular potentials generated by activity of model neurons. Neither of them implements extracellular stimulation of model neurons.
mae
Posts: 1
Joined: Thu Feb 02, 2023 8:28 am

Re: Extracellular stimulation and recording

Post by mae »

Hello Ted,
I'm new to computational neuroscience. This might be a naive question, but I was wondering what were the advantages of the method you suggested compared to Rattay and McIntyre implementation ? Also, do you know of any references using this method ?
ted
Site Admin
Posts: 6316
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extracellular stimulation and recording

Post by ted »

what were the advantages of the method you suggested
My posts mentioned several "methods." To which do you refer?
compared to Rattay and McIntyre implementation
Good question. To answer this, ask yourself the following questions:
What are the assumptions and limitations of Rattay's "activating function" approach?
What are the assumptions and limitations of the other approaches?
In what ways do the anatomical or biophysical properties of real cells violate these assumptions?
Can a particular method handle extracellular stimulation in which extracellular potential has a uniform linear gradient?
Can it handle extracellular stimulation or recording in a conductive medium that has complex boundary conditions or nonuniform conductivity?
You'll find the answers to these questions in articles by Rattay and in the documentation of the other approaches that were mentioned.
Also, do you know of any references using this method ?
Here are some ways to find out:
1. For any particular method that is described in the scientific literature, use PubMed to find the paper that describes the method. Then check that paper's PubMed entry for other papers that cite it.
2. Use Web of Science to do the same thing ("cited reference search").
3. For any particular method, use ModelDB's text search to find a model entry that contains relevant strings, such as Rattay, "activating function", xtra (the name of a mod file used in some models of extracellular stimulation or recording), LFPy, LFPsim etc..

Note added 20240109:

First, two big caveats about the activating function approach. (1) It assumes that the structure being stimulated is infinitely long. (2) It fails completely if the field's second spatial derivative is 0.

Second, many published models written for NEURON have implemented extracellular stimulation by driving e_extracellular as described here. Here is an incomplete list of examples whose source code is available from ModelDB (there are also many others that do not have ModelDB entries): Cavarretta et al. 2014 modeldb.science/151731, Fleming et al. 2020 modeldb.science/262046, Migliore et al. 2016 modeldb.science/190559, Reilly 2016 modeldb.science/239006, Xie et al. 2023 modeldb.science/267618.
ted
Site Admin
Posts: 6316
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extracellular stimulation and recording

Post by ted »

Here are examples of extracellular stimulation of a spherical cell implemented in hoc and Python https://www.neuron.yale.edu/ftp/ted/neu ... sphere.zip
firoozeh
Posts: 13
Joined: Mon Mar 09, 2020 8:40 am
Location: Iran

Re: Extracellular stimulation and recording

Post by firoozeh »

Is there any code in python for monopolar extracellular stimulation of a ball and stick model? (modeling soma as an Integrate and fire and axon as a passive cable)

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

Re: Extracellular stimulation and recording

Post by ted »

I'm sure that some modelers have implemented python code based on the hoc example, but I don't know of any sources that are available online. Maybe it's time for there to be an "official" example (well, one from a "trusted source" or at least a source that is willing to support it).
firoozeh
Posts: 13
Joined: Mon Mar 09, 2020 8:40 am
Location: Iran

Re: Extracellular stimulation and recording

Post by firoozeh »

Dear Ted,
I am trying to plot membrane voltage in soma for different frequencies of extracellular stim, I wrote the file, "plot__f.hoc" as below:

Code: Select all

// Set up recording vector
objref  voltageVector
voltageVector = new Vector() // Vector to record voltage at the middle of the soma
voltageVector.record(&soma.v(0.5)) // Record voltage at the middle of the soma


// List of stimulation frequencies
objref frequencies
frequencies = new Vector(10)

// creates a vector with 100 elements going from 5 to 950 in increments of 100.
frequencies.indgen(50, 950, 100)
for i = 0,frequencies.size()-1 {print(frequencies.x[i])} //show components

// Loop through the frequencies to record corresponding voltages
for i = 0, frequencies.size() - 1 {
    fz.f = frequencies.x[i] 
    run() 
    frequencyVector.append(frequencies.x[i]) // Append the current frequency to the vector
    voltageVector.append(soma.v(0.5)) // Record the corresponding membrane voltage
}

// Create a graph
objref graph
graph = new Graph() // Create a new graph
graph.size(0, 500, -80, 40) // Set the x and y-axis limits
graph.xaxis(0, 1, 100, 1) // Configure the x-axis (scaled for frequency)
graph.yaxis(-80, 20, 10, 1) // Configure the y-axis (scaled for voltage)

// Plot the data
graph.plot(frequencyVector, voltageVector) // Plot frequencies on x-axis and voltages on y-axis


but when I upload it, it doesnt work and no graph showed....


also when I print vector of frequency I get syntax error,

Code: Select all

for i = 0,voltageVector.size()-1 {print(voltageVector.x[i])} 

and when I print the vector for v of soma, it seems to record v in whole simulation time,although I wanted to record v of soma in tstop for different frequencies....

Code: Select all

for i = 0,frequencyVector.size()-1 {print(frequencyVector.x[i])} 

would you please help me solve this problem?
Post Reply