Page 1 of 1

extracellular stimulation of retina cells

Posted: Mon Jul 25, 2011 6:35 pm
by shn
Hello everybody,
I'm a Msc student,
I am trying to implement the extracellular stimulation and recording on a model for retina network. For attempt one, I consider having just one ganglion cell. I took the code from the example provided by Ted for extracellular stimulating ( ... I created the files parameters.hoc and createcells.hoc instead of, which was created by saving a CellBuilder to a ses file. The files parameters.hoc and createcells.hoc are for creating one ganglion cell. So my initxstim.hoc file is as following:

Code: Select all

load_file("anatscale.hoc")	// show xyz scale bars
load_file("interpxyz.hoc")	// only interpolates sections that have extracellular
load_file("setpointers.hoc")	// automatically calls grindaway() in interpxyz.hoc
load_file("field.hoc")		// computes extracellularly recorded potential vrec
load_file("")            // graph of vrec(t)
load_file("calcrxc.hoc")	// computes transfer r between segments and recording electrodes
load_file("stim.hoc")		// extracellular stimulus
In order to insert the mechanism extracellular into ganglion cell, I managed the file ganglion.tem, which is used in createcells.hoc, like this:

Code: Select all

begintemplate Ganglion
     public soma,spiketimes, spikecount
     create soma
     objref spikecount, spiketimes,vc
     proc init() { 
    create soma
    spiketimes = new Vector()
    soma {
       insert pas
       insert spike
       gkbar_spike = 0.012
       gabar_spike = 0.036
       gcabar_spike = 0.0022
       gkcbar_spike = 0.00005
       celsius = 22
       spikecount = new APCount(0.5)
       spikecount.thresh = -30
       vc = new VClamp(0.5)
	forsec "soma" {
        insert extracellular xraxial=1e9 xg=1e9 xc=0 e_extracellular=0
        insert xtra
	forall {
  }	// end init()
endtemplate Ganglion
It works when I run it to see the response of ganglion cell, although I’m not sure if it is correct. Now, for attempt two, I want to consider 4 cone-bipolar cells connected to one ganglion cell through synapses. I want to stimulate the cone-bipolar cells using extracellular mechanism and see the behavior of ganglion cell. So I inserted the mechanism extracellular into bipolar cells in the code for Bip.tem like the previous code that I had for the file ganglion.tem (this time, both of the files ganglion.tem and Bip.tem are used in createcells.hoc). But I didn’t get any response from the ganglion cell.
I read the posts about extracellular stimulating in forum but didn’t get any idea.
Can anyone in here help me, please?
Thanks for every suggestion.
Best Regards

Re: extracellular stimulation of retina cells

Posted: Tue Jul 26, 2011 11:26 am
by ted
You're off to a good start, but there are many potential pitfalls. Templates are difficult to write, so it's best to defer that until after you are sure that models of individual cells are "correct." Extracellular stimulation is best added last, after everything else is working.

For your particular project, I would suggest this development strategy:

1. Start by making a model of a "cone-bipolar cell." Don't bother with templates or extracellular fields at first. Make sure the model has the anatomical and biophysical properties that you want, and that it responds to injected current or synaptic input or "illumination" in the way that you want (how are you going to represent the effect of photic stimulation?). Finally, test its response to extracellular stimulation.

2. Repeat step 1 to create a model of a single ganglion cell and verify that it responds to extracellular stimulation properly (hint: a single compartment model will _not_ respond to extracellular stimulation).

3. Now you are ready to create templates for these two cell classes. The easiest way to do this is to use the CellBuilder or Network Builder to write a template for a simple model cell, e.g. a ball and stick model where the soma (ball) has hh and the stick (dendrite) has pas, then study that template to discover the correct pattern to use for your own cell classes. For one thing, a cell class template should really contain only the code that is necessary to specify the properties of an instance of that cell class. Current clamps, voltage clamps*, spike counters--none of these should be part of such a template. To keep track of spike times, it is best to use the NetCon class's record() method to capture them to a Vector (as in our paper
Hines, M.L. and Carnevale, N.T.
Translating network models to parallel hardware in NEURON.
J. Neurosci. Methods 169:425-455, 2008
available from
It might make sense to include synaptic mechanism point processes like ExpSyn or Exp2Syn, or it might not, depending on whether or not all instances of a cell class are to have exactly the same synapses at the same locations. And there are some "administrative details" about templates, such as the fact that a template really needs to contain a proc init().

*--You'll need to do something to represent the effects of photic stimulation. This could be done with IClamps or SEClamps (don't use VClamp unless you are interested in the effects of imperfect clamp electronics), I suppose, but these signal sources should be created and managed _outside_ of any cell class definition.

Re: extracellular stimulation of retina cells

Posted: Sun Jul 31, 2011 1:47 pm
by shn
Hello Ted,
Thanks for the explanations. Currently I am using Publio Rodrigo modeling entitled “A network model of the vertebrate retina”. This model consists of the Rod, Cone, Bipolar, AII Amacrine and Ganglion cells. The Rods receive photo current stimulation (using Iclamp) and the output layer is one ganglion cell. I took the code and changed it to have just one ganglion cell that receives photo current stimulation too see the response of ganglion cell. And again I did it for one cone-bipolar cell. So I think the model has the anatomical and biophysical properties that I want and the templates are correct, although I’m not sure I have inserted the photo current correctly. I can zip up my implementation and send it to you if you would have time to have a look on it. If these implementations for photic stimulation of ganglion cell and cone-bipolar cell were correct, it’s time to repeat it for extracellular stimulation that I wish, but I have problem with.
Thanks for all the help

Re: extracellular stimulation of retina cells

Posted: Sun Jul 31, 2011 3:14 pm
by ted
All cells in that model are implemented as single compartments. You can check for yourself by
(1) testing the source code:
grep nseg *hoc
grep nseg *ses
return nothing.
grep nseg *tem
A2.tem: nseg=1
Bip.tem: nseg=1
Rod.tem: nseg=1
so there are no statements that would assign a value > 1 to any section's nseg parameter.
(2) checking the model after it has been initialized.
nrngui mosinit
forall if (nseg>1) print secname()
prints no section names.

This means that none of the cell models used in that network model will respond to extracellular stimulation implemented with the method that I devised.


Because the method I devised relies on the fact that stimulating a cell with an extracellular field requires that the field produce a transmembrane current. There must be some part of the cell where current flows in through the membrane, and some other part of the cell where current flows out through the membrane. This can't happen with a single compartment model of a cell.


Because the electrical equivalent circuit of a single compartment model is a two terminal device.

Code: Select all

Equivalent circuit of a single compartment model cell

  o vi
|   |  <-- membrane capacitance and ion channels are in this box
  o vo
The potential at one terminal is vi, the intracellular potential. The potential at the other is vo, the extracellular potential. Changing the extracellular field is like attaching a voltage source to the vo terminal. You can do whatever you like to that terminal, but you're not going to make any current pass into or out of the cell.


Because there is no return path from the vi terminal to ground. You have an open circuit.

"Well, some of the cells are connected by gap junctions. That allows a return path, doesn't it?"

Yes but the resulting stimulus currents will depend entirely on where the cells are located and their total surface areas. It won't reflect the effect of cell shape or orientation. And none of the cells that are not gap coupled will "feel" the field at all.

"Well, what can I do?"

If you knew how cell shape and orientation affected the transmembrane current in the spike trigger zone of real cells exposed to an extracellular field, you could in principle use that information to implement current sources that you could attach to your single compartment model cells. Gaining that knowledge would require implementing model cells that preserve anatomical detail and would be a research project in and of itself. One possible approach to doing this would be to try to develop an "equivalent dipole" model of each cell class. That might allow each cell in a network model to be represented by a two compartment model. Well, just my imagination at work. It would take time, effort, and judgment. Wonder if someone else has already done it.

Re: extracellular stimulation of retina cells

Posted: Tue Aug 02, 2011 4:19 am
by shn
Thanks for the clarification of subject.
"Well, some of the cells are connected by gap junctions. That allows a return path, doesn't it?"

Yes but the resulting stimulus currents will depend entirely on where the cells are located and their total surface areas. It won't reflect the effect of cell shape or orientation. And none of the cells that are not gap coupled will "feel" the field at all.
So if the cells that are connected by gap junctions feel the extracellular field, I can consider some part of the retina network in this model of Publio Rodrigo, which consists of the cells that have synapses with each other and at last have synapses with one ganglion cell; and these cells can feel the extracellular field and I can use your code for extracellular stimulating. Right?

Re: extracellular stimulation of retina cells

Posted: Tue Aug 02, 2011 9:26 am
by ted
One can use anybody's code to try to do anything, and it might "work" in the sense of generating numerical results without crashing, but that doesn't make the result "valid" or "useful for producing insight."

Extracellular stimulation applied to a cell induces transmembrane current flow in every branch of the cell. If you take the approach that I devised for representing extracellular stimulation, and try to apply it to a network that consists of single compartment model cells, the stimulus will have absolutely no effect if there are no gap junctions. If there are gap junctions, the effect of the stimulus will be mediated by current flow through the gap junctions. Will the resulting simulations be useful for producing insight? This you have to decide for yourself. Will the results be publishable? This will be decided by someone else.

Re: extracellular stimulation of retina cells

Posted: Tue Aug 02, 2011 10:33 am
by shn
Thanks Ted. As it seems, I think I should find some way to represent the cells by a two compartment model. Can I change the model of Publio Rodrigo, in which the cells have been represented by a single compartment model, so that I can represent them by a two compartment model?

Re: extracellular stimulation of retina cells

Posted: Tue Aug 02, 2011 4:32 pm
by ted
Yes, but the questions are
(1) what changes should be made
(2) how to make them

"What changes should be made"--A two compartment model would, in principle, allow your model cells to emulate a dipole. For each cell class, the total surface area of the two compartments should be the same as the total surface area of a "real" cell of that class.

So much for the easy stuff. What is not clear:

1. the relative sizes of the two compartments--should they be the same size, or should one be smaller than the other?
2. the distribution of ion channels between the two compartments--should both have the same membrane properties, or should one be entirely passive (have just a leak conductance) and the other active, or shoud some other rule be used? (but what rule?)
3. the anatomical distance between the two compartments--ideally this should come from an experiment (wet-lab or computational) that determines an equivalent dipole description of how an anatomically detailed cell model responds to an extracellular field
4. how the compartments are connected--there has to be some electrical resistance that separates the two compartments, but how big should it be?

"How to make the changes" i.e. how to implement them with hoc. I'd suggest using the Network Builder to set up the cell class specifications, then export hoc code that can be mined for reusable stuff. This is a lot easier than trying to write a template or modify someone else's template. One big advantage is that each class specification will include _almost_ everything you need, right down to the statements that allow you to control the position of a cell in space. What it won't give you is the ability to control the orientation of the cell's dipole, but that can be done after the cell has been created.

Each cell would consist of a pair of sections--I'd call them sec[0] and sec[1]--where sec[1]'s 0 end is attached to the 1 end of sec[0]. You might prefer to call these soma and dend, especially if soma is active and dend is passive. Synaptic mechanisms would be attached to dend, and NetCons would be attached to soma.

Re: extracellular stimulation of retina cells

Posted: Fri Aug 05, 2011 11:29 am
by shn
Thanks for the explanations.
Considering your suggestion, I studied the tutorials for Cell Builder and Network Builder. They were clear and useful, but I don’t know exactly how to model a ganglion cell (as starting point) by Network Builder. I mean I don't know which sections should I use to define its topology (soma, axon, dendrite), and for its geometry and biophysics properties, should I use the values that were in the model of Publio Rodrigo? And if yes, his model consists of Na, Ca and K channels, while in the Cell Builder, as I saw, the column for hh mechanism in the Biophysics part, just has edit boxes for Na and K channels. And after that, as you said I should use two compartment model for the cells, so I should use nseg property, right? But I didn't see explanations about using nseg in the tutorials of Cell Builder and Network Builder. Would you guide me or send an example please?

Re: extracellular stimulation of retina cells

Posted: Fri Aug 05, 2011 1:11 pm
by ted
Excellent questions.

It may be useful to step back from the details and structure the problem as a sequence of conceptual steps.

The first step is to discover the appropriate dipole representation for each cell class (for the moment, let's skip over this step). Given that and the surface area of the cell, you should be able to determine the necessary spacing between the two compartments.

The starting point for the two compartment models should be a simple hoc file that specifies two sections connected end to end, each with nseg = 1. The geometry of these two compartments should be specified with NEURON's 3D syntax. For example, a file that defines a two compartment representation of a ganglion cell would be

Code: Select all

// base definition of ganglion cell


// parameters
DSOMA = . . . values unique to retinal ganglon cell class . . .

// topology and geometry

create soma, dend // "soma" actually represents soma + axon + some part of dendritic tree
  // "dend" represents the remainder of the dendritic tree
access soma
connect dend(0), soma(1)

soma {
  nseg = 1
  pt3dadd(0,0,0, DSOMA)
  pt3dadd(LSOMA,0,0, DSOMA)

dend {
  nseg = 1
  pt3dadd(0,0,0, DDEND)
  pt3dadd(LDEND,0,0, DDEND)
For each cell class, you'd assign values to parameters DSOMA, LSOMA, DDEND, and LDEND so that
and the distance between soma and dend (which is 0.5*(LSOMA + LDEND)) is appropriate for the dipole.
You might call these files

Put these hoc files in the same directory as the mod files that specify the mechanisms you want them to have. Compile the mod files in that directory. Then, when you double click on one of these hoc files (or execute
nrngui baseganglioncell.hoc
in that directory, if you're using Linux), NEURON will start up, load all of the compiled mechanisms, and then read your hoc file. At this point you can
NEURON Main Menu / Build / Network Cell / From Cell Builder
then click on
Use Selection (or create new)

Three windows will pop up--a NetReadyCellGUI tool, a SynTypeGUI tool, and a CellBuilder. The CellBuilder and SynTypeGUI tool actually belong to the NetReadyCellGUI tool. Click on the CellBuilder's Management button,
then click on Import,
and select
Top Level

The CellBuilder will now contain your model specification with proper topology and geometry.
You can now click on the Biophysics button and you will see that the compiled mechanisms are ready for you to insert into your model's compartments.

Sounds like a lot of steps, right? It's much easier done than said. I can show you how if you have a reasonably fast internet connection that allows desktop sharing. If you'd like to do this, let me know and we can set up a time and date.

Re: extracellular stimulation of retina cells

Posted: Sat Aug 06, 2011 4:41 pm
by shn
I did these steps, but finally I saw just topology of the cell that I created and no geometry or biophysics properties. I think I couldn’t write the code for baseganglioncell.hoc correctly. I would be grateful if you can show these by desktop sharing as you said. Please inform me about the time and date to have online connection with each other.

Re: extracellular stimulation of retina cells

Posted: Sun Aug 07, 2011 11:57 am
by ted

Code: Select all

I did these steps, but finally I saw just topology of the cell that I created and no geometry or biophysics properties. I think I couldn’t write the code for baseganglioncell.hoc correctly.
Why don't you email me
ted dot carnevale at yale edu
your baseganglioncell.hoc so I can see for myself?

Re: extracellular stimulation of retina cells

Posted: Sun Aug 07, 2011 6:14 pm
by ted
Here is something important to keep in mind--

The authors' source code in ModelDB does something a bit tricky: it mixes model setup code (statements that control the properties assigned to the biology that is represented in the model) with simulation control code (statements that control the execution of simulations. Specifically, their program provides a "Start" button that is used to launch a simulation. Clicking on this button causes execution of a procedure called start() (see init.hoc). Here is proc start()--

Code: Select all

proc start() {  local i,j

insert_iclamps(amp,10+amp) //defined at createcells.hoc
block_ih(gihbar) // defined at createcells.hoc
rod_gaps(PROB)  // defined at netconnection.hoc
A2_gaps(0.25)   // defined at netconnection.hoc
Glursyn()       // defined at netconnection.hoc

} // end proc start
These statements

Code: Select all

block_ih(gihbar) // defined at createcells.hoc
rod_gaps(PROB)  // defined at netconnection.hoc
A2_gaps(0.25)   // defined at netconnection.hoc
Glursyn()       // defined at netconnection.hoc
modify the biological properties that are represented in the model. The first statement changes the properties of rods--

Code: Select all

proc block_ih(){

for i = 0, nrodx-1 {
    for j = 0, nrody-1 {
It will be important to remember this when it comes time to create the models of rod cells. Were all of the simulations reported in that paper executed with identical values for rod ghbar_h, or did they use different values to investigate the effects of changing ghbar_h?

The other three statements change the architecture of the network itself, by changing the gap junctions between cells.

If code is very complex, it can be difficult to follow model setup and initialization, so that the actual values of parameters at run time may be hard to discover. For such cases, it may be useful to just go ahead and launch a simulation, but stop execution after a short time (use the RunControl panel's "Stop" button, or click on ^C (control-C) to halt the interpreter). Then bring up the Model View tool
NEURON Main Menu / Tools / Model View
and use it to explore the properties of the model cells or write a text file that contains a description of model properties (to print out Model View's complete outline of model properties, click on
ModelView / File / Write text

A general comment about good program design: it is usually best for programs to be organized in a modular way, so that model specification code, instrumentation code, GUI code, analysis code, and simulation control code are all separate from each other. This simplifies debugging, development, and maintenance. But this is not hard and fast rule that cannot be broken. Sometimes--especially when exploring parameter space--it is useful for the simulation control code to call procedures that change model architecture or parameters. It is always important to keep this in mind when working with someone else's code.

Re: extracellular stimulation of retina cells

Posted: Tue Aug 09, 2011 8:53 am
by shn
Thanks for the clarification. I understood your explanations but still I don’t know how to write my baseganglion.hoc code. Do you mean that I should use the Model View's outline of model properties for the ganglion cell to define the baseganglion.hoc code? I don’t know what should I do?

Re: extracellular stimulation of retina cells

Posted: Thu Aug 11, 2011 11:28 am
by ted
My comments in that post addressed issues that might be of general interest--for example, it is not uncommon to find simulation control code that contains one or more statements that alter model parameters, and people who want to reuse such code must understand the implications when they try to discover "what is really in the model." Information that is in any way "proprietary" or highly specific to your particular project I will reserve for email that will be sent directly to you.