Changing cell locations also changes

Moderator: wwlytton

Post Reply
Qroid_montreal
Posts: 38
Joined: Sun Oct 16, 2011 1:58 pm

Changing cell locations also changes

Post by Qroid_montreal »

Hi - I'm trying to simulate ephaptically-coupled neurons, and I'm having problems when changing cell locations with pt3dchange. I think I have the hang of creating multiple instances using a template. However, when I change their location using pt3dchange it seems to change other parameters like area, diam, and L. I've tried a few methods (just changing the root/soma location, attaching the soma to a dummy section), but none have worked.

Here's some sample code for creating and moving the cells.

Code: Select all

offset=100
obfunc create_cells() { local i  localobj tlist, tcell
	tlist = new List()
	for i = 0,$1-1 {
		print i
		tcell = new CellL5_Cell() // CellL5_Cell template
		tcell for(x) pt3dchange(x,x3d(x),y3d(x)+offset*i,z3d(x), diam3d(x)) // move cell with pt3dchange
		tlist.append(tcell)
	}
	return tlist
}
cells=create_cells(ncell) // Create network
I want to create ncell neurons, each offset by 100 um in the y-direction. Otherwise I want the neurons to be identical. However, geometric variables like area are different between them:

Code: Select all

oc>cells.object(0).soma print area(0.5)
15946.678
oc>cells.object(1).soma print area(0.5)
2748.8936
And if I comment out pt3dchange, i.e. I don't change the cells' positions, the variables go back to identical, making me think that pt3dchange is what screws it up:

Code: Select all

oc>cells.object(0).soma print area(0.5)
2748.8936 
oc>cells.object(1).soma print area(0.5)
2748.8936
Other parameters like L etc. behave the same way. Everything in the shape plots looks perfect, though. Just so I understand, what's going on? Why does changing position do this? Is there a better way to create multiple instances of the same class, control their position, but have them otherwise identical? Thank in advance for any help.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Changing cell locations also changes

Post by ted »

A template exported from the CellBuilder will have a public method called position. Use that to specify cell locaton and your problem will vanish. If your templates weren't exported from CellBuilders, do yourself a favor and add the necessary code to them.

"How?"

Use the CellBuilder to make a very simple toy model cell, then export a cell class from that CellBuilder. Examine the exported hoc file to see how cell position can be changed, and steal what you need for your own templates. Specifically the following items:

Code: Select all

public x, y, z, position
This is one of the first few lines in the template. The line may include some other names, like synlist and connect2target, but those aren't related to controlling cell location and they may not be relevant to your own templates.

Code: Select all

  x = y = z = 0 // only change via position
which is inside the template's proc init()

Code: Select all

proc position() { local i
  soma for i = 0, n3d()-1 {
    pt3dchange(i, $1-x+x3d(i), $2-y+y3d(i), $3-z+z3d(i), diam3d(i))
  }
  x = $1  y = $2  z = $3
}
which will be somewhere near the bottom of the template. This particular example refers to soma, and that may be correct for your own needs as well--as long as soma is your model cell's root section. If your model cell's root section has some other name, replace soma with that name.

After you're done, make sure that it works properly. Your cell classes will now give you complete control over cell location, and your network setup code will be easy to read.
Qroid_montreal
Posts: 38
Joined: Sun Oct 16, 2011 1:58 pm

Re: Changing cell locations also changes

Post by Qroid_montreal »

Hi Ted - thanks very much. I replaced "tcell for(x) pt3dchange(x,x3d(x),y3d(x)+offset*i,z3d(x), diam3d(x))" with "tcell.position(0,offset*i,0)". area, diam, and L are now the same between cells, and shape plot shows the cells are in the right place. That's great.

I'm having a small issue with outputting absolute positions. Is it right that values from x3d(), y3d() and z3d() are relative to the root section? So to get the absolute x position of section i, say, I'd really need to output x_section_i + x_soma. Is that correct?
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Changing cell locations also changes

Post by ted »

Qroid_montreal wrote:Is it right that values from x3d(), y3d() and z3d() are relative to the root section?
Not necessarily. The advent of "logical connections" as a way to improve the cosmetics of some detailed morphometric reconstructions (see
http://www.neuron.yale.edu/neuron/stati ... #pt3dstyle) has complicated things a bit. To understand this, use the CellBuilder to make a toy model that consists of a 10x10 um soma to which a 1um diameter, 100um long dendrite is attached, export a template from it, then exit neuron. Now restart NEURON, xopen the template's hoc file, and execute
objref foo
foo = new TestCell() // I called the cell class "TestCell"
Then at the oc> prompt execute
forall {print secname() for i=0,n3d()-1 print x3d(i), y3d(i), z3d(i)}

The result I got was
TestCell[0].soma
0 0 0
10 0 0
TestCell[0].dend
15 0 0
115 0 0
I'm not surprised that soma and dend are horizontal; that's how I drew them. Also it's good to see that their lengths are 10 and 100 um, respectively. What does surprise me is that dend's 0 end does not have the same x coordinate as soma's 1 end, to which it is connected electrically.

Next I executed
foo.position(-1,-2,-3)
then executed
forall {print secname() for i=0,n3d()-1 print x3d(i), y3d(i), z3d(i)}
and the new result was
TestCell[0].soma
-1 -2 -3
9 -2 -3
TestCell[0].dend
15 0 0
115 0 0
so TestCell's position method affected only soma's coordinates, not dend's.

Finally, I executed
define_shape()
and now
forall {print secname() for i=0,n3d()-1 print x3d(i), y3d(i), z3d(i)}
generated
TestCell[0].soma
-1
9
TestCell[0].dend
9
109

What this means:
1. pt3d specification of one section's geometry will affect that section, but does not necessarily affect the 3d data associated with any other section.
2. define_shape() adjusts the 3d data associated with a child section so that (a) the first 3d point of the child section is at the same location as the parent, and (b) the other 3d points that belong to the child section are translated so that the child section's shape and orientation are preserved.

Now I changed the soma's position again

Code: Select all

oc>foo.position(0,0,0)
	0 
oc>forall {print secname()  for i=0,n3d()-1 print x3d(i), y3d(i), z3d(i)}
TestCell[0].soma
0 0 0 
10 0 0 
TestCell[0].dend
9 -2 -3 
109 -2 -3 
The soma moved, but not dend! No surprise really, and neither is this:

Code: Select all

oc>define_shape()
	1 
oc>forall {print secname()  for i=0,n3d()-1 print x3d(i), y3d(i), z3d(i)}
TestCell[0].soma
0 0 0 
10 0 0 
TestCell[0].dend
10 0 0 
110 0 0 
"Does this mean define_shape() should be executed after executing a model specification that uses pt3d, or after using pt3dchange to change the location of a section?"

Only if it is important that that all of the sections in your model are in their correct spatial locations relative to each other, e.g. if you are simulating extracellular stimulation or recording.

I should mention that the mere existence of a Shape or PlotShape obviates the need to call define_shape(). Continuing with the same example as above,

Code: Select all

oc>objref sh
oc>sh = new Shape() // creates a Shape plot
oc>foo.position(-1,-2,-3)
At this point, if there were no shape plot, I'd expect that dend's coordinates would still be
10 0 0
110 0 0
but the existence of a shape plot means that "moving" the soma will also update the pt3d data associated with all sections

Code: Select all

oc>forall {print secname()  for i=0,n3d()-1 print x3d(i), y3d(i), z3d(i)}
TestCell[0].soma
-1 -2 -3 
9 -2 -3 
TestCell[0].dend
9 -2 -3 
109 -2 -3
The bottom line: if it is important that all pt3d-specified sections have the "correct" pt3d data, either call
define_shape()
after executing any statement that affects the 3d specification, or just make sure that a Shape or PlotShape exists.
Qroid_montreal
Posts: 38
Joined: Sun Oct 16, 2011 1:58 pm

Re: Changing cell locations also changes

Post by Qroid_montreal »

Hi Ted - again, thanks so much. I included "tcell define_shape()" right after "tcell.position(0,offset*i,0)" and my pt3d values are now correct. This also explains why my Shape plots looked fine even when the output values weren't!
Post Reply