/usr/share/nrn/lib/hoc/impedanc.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 | /*
A wrapper for the Impedance class that makes it convenient to
define measuring electrode location, and current injection location
This is useful for plotting impedance vs time and freq.
usage:
imp = new Imp1([impedanceobject]) // if no arg then this creates one
section imp.measure(x) //specify measurement location
section imp.inject(x) //specify injection location
imp.ratio(freq) // v(measure)/v(inject)
imp.input(freq) // v(measure)/i(measure)
imp.transfer(freq) // v(measure)/i(inject)
imp.map() // a widget for setting measure and inject
// locations
imp.move_callback = object // if you want object.move() called
// each time inject or measure is moved
imp.extended = 1 // if you want to perform the extended impedance
// calculation described in
// http://neuron.yale.edu/neuron/docs/help/neuron/neuron/classes/impedanc.html
Notes:
Impedance objects are expensive in terms of storage but efficiently
calculate input impedances everywhere and
transfer impedances everywhere relative to a specific location.
For this reason the Imp1 constructor can use a pre-existing Impedance
object if you don't want it to construct its own instance.
This object calls Impedance.compute(freq, extended)
everytime a ratio, etc is requested.
*/
begintemplate Imp1
public measure, inject, ratio, input, transfer, map, move_callback, extended
objectvar imp, sec[2], shape, b1, this, move_callback
double x[2], color[2]
strdef s0, s1, stemp, sdist
proc init() {
if (numarg() > 0) {
imp = $o1
}else{
imp = new Impedance()
}
measure(.5)
inject(.5)
}
proc measure() {
sec[0] = new SectionRef()
x[0] = $1
sectionname(stemp)
sprint(s0, "measure (red): %s(%g)", stemp, $1)
}
proc inject() {
sec[1] = new SectionRef()
x[1] = $1
sectionname(stemp)
sprint(s1, "inject (blue): %s(%g)", stemp, $1)
}
func ratio() {local y
compute($1)
sec[1].sec y = imp.ratio(x[1])
return y
}
func transfer() {local y
compute($1)
sec[1].sec y = imp.transfer(x[1]) // since v(x)/i(loc) == v(loc)/i(x)
return y
}
func input() {local y
compute($1)
sec[0].sec y = imp.input(x[0])
return y
}
proc compute() {
sec[0].sec imp.loc(x[0])
imp.compute($1, extended)
}
objectvar rvp
proc dist() {local y
sec[0].sec distance(0,x[0])
sec[1].sec y = distance(x[1])
sprint(sdist, "distance(um) %g", y)
}
proc map() {local i
mark = 0
dist()
b1 = new VBox()
b1.ref(this)
b1.save("save()")
b1.intercept(1)
xpanel("")
xmenu("measure/inject")
xradiobutton("measure", "mark=0", 1)
xradiobutton("inject", "mark=1")
xbutton("Exchange", "exchange()")
xmenu()
xvarlabel(s0)
xvarlabel(s1)
xvarlabel(sdist)
xpanel()
shape = new Shape()
for i=0,1 color[i]=i+2
shapemark(2)
for i=0,1 {
color[i] = i+2 // red, blue
shapemark(i, sec[i], x[i], color[i])
}
shape.action("move()")
b1.intercept(0)
sprint(stemp, "%s", this)
b1.map(stemp)
}
proc move() {local i, xx
i = mark
xx = hoc_ac_
if (i == 0) {
measure(xx)
}else{
inject(xx)
}
shapemark(i, sec[i], x[i], color[i])
dist()
if (object_id(move_callback)) {
move_callback.move()
}
}
objectvar etmp
proc exchange() {local xx, i //swap inject and measure
etmp = sec[0]
xx = x[0]
sec[1].sec measure(x[1])
etmp.sec inject(xx)
objectvar etmp
for i=0,1 shapemark(i, sec[i], x[i], color[i])
if (object_id(move_callback)) {
move_callback.move()
}
}
// should put this in plotshape class and avoid a meaningless point process
objectvar stim[1]
proc shapemark() {local i
if (numarg() == 1) {
objectvar stim[$1]
for i=0,1 sec[i].sec stim[i] = new PointProcessMark(x[i])
for i=0,1 shape.point_mark(stim[i], color[i])
}else{
$o2.sec stim[$1].loc($3)
}
}
proc save() {}
endtemplate Imp1
proc makeImp1() {
if(!execute1("v", 0)) {
continue_dialog("No accessed section: Can't start an Imp1")
return
}
hoc_obj_[0] = new Imp1()
hoc_obj_[0].map()
}
|