Code: Select all
--- a/share/lib/python/neuron/rxd/geometry.py Wed Sep 10 08:40:55 2014 +0200
+++ b/share/lib/python/neuron/rxd/geometry.py Tue Sep 23 16:12:12 2014 +0100
@@ -20,10 +20,12 @@
def _volumes1d(sec):
- arc3d = [h.arc3d(i, sec=sec._sec)
- for i in xrange(int(h.n3d(sec=sec._sec)))]
- diam3d = [h.diam3d(i, sec=sec._sec)
- for i in xrange(int(h.n3d(sec=sec._sec)))]
+ if not isinstance(sec, nrn.Section):
+ sec = sec._sec
+ arc3d = [h.arc3d(i, sec=sec)
+ for i in xrange(int(h.n3d(sec=sec)))]
+ diam3d = [h.diam3d(i, sec=sec)
+ for i in xrange(int(h.n3d(sec=sec)))]
vols = numpy.zeros(sec.nseg)
dx = sec.L / sec.nseg
for iseg in xrange(sec.nseg):
@@ -89,10 +91,12 @@
_perimeter1d = _make_perimeter_function(numpy.pi)
def _neighbor_areas1d(sec):
- arc3d = [h.arc3d(i, sec=sec._sec)
- for i in xrange(int(h.n3d(sec=sec._sec)))]
- diam3d = [h.diam3d(i, sec=sec._sec)
- for i in xrange(int(h.n3d(sec=sec._sec)))]
+ if not isinstance(sec, nrn.Section):
+ sec = sec._sec
+ arc3d = [h.arc3d(i, sec=sec)
+ for i in xrange(int(h.n3d(sec=sec)))]
+ diam3d = [h.diam3d(i, sec=sec)
+ for i in xrange(int(h.n3d(sec=sec)))]
area_pos = numpy.linspace(0, sec.L, sec.nseg + 1)
diams = numpy.interp(area_pos, arc3d, diam3d)
return numpy.pi * 0.25 * diams ** 2
@@ -262,10 +266,12 @@
return 'Shell(lo=%r, hi=%r)' % (self._lo, self._hi)
def neighbor_areas1d(self, sec):
- arc3d = [h.arc3d(i, sec=sec._sec)
- for i in xrange(int(h.n3d(sec=sec._sec)))]
- diam3d = [h.diam3d(i, sec=sec._sec)
- for i in xrange(int(h.n3d(sec=sec._sec)))]
+ if not isinstance(sec, nrn.Section):
+ sec = sec._sec
+ arc3d = [h.arc3d(i, sec=sec)
+ for i in xrange(int(h.n3d(sec=sec)))]
+ diam3d = [h.diam3d(i, sec=sec)
+ for i in xrange(int(h.n3d(sec=sec)))]
area_pos = numpy.linspace(0, sec.L, sec.nseg + 1)
diams = numpy.interp(area_pos, arc3d, diam3d)
if self._type == _lo_hi_shell:
@@ -275,10 +281,12 @@
def is_area(self): return False
def volumes1d(self, sec):
- arc3d = [h.arc3d(i, sec=sec._sec)
- for i in xrange(int(h.n3d(sec=sec._sec)))]
- diam3d = [h.diam3d(i, sec=sec._sec)
- for i in xrange(int(h.n3d(sec=sec._sec)))]
+ if not isinstance(sec, nrn.Section):
+ sec = sec._sec
+ arc3d = [h.arc3d(i, sec=sec)
+ for i in xrange(int(h.n3d(sec=sec)))]
+ diam3d = [h.diam3d(i, sec=sec)
+ for i in xrange(int(h.n3d(sec=sec)))]
vols = numpy.zeros(sec.nseg)
dx = sec.L / sec.nseg
for iseg in xrange(sec.nseg):