Code: Select all

```
: 3-D mapping of model geometry
NEURON {
SUFFIX d3
RANGE x, y, z
}
ASSIGNED {x(micron) y(micron) z(micron)}
```

Code: Select all

```
load_file("morphology.nrn")
forall {insert d3}
proc endpt() {
P=(n3d()-1)*$1
x_d3($1)=x3d(P)
y_d3($1)=y3d(P)
z_d3($1)=z3d(P)
}
proc fracpt() { local posn, A, i
A=$1
posn=$2
i=$3
x_d3(posn)=x3d(i-1) + (x3d(i) - x3d(i-1))*A
y_d3(posn)=y3d(i-1) + (y3d(i) - y3d(i-1))*A
z_d3(posn)=z3d(i-1) + (z3d(i) - z3d(i-1))*A
}
// make 3-d mapping of cell sections
proc map_segments_to_3d() {local i,x,D,alpha
forall {
i=0
endpt(0)
for (x) if (x > 0 && x < 1) {
while (arc3d(i) / L < x) {
i += 1
}
D=arc3d(i) - arc3d(i-1)
if (D <= 0) {
printf("\t\t * %s had a D < 0\n", secname())
}
alpha = (x * L - arc3d(i-1))/D
fracpt(alpha,x,i)
}
endpt(1)
}
}
map_segments_to_3d()
```

Code: Select all

```
dendA5_011111111111 {
for (x) {print "x=",x," x_d3(x)=",x_d3(x)," y_d3(x)=",y_d3(x)," z_d3(x)=",z_d3(x)}
//this part show that the algorithm is correct and working
i=0
endpt(0)
print "x_d3(0)=",x_d3(0)," y_d3(0)=",y_d3(0)," z_d3(0)=",z_d3(0)
for (x) if (x > 0 && x < 1) {
while (arc3d(i) / L < x) {
i += 1
}
print "x_d3(x)=",x_d3(x)," y_d3(x)=",y_d3(x)," z_d3(x)=",z_d3(x)
}
endpt(1)
print "x_d3(1)=",x_d3(1)," y_d3(1)=",y_d3(1)," z_d3(1)=",z_d3(1)
}
```

results of the test code:

Code: Select all

```
x=0 x_d3(x)=43.779999 y_d3(x)=219.50999 z_d3(x)=2.97
x=0.5 x_d3(x)=43.779999 y_d3(x)=219.50999 z_d3(x)=2.97
x=1 x_d3(x)=43.779999 y_d3(x)=219.50999 z_d3(x)=2.97
//notice: value of range variables does not change above
// but the algorithm seems correct
x_d3(0)=36.290001 y_d3(0)=206.33 z_d3(0)=1.3200001
x_d3(x)=36.290001 y_d3(x)=206.33 z_d3(x)=1.3200001
x_d3(1)=43.779999 y_d3(1)=219.50999 z_d3(1)=2.97
```