templating a multi-compartmental cell

Managing anatomically complex model cells with the CellBuilder. Importing morphometric data with NEURON's Import3D tool or Robert Cannon's CVAPP. Where to find detailed morphometric data.
Post Reply
ibuki
Posts: 9
Joined: Wed Mar 26, 2014 5:33 am

templating a multi-compartmental cell

Post by ibuki »

Hello,

I'm trying to template my multi-compartmental cell base on a previous .geo file ( https://senselab.med.yale.edu/ModelDB/S ... ctc200.geo). For this purpose, I tried to follow the tutorial here: http://www.anc.ed.ac.uk/school/neuron/t ... /tutC.html

Everything seems to work well if I just copy the sample programs and run them on my NEURON platform. But I got confused reading the following:
Each time we create a new section and connect it to others, NEURON places the section in a 3-D space and assigns an X, Y and Z coordinate to each end of the section. When creating more than one neuron, as we have above, each neuron is given a different Z coordinate for all of its sections.
How does NEURON assign different Z coordinates to multiple neurons?

In their sample program, the soma was created as follows:

Code: Select all

    create soma

    soma {
      nseg = 1
      diam = 18.8
      L = 18.8
      Ra = 123.0
      insert hh
      gnabar_hh=0.25
      gl_hh = .0001666
      el_hh = -60.0
    }
and the template is called by running the following lines:

Code: Select all

nSThcells = 4
objectvar SThcells[nSThcells]

for i = 0, nSThcells-1 {
    SThcells[i] = new SThcell()
}
I don't really get how the Z coordinates were assigned to make sure the neurons were placed differentially in 3D space (automatically done in the back stage of NEURON?). Are the Z coordinates correctly assigned because no coordinates were specified for the soma? What about if I need to specify the 3D coordinates for my soma, just like in the .geo file?

This is the thing I tried for my 200-compartment neuron (by manipulating the z coordinates):

Code: Select all

access soma_tc
	
	f=new File()
	
	for counter=0,3 {
		soma_tc[counter] {
			nseg = 1
			pt3dclear()
		
			f.ropen("soma.dat")	
			for j = 1, 13 {
			pt3dadd(f.scanvar(),f.scanvar(),f.scanvar()+counter*200,f.scanvar())

			printf("  fscanvar=%d  ", counter)	
			insert hh
			gnabar_hh= 0.2
			gl_hh = .0001666 
			el_hh = -60.0

			insert pas
			}
		}
}
The soma.dat file contains the following, which are the coordinates for the soma (13 is the number of segments for this soma):

Code: Select all

        13
        -23.25  -7.35   -34.2   0
        -21.9   -6.18   -31.05  14.959
        -21     -5.8875 -30.4875        21.439
        -20.1   -5.03862        -28.6974        24.974
        -16.95  -4.48638        -27.5526        25.363
        -16.05  -4.26426        -26.5824        26.719
        -13.8   -3.05889        -24.0111        28.865
        -9.75   -1.51125        -21.6675        28.311
        -4.8    1.0875  -17.5662        25.297
        -3.45   0.795   -15.435 23.776
        -0.75   1.875   -11.4192        15.383
        0.15    1.56    -10.53  10.826
        1.5     3       -9      0
and every time a new soma is created, the Z coordinates go greater by 200, which leads to a different spatial location. "counter" specifies the number of cells (thus, the number of somas) I want to have. This allows me to create 4 somas in 1 template and place them differentially in space, but that's not what I really want and the dendrites are hard to manage under this approach. I hope to have only 1 soma in one template (a template which includes all stuff in the .geo file for having one neuron) and call the .tem multiple times by using:

Code: Select all

nSThcells = 4 (n, the number of neurons you want for your network, in this case 4)
objectvar SThcells[nSThcells]

for i = 0, nSThcells-1 {
    SThcells[i] = new SThcell()
}
to create multiple cells from one template, but it seems impossible when you specify the coordinates for the soma, as I've tried this before:

Code: Select all

	access soma_tc
	//set parameters for soma_tc section
	
	f=new File()
	f.ropen("soma.dat")	
	soma_tc {
		nseg = 1
		pt3dclear()
			for j = 1, 13 {
			pt3dadd(f.scanvar(),f.scanvar(),f.scanvar(),f.scanvar())	
	}	
}
and it never worked, the somas were not correctly placed in space.

I noticed people tried similar things before but failed ( http://www.neuron.yale.edu/phpBB/viewto ... =13&t=1826 ). So it's not possible to load a .geo file in a template?

Sorry for making such a long thread. My major questions are:
1. How does NEURON assign different spatial location, e.g., by using different z coordinates, to templated neurons?
2. Does that work if we have to specify the soma's coordinates?
3. Any easier way to template a 200-compartment neuron?

Please let me know if any of the above is unclear, and in case you would like to check on my codes.
I deeply appreciate your time and patience.

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

Re: templating a multi-compartmental cell

Post by ted »

There are many paths to your goal, but most are far more difficult than necessary. You're on one of those. The most efficient path begins by getting the detailed anatomical structure of the cell into a CellBuilder, then using the CellBuilder to specify the model cell's discretization parameters and biophysical properties, and finally exporting a cell class definition (template) from that CellBuilder. In the process, most of the questions in your post will become irrelevant.

If you have not already worked through the first two CellBuilder tutorials, do so now--see
http://www.neuron.yale.edu/neuron/stati ... /main.html

Next use NEURON to execute the hoc file that defines the anatomical structure of the model cell in which you are interested--if you are running NEURON from the command line, cd to the directory that contains that file and execute the command
nrngui whatever_it_is_called
(in your case, that would be tc200.geo)
If not, drag and drop that file on top of the nrngui icon (if you're using OS X), or if you're using MSWindows, start nrngui, then use
NEURON Main Menu / File / working dir
to change to the directory that contains tc200.geo, and finally at the oc> prompt in NEURON's interperter window type the command
xopen("tc200.geo")

That will create a top-level implementation of the model cell (without ion channels, of course). Import this into a CellBuilder and proceed as in the second CellBuilder tutorial, but impose the biophysical specification that you want.

Hint: before you start, make a new empty directory, copy tc200.geo to it, and also copy into it the mod files for the mechanisms you want to use, then compile those mod files with mknrndll or nrnivmodl as appropriate for your operating system. This will make those mechanisms available on the Biophysics page of the CellBuilder when you start NEURON in that directory.

As you go along, make sure to save the CellBuilder to a session file at different points so you don't lose your work by accident.

When you think your model specification is complete, save the CellBuilder again, then test the model by attaching an IClamp to the soma and running some simulations. The first test is to make sure that your model is initialized to steady state. Run a simulation with the stimulus current set to 0 and watch what happens to membrane potential at the soma and along a path that extends from one end of the cell to the other (e.g. basilar dendrite to apical dendrite, maybe also basilar dendrite to the end of the axon if there is an axon). If membrane potential does not remain constant you need to find out why and what to do about it (ask if you don't know).

Finally, export the model to a template. On the CellBuilder's Management page click on Export, then click on "Export to file" and enter the name of the file that you want to hold your template.
ibuki
Posts: 9
Joined: Wed Mar 26, 2014 5:33 am

Re: templating a multi-compartmental cell

Post by ibuki »

Dear Ted,
I appreciate your informative and detailed reply. I tried to proceed with this approach and there were some questions along the way.

1. Some parameters were not accessible via the CellBuilder interface. Can I set them up directly by editing the .tem script generated from CellBuilder?
For example, values of ena and ek were re-assigned for the hh2 mechanism in the original program, by using:

Code: Select all

soma {
	g_pas = G_pas
	cm = 0.88

	insert hh2		// insert fast spikes
	ena = 50
	ek = -100
	vtraub_hh2 = -52
	gnabar_hh2 = 0.1
	gkbar_hh2 = 0.1
}
However, ena and ek were not accessible through the CellBuilder. In the following script (taken from hh2.mod), only gnabar, gkbar and vtraub were modifiable via CellBuilder.

Code: Select all

NEURON {
	SUFFIX hh2
	USEION na READ ena WRITE ina
	USEION k READ ek WRITE ik
	RANGE gnabar, gkbar, vtraub
	RANGE m_inf, h_inf, n_inf
	RANGE tau_m, tau_h, tau_n
	RANGE m_exp, h_exp, n_exp
}
Thus I will add them independently to the .tem exported from CellBuilder by changing

Code: Select all

  soma {
    insert pas
      g_pas = 3.79e-05
      e_pas = -76.5
    cm = 0.88
    insert hh2
      gnabar_hh2 = 0.1
      gkbar_hh2 = 0.1
      vtraub_hh2 = -52
  }
into

Code: Select all

  soma {
    insert pas
      g_pas = 3.79e-05
      e_pas = -76.5
    cm = 0.88
    insert hh2
      ena = 50
      ek = -100
      gnabar_hh2 = 0.1
      gkbar_hh2 = 0.1
      vtraub_hh2 = -52
  }
manually. Does it work like this?

2. I can record from multiple tc200.geo cells which implies they were successfully created. However, I still can't see more than one cell with 3D rotating.
I assume this is because coordinates for all the cells were the same thus they all overlap.
It will be a lot easier if I can create a graph in which cells are differentially located. Such as they had here:
Image
How can I do this?

Thanks for your help in advance.

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

Re: templating a multi-compartmental cell

Post by ted »

ibuki wrote:1. Some parameters were not accessible via the CellBuilder interface.
True. The only parameters that are visible on the CellBuilder's Biophysics page are those that are declared in the NEURON block of the mod files that define the inserted mechanisms.
Can I set them up directly by editing the .tem script generated from CellBuilder?
For example, values of ena and ek were re-assigned for the hh2 mechanism in the original program . . .
However, ena and ek were not accessible through the CellBuilder. . . .
only gnabar, gkbar and vtraub were modifiable via CellBuilder.
Yes, and the hh2 mechanism's NEURON block hints at why this is so.

Code: Select all

NEURON {
	SUFFIX hh2
	USEION na READ ena WRITE ina
	USEION k READ ek WRITE ik
	RANGE gnabar, gkbar, vtraub
The USEION statements mean that values of ena and ek don't "belong" to the code in hh2. Instead, every instance of the hh2 mechanism must READ these values from code that lies outside of the code that defines hh2. If you examine the rest of the mod file that defines hh2, you'll see that gnabar, gkbar, and vtraub really do "belong" to hh2--hh2 knows their values, and doesn't have to ask NEURON what they are.
Thus I will add them independently to the .tem exported from CellBuilder by
. . .

Code: Select all

  soma {
    insert pas
      g_pas = 3.79e-05
      e_pas = -76.5
    cm = 0.88
    insert hh2
      ena = 50
      ek = -100
Yes, that will work.
I still can't see more than one cell . . . I assume this is because coordinates for all the cells were the same thus they all overlap.
Multiple instances are automatically displaced along the z axis, but when a Shape plot comes up, your view is along the z axis, i.e. orthogonal to the xy plane, so all the cells are stacked on top of each other. If you really want to control where they are drawn on the screen, take advantage of the cell class's position() method. Example: suppose you have 12 cells mycell[0]..mycell[11] and you want to show them arranged on the xy plane in a rectangular array as 3 rows with 4 cells per row. This is what I'd try

Code: Select all

proc movecells() { local Dx, Dy
  Dx = $1
  Dy = $2
  for i=1,4 {
    for j=1,3 {
      mycell[i*j].position((i-1)*Dx, (j-1)*Dy, 0) // move origin of mycell[i*j] to (i-1)*Dx, (j-1)*Dy, 0
    }
  }
}
movecells(30,30)
and maybe try again with different arguments to movecells until it looks good.
ibuki
Posts: 9
Joined: Wed Mar 26, 2014 5:33 am

Re: templating a multi-compartmental cell

Post by ibuki »

Thank you so much Ted, these all worked well and now I have the template.
The templated cell has same firing patterns as the original one (without localizing T-current), so I suppose I'm safe when no T-current is localized.
However, there are two things I want to confirm since T-current setting is necessary:
1. How to check on the mechanisms inserted into each compartment?
When I was testing the templated cell, it sometimes gave the error message "itGHK mechanism not inserted in section soma_tc" even I've written

Code: Select all

forsec all {
    insert pas
      g_pas = 3.79e-5
      e_pas = -76.5
    cm = 0.88
    Ra = 173
    insert itGHK
...
}
and added

Code: Select all

access soma_tc
  soma_tc {
  	insert itGHK
...
}
in my .tem file. Is there a way I can check the mechanisms inserted in a compartment (the "Plot what?" function under voltage plot no longer works after using the template)? How to insert the itGHK in this case? Did the forsec all fail?

2. Managing the localized T-current.
I'm trying to add the localize() function by
1. adding the .oc file's (containing the settings for localizing T-current) proc localize() into my .tem file, following the proc biophys() part. Here's the program I use: http://senselab.med.yale.edu/ModelDB/Sh ... cloc200.oc
Then, add localize() to the proc init():

Code: Select all

proc init() {
  topol()
  subsets()
  geom()
  biophys()
  geom_nseg()
  localize()
  x = y = z = 0 // only change via position

}
and call localize(1.7e-5,corrD*8.5e-5,corrD*8.5e-5) by the end of .tem/in the main program. The error messages I got were like:
----------------------------------------------------------------------------------
localize not enough arguments
in new.tem near line 23
}
^
TCcell[0].localize()

TCcell[0].init()

or

localize not enough arguments
in templatedcell.hoc near line 24
}
^
TCcell[0].localize()
TCcell[0].init()
----------------------------------------------------------------------------------
Base on the loc200.oc I think 3 arguments were fine. Why this error?

Another way I've tried is to 2. directly load the loc200.oc file in my main program:

Code: Select all

//load_file("loc200_tc.oc")	
//	localize(1.7e-5,corrD*8.5e-5,corrD*8.5e-5) // this line is actually inserted into the for i=0, ncells-1 {	... part, so each cell created could be localized for T-current
and the error message was like:
----------------------------------------------------------------------------------
localize undefined function
in loc200_tc.oc near line 24
}
^
localize(1.7e-05, 8.5e-05, 8.5e-05)
----------------------------------------------------------------------------------
Though I've loaded the .oc file, in which the proc localize() is defined.
The line 25 of loc200_tc.oc was

Code: Select all

soma_tc.pcabar_itGHK = $1
Maybe the error has to do with the itGHK mechanism at soma_tc?

Thank you so much for your patience as always, Ted. I hope these descriptions won't cause any confusion.
Ibuki.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: templating a multi-compartmental cell

Post by ted »

ibuki wrote:1. How to check on the mechanisms inserted into each compartment?
Suggest you use NEURON's ModelView tool to analyze your model. See the presentation See the "Guides and Tutorials" on NEURON's Documentation page
http://www.neuron.yale.edu/neuron/docs

Code: Select all

When I was testing the templated cell, it sometimes gave the error message "itGHK mechanism not inserted in section soma_tc"
Then there's a bug in your code. You might want to review How to develop and debug your own code in the Forum's Hot tips area http://www.neuron.yale.edu/phpBB/viewforum.php?f=28.
2. Managing the localized T-current.
Very strange. I'll have to be able to reproduce it in order to discover what's causing it. If you zip up just the files that are needed to reproduce these symptoms and email them to
ted dot carnevale at yale dot edu
I'll let you know what I find out.
ibuki
Posts: 9
Joined: Wed Mar 26, 2014 5:33 am

Re: templating a multi-compartmental cell

Post by ibuki »

Dear Ted,

Thank you for the tips. I double-checked the mechanisms: my itGHK was correctly inserted.
I will send you a .zip file which contains:
1. The working version without localized T-current (just serve as a comparison)
2. The localizing T-current, but not-yet-working versions:
a. in which proc localize() was added in the .tem file
b. in which proc localize() was loaded by using the loc200.oc file

Please let me know if you have any questions concerning the codes. Thanks again for your tips, information and help.
Ibuki.
Post Reply