I have a model of a neuron, and I'm writing code to diffrent test on this model. To make my code more compact, I'm creating a library of functions that i load in the en the experiment hoc file.
Code: Select all
load_file("hocsrc/record-APs.hoc")
objectvar fiber
fiber = new fiberTemplate()
nSeg = fiber.axon[1].nseg
objref spTimes[nSeg]
objref apTimes[nSeg]
connectAPcounters(fiber, spTimes, apTimes)
Code: Select all
/*
## record-aciton-potentials.hoc
These funktion sets up the recording of action potentials and saves them to file.
**Parameters**
axon[x]
*/
proc connectAPcounters() { local i
// $o1 is an template
// $o2 is an array
// $o3 is an array
i = 0
$o1.axon[1] {
for (x,0) {
$o2[i] = new Vector()
$o3[i] = new APCount(x)
$o3[i].thresh = -10
$o3[i].record($o2[i])
i += 1
}
}
}
proc saveAPcounters(){ local ii, i
// $o1 is a wopen file
// $o2 is an arrayy
nElements = $o2.size()
nAPs = $o2[0].size()
veclast = nAPs - 1
vecloop = nAPs - 2
$o1.printf("\"aps\":[\n")
for (ii = 0; ii < nElements; ii += 1) {
$o1.printf("[")
for i=0, vecloop $o1.printf("%g, ", $o2[ii].x(i))
$o1.printf("%g]", $o2[ii].x(veclast))
if (ii < nElements - 1) $o1.printf(",")
$o1.printf("\n")
}
$o1.printf("],\n")
}
1
1
1
100
100
1
1
1
1
/home/peter/neuron/nrn/x86_64/bin/nrniv: syntax error
in record-APs.hoc near line 16
$o2 = new Vector()
^
xopen("record-APs.hoc")
execute1("{xopen("re...")
load_file("hocsrc/rec...")
0
1
1
1
/home/peter/neuron/nrn/x86_64/bin/nrniv: connectAPcounters undefined function
in record-APs.hoc near line 150
connectAPcounters(fiber, spTimes, apTimes)
^
connectAPcounters(fiberTemplate[0], Vector[8], NULLobject)
I have two questions.
1) how do I pass fiber.axon[1] to the proc()?
2) Why cant I add new Vectors to the array which I pass to the proc()?