/usr/share/nrn/lib/hoc/logax.hoc is in neuron 7.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | begintemplate LogAvsX
public measure, inject, ratio, input, transfer, move_callback, sl, extended, imp
public flush, begin, view_count
objectvar imp, sec, shape, b1, this, move_callback
objref seclist, g, rvp[1], sl
double orig[1]
strdef s0, s1, s2, stemp, sdist, sname, fstyle, tstr
proc init() {
extended = 0
direct_ = 0
style_ = 0
fstyle = "log(Attenuation)"
flush_ = 0
scale_ = 0
sel_act_ = 0
sec = new SectionRef()
x = .5
outside_sections()
nsec = 0
forsec sl { nsec += 1 }
objref rvp[nsec]
double orig[nsec]
freq = 0
variable_domain(&freq, 0, 1e9) units(&freq, "Hz")
imp = new Impedance()
build()
measure(.5)
}
proc outside_sections() {
sl = new SectionList()
sl.wholetree()
}
proc measure() {
sec = new SectionRef()
x = $1
setdir(direct_)
}
proc setdir() {
sec.sec {
direct_ = $1
if (style_ == 1) { // input
sprint(s0, "unused (red) %s(%g)", secname(), x)
}else if (direct_ == 0) {
sprint(s0, "Measure (red) %s(%g)", secname(), x)
}else {
sprint(s0, "Inject (red) %s(%g)", secname(), x)
}
}
draw()
}
proc compute() { // calcs impedances, argument is freq (Hz)
sec.sec imp.loc(x)
imp.compute($1, extended)
}
double sz[4]
proc draw() { local i
compute(freq) // freq is set by a field editor
g.flush()
if (scale_) {
g.size(&sz[0])
g.size(sz[0], sz[1], 0, sz[3])
}
}
proc build() {local i
b1 = new VBox()
b1.ref(this)
b1.save("")
b1.intercept(1)
xpanel("", 1)
xbutton("Redraw", "draw()")
xmenu("Shape Select Action")
xradiobutton("Move electrode", "sel_act_ = 0 gcolor()", 1)
xradiobutton("Show Position", "sel_act_ = 1")
xmenu()
xmenu("Plot")
xradiobutton("log(Attenuation)", "style(0)", 1)
xradiobutton("Zin (Mohm)", "style(1)")
xradiobutton("Ztransfer (Mohm)", "style(2)")
xradiobutton("V(measure)/V(inject)", "style(3)")
xmenu()
xmenu("Extras")
xstatebutton("Movie mode", &flush_, "add_flush()")
xstatebutton("Auto Scale", &scale_, "draw()")
xmenu()
xpanel()
xpanel("")
xcheckbox("include dstate/dt contribution", &extended, "draw()")
xpvalue("frequency", &freq, 1, "draw()")
xradiobutton("Vin", "setdir(0)", 1)
xradiobutton("Vout", "setdir(1)")
s0 = " Please Wait "
xvarlabel(s0)
xpanel()
shape = new Shape()
g = new Graph() // appends graph to box
g.menu_tool("Show position", "show_position")
color = 2
shapemark(1)
shapemark(0, sec, x)
shape.action("move()")
b1.intercept(0)
sprint(stemp, "%s", this)
b1.map(stemp)
compute(freq)
sec.root distance()
i=-1 forsec sl {i+=1 orig[i] = distance(0)}
i=-1 forsec sl {i+=1
rvp[i] = new RangeVarPlot("fun($1)")
rvp[i].begin(0)
rvp[i].end(1)
rvp[i].origin(orig[i])
}
add_rvp()
}
proc add_rvp() {local i
g.erase_all()
g.label(-100,-100, "")
for i=0, nsec-1 {
g.addobject(rvp[i])
}
g.label(.5, .9, fstyle)
}
func vmvi() {local xx, y, z
if (direct_ == 0) {
y = imp.ratio($1)
}else{
sec.sec xx = imp.input(x)
y = imp.transfer($1)/xx
}
if (y*1e20 <= 0) {
return 1e-30
}
return y
}
func fun() {
if (style_ == 0) {
return -log(vmvi($1))
}else if (style_ == 1) {
return imp.input($1)
}else if (style_ == 2) {
return imp.transfer($1)
}else{
return vmvi($1)
}
}
proc style() {
style_ = $1
if (style_ == 0) {
fstyle = "log(Attenuation)"
}else if (style_ == 1) {
fstyle = "Zin"
}else if (style_ == 2){
fstyle = "Ztransfer"
}else if (style_ == 3) {
fstyle = "V(measure)/V(inject)"
}
setdir(direct_)
add_rvp()
draw()
}
imin=0
proc gcolor() {local i
i=-1 forsec sl { i+=1
rvp[i].color(1)
}
}
proc move() {local i, xx, ss
xx = hoc_ac_
rvp[imin].color(1)
if (sel_act_ == 0) {
measure(xx)
shapemark(0, sec, x, color)
shape.color_all(1)
draw()
}else{
ss = this_section(.5)
i=-1 forsec sl {i+=1
if (ss == this_section(.5)) {
rvp[i].color(2)
}else{
rvp[i].color(1)
}
}
g.flush()
}
}
// should put this in plotshape class and avoid a meaningless point process
objectvar stim
proc shapemark() {local i
if (numarg() == 1) {
objectvar stim
for i=0,$1-1 sec.sec stim = new PointProcessMark(x)
for i=0,$1-1 shape.point_mark(stim, color)
}else{
$o2.sec stim.loc($3)
}
}
proc show_position() {local i, xx, min, x, xs, ys
if ($1 == 2) {
min = 1e9
imin= -1
xs = g.size(2) - g.size(1)
ys = g.size(4) - g.size(3)
i=-1 forsec sl {i+=1
x = rvp[i].left()
for (xx) {
f = ((x + xx*L - $2)/xs)^2 + ((fun(xx) - $3)/ys)^2
if (f < min) {
min = f
imin = i
}
}
}
shape.color_all(1)
i=-1 forsec sl {i+=1
if (i==imin) {
rvp[i].color(2)
shape.color(2)
}else{
rvp[i].color(1)
}
}
g.flush()
shape.flush()
}
}
proc add_flush() {
if (flush_) {
sprint(tstr, "flush_list.append(%s)", this)
execute(tstr)
}
}
func view_count() {
if (flush_) {
return g.view_count()
}else{
return 0
}
}
proc begin() {
}
proc flush() {
draw()
}
proc save() {}
endtemplate LogAvsX
proc makelogax() {
if(!execute1("v", 0)) {
continue_dialog("No accessed section: Can't start an LogAvsX")
return
}
hoc_obj_[0] = new LogAvsX()
}
|