-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdistance.hoc
226 lines (186 loc) · 4.93 KB
/
distance.hoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
load_file("nrngui.hoc")
create soma[1], apical[1], basal[1]
objectvar st
objectvar sh
strdef str1
tstop = 1500
steps_per_ms = 40
ra = 200
rm = 60000
c_m = 0.75
v_init = -65
celsius = 30
t = 0.025
proc setpassive() {
forall {
insert pas
cm = c_m
e_pas = v_init
Ra=ra
g_pas=1/rm
}
}
objref Trunk
proc load_3dcell() {
xopen("n123.hoc")
forall {
soma area(0.5)
nseg = int((L/(0.1*lambda_f(100))+.9)/2)*2 + 1
totcomp=totcomp+nseg
}
setpassive()
access soma[0]
Trunk = new SectionList()
soma[0] Trunk.append() // 13.40um from soma
apical[0] Trunk.append() // 13.40um from soma
apical[4] Trunk.append() // 46.03
apical[6] Trunk.append() // 45.75
apical[14] Trunk.append() // 52.53
apical[15] Trunk.append() // 58.97
apical[16] Trunk.append() // 70.89
apical[22] Trunk.append() // 72.93
apical[23] Trunk.append() // 74.48
apical[25] Trunk.append() // 93.56
apical[26] Trunk.append() // 98.55
apical[27] Trunk.append() // 121.89
apical[41] Trunk.append() // 144.46
apical[42] Trunk.append() // 142.81
apical[46] Trunk.append() // 156.96
apical[48] Trunk.append() // 162.99
apical[56] Trunk.append() // 179.58
apical[58] Trunk.append() // 180.11
apical[60] Trunk.append() // 210.33
apical[62] Trunk.append() // 222.80
apical[64] Trunk.append() // 233.67
apical[65] Trunk.append() // 252.71
apical[69] Trunk.append() // 292.06
apical[71] Trunk.append() // 324.53
apical[81] Trunk.append() // 346.84
apical[83] Trunk.append() // 387.00
apical[95] Trunk.append() // 413.05
apical[103] Trunk.append() // 417.73
apical[104] Trunk.append() // 423.75
}
/*****************************************************************/
objref netlist, s, ampasyn, f1, DEND, sapamp, sampvec, sampvec
strdef str2
somax=2.497
somay=-13.006
somaz=11.12
double distances[200]
proc compute_distances() {
wopen("n123_all.dis")
load_3dcell()
access soma[0]
distance()
DEND = new SectionList()
forsec "basal" {
DEND.append()
}
forsec "apical"{
DEND.append()
}
forsec Trunk {
for(x) {
if(x!=0){
//rdist=raddist(x)
rdist=distance(x)
fprint("%s\t%f\t%f\n", secname(),x,rdist)
print secname(), "\t\t", x,"\t\t", rdist, "\t\t", distance(x)
}
}
}
wopen()
}
/*****************************************************************/
func raddist() {
distn0=distance(0)
distances[0]=0
sum=0
for i=1,n3d()-1 {
xx=(x3d(i)-x3d(i-1))*(x3d(i)-x3d(i-1))
yy=(y3d(i)-y3d(i-1))*(y3d(i)-y3d(i-1))
zz=(z3d(i)-z3d(i-1))*(z3d(i)-z3d(i-1))
sum=sum+sqrt(xx+yy+zz)
distances[i]=sum
}
xval=$1
// Amoung the various pt3d's find which one matches the distance of
// current x closely
distn=distance(xval)
match=distn-distn0
matchptdist=100000
for i=0,n3d()-1 {
matptdist=(match-distances[i])*(match-distances[i])
if(matchptdist>matptdist){
matchptdist=matptdist
matchi=i
}
}
//print "Match for ", x, " is ", matchi, " XDIST ", match, " MATCH ", distances[matchi], " ERROR ", sqrt(matchptdist)
// Find the distance of the closely matched point to the somatic
// centroid and use that as the distance for this BPAP measurement
xx=(x3d(matchi)-somax)*(x3d(matchi)-somax)
yy=(y3d(matchi)-somay)*(y3d(matchi)-somay)
zz=(z3d(matchi)-somaz)*(z3d(matchi)-somaz)
return sqrt(xx+yy+zz)
}
/*****************************************************************/
proc update_init(){
finitialize(v_init)
fcurrent()
}
/*****************************************************************/
// CA3b4: Centroid of Soma is: -2.68892 13.0872 1.07191
/*
proc saveradialamps(){local count, distn, nlcount, distn0, sum, match,\
matchptdist, matchptdist, raddist
wopen($s1)
count=0
nlcount=0
forall {
distn0=distance(0)
distances[0]=0
sum=0
for i=1,n3d()-1 {
xx=(x3d(i)-x3d(i-1))*(x3d(i)-x3d(i-1))
yy=(y3d(i)-y3d(i-1))*(y3d(i)-y3d(i-1))
zz=(z3d(i)-z3d(i-1))*(z3d(i)-z3d(i-1))
sum=sum+sqrt(xx+yy+zz)
distances[i]=sum
}
for (x) {
// Amoung the various pt3d's find which one matches the distance of
// current x closely
distn=distance(x)
match=distn-distn0
matchptdist=100000
for i=0,n3d()-1 {
matptdist=(match-distances[i])*(match-distances[i])
if(matchptdist>matptdist){
matchptdist=matptdist
matchi=i
}
}
//print "Match for ", x, " is ", matchi, " XDIST ", match, " MATCH ", distances[matchi], " ERROR ", sqrt(matchptdist)
// Find the distance of the closely matched point to the somatic
// centroid and use that as the distance for this BPAP measurement
xx=(x3d(matchi)-somax)*(x3d(matchi)-somax)
yy=(y3d(matchi)-somay)*(y3d(matchi)-somay)
zz=(z3d(matchi)-somaz)*(z3d(matchi)-somaz)
raddist=sqrt(xx+yy+zz)
if (ampvec[count].size()>0){
fprint("%s\t%f\t%f\n", secname(), raddist, \
ampvec[count].x[0]-v_init)
} else {
nlcount=nlcount+1
fprint("%s\t%f\t0\n", secname(), raddist)
}
count=count+1
}
}
print "Nilcount = ", nlcount
wopen()
}
*/
compute_distances()