Purpose of interpxyz.hoc in extracellular_stim_and_rec code

Anything that doesn't fit elsewhere.
Post Reply
pascal
Posts: 106
Joined: Thu Apr 26, 2012 11:51 am

Purpose of interpxyz.hoc in extracellular_stim_and_rec code

Post by pascal »

Hi Ted,

I want to make sure I understand why interpxyz.hoc is necessary in your extracellular_stim_and_rec code (found here: http://www.neuron.yale.edu/phpBB/viewto ... f=28&t=168). In particular, it seems to my naive eyes that define_shape() already calculates the interpolated 3D coordinates at each node of each segment, rendering interpxyz.hoc superfluous. In your April 4 post in this thread:

viewtopic.php?f=8&t=3627&p=15469&hilit= ... ape#p15469

you state that "The number of 3d points that you use to define the geometry of any section has nothing to do with that section's spatial discretization parameter nseg." And yet I have written a toy model that defines 3D points using the stylized geometry in conjunction with define_shape(), and after calling define_shape() the interpolated centers of the nodes have already been defined. Here is my code:

Code: Select all

from neuron import h, gui

soma=h.Section(name='soma') 
dend=h.Section(name='dend')

soma.diam = soma.L = 20 #microns
soma.nseg = 3
dend.diam = 2 #microns
dend.L=200 #microns

#insert extracellulra and xtra mechanisms
soma.insert('extracellular')
soma.insert('xtra')
dend.insert('extracellular')
dend.insert('xtra')

#define connectivity between sections
dend.connect(soma,0,0) #connect 0 end of Bdend to 0 end of soma 

h.define_shape()

for sec in h.allsec():
    print "section=",sec.name() #or use print h.secname()
    for i in xrange(int(h.n3d())): print i, h.x3d(i), h.y3d(i), h.z3d(i), h.diam3d(i)
The output of the print statement at the end is:

section= soma
0 0.0 0.0 0.0 20.0
1 3.33333325386 0.0 0.0 20.0
2 10.0 0.0 0.0 20.0
3 16.6666660309 0.0 0.0 20.0
4 20.0 0.0 0.0 20.0
section= dend
0 0.0 0.0 0.0 2.0
1 -100.0 8.74227771419e-06 0.0 2.0
2 -200.0 1.74845554284e-05 0.0 2.0

So define_shape() has already calculated the interpolated centers of each segment of the 'soma' section (in addition to the coordinates at both ends). What is the point of doing this entire calculation all over again in interpxyz.hoc? I do see that the end of interpxyz.hoc defines the x, y, and z range variables of the 'xtra' mechanism, but why not simply copy the information we already have from calling define_shape(), rather than re-doing the entire calculation?

I just want to make sure I am not missing something regarding the purpose of interpxyz.hoc. Thanks.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Purpose of interpxyz.hoc in extracellular_stim_and_rec c

Post by ted »

So define_shape() has already calculated the interpolated centers of each segment of the 'soma' section (in addition to the coordinates at both ends). What is the point of doing this entire calculation all over again in interpxyz.hoc?
Sure, do whatever works for you. But what if you're involved in interactive model development, running one simulation after another without exiting NEURON, and you suddenly realize that soma.nseg == 3 is unnecessary, and 1 is sufficient? Or you want to compare simulations that use different values of nseg, in order to verify that spatial discretization is sufficiently fine? Or you discover that using the stylized method means you don't really have control over the shape or orientation of your branched model cell (you don't), because you're allowing some algorithm, internal to NEURON, to choose the branch point angles that it likes. Or you decide it's time to start working with detailed morphological reconstructions (like most modelers who are interested in extracellular stimulation or recording). Or you just want to write and use code that works properly regardless of whether the model specification is stylized or 3d (who would ever want that?).
pascal
Posts: 106
Joined: Thu Apr 26, 2012 11:51 am

Re: Purpose of interpxyz.hoc in extracellular_stim_and_rec c

Post by pascal »

Got it, interpxyz.hoc applies very generally to stylized and 3d models. Thanks.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Purpose of interpxyz.hoc in extracellular_stim_and_rec c

Post by ted »

If the only thing you model is a single, cylindrical, unbranched axon, and you're never going to change nseg, the simplest and easiest thing to do is start with a stylized model specification and calculate the xyz coords assuming that the 0 end is at (0,0,0), the axon lies along the x axis, and node centers are at
(L*(0.5+i)/nseg), 0, 0
for i = 0..nseg-1. That may be easiest even if there are a few sections, as long as they're all in a straight line and unbranched and you never have to change nseg. Anything more complex than that, let code do the work.
Post Reply