### cvode.record problem

Posted:

**Mon Apr 29, 2013 2:59 pm**I have a problem with cvode.record that I just can't seem to figure out. I call a proc called arun1() that does a run() and records v and t with cvode.record and then computes some stats with the v and t vector data. If I call the proc once, results are exactly as expected, but if I call it a second time, the v vector gets the voltage data but the t vector has size 0 and I get the message arg x out of range. A plot of the data (Graph--> Voltage axis within the GUI) looks fine.

When I simplify the cell to just a soma with HH, cvode.record works as it should no matter how many times I call my proc. I do nrngui, load the hoc file below, type arun1(), change stim.amp, type arun1(), change... etc. Why the code below works, while code with the large cell fails with the second arun1() call is what I can't figure out. I have no problems with the large cell code except for this cvode.record problem.
Any suggestions will be appreciated.

When I simplify the cell to just a soma with HH, cvode.record works as it should no matter how many times I call my proc. I do nrngui, load the hoc file below, type arun1(), change stim.amp, type arun1(), change... etc. Why the code below works, while code with the large cell fails with the second arun1() call is what I can't figure out. I have no problems with the large cell code except for this cvode.record problem.

Code: Select all

```
create soma //soma with current input
access soma
soma { insert hh insert pas}
soma { diam=20 L=10}
objref stim
stim = new IClamp(0.5)
stim.del=1
stim.amp=0.3
stim.dur=1000
tstop=1200
v_init=-65
proc init() { local dtsav, temp // From the NEURON Book for init to SS
// init_cell()
finitialize (v_init)
t = -1e10
dtsav = dt
dt=1e9
// if cvode is on, turn it off to do large fixed step
temp = cvode.active()
if (temp != 0) {cvode.active(0) }
while (t<-1e9) {
fadvance()
}
// restore cvode if necessary
if (temp != 0) { cvode.active(1) }
dt = dtsav
t=0
if (cvode.active()) {
cvode.re_init()
} else {
fcurrent()
}
frecord_init()
}
proc arun1() {local i, n, y, th, ave, sd, SS, cv, rate localobj vec_v, vec_t, sT2
vec_v = new Vector()
vec_t = new Vector()
sT2 = new Vector()
cvode.record ( &v(0.5), vec_v, vec_t)
run()
th=-20
n=0
print vec_v.size , vec_t.size, sT2.size // print vector sizes before making the sT2 vector
// with the large cell get i.e., 17863 17863 0 here with first call
// get i.e., 16388 0 0 with second call
for i=1,vec_v.size-1 {
if(vec_v.x[i] >= th && vec_v.x[i-1] < th) sT2.append(vec_t.x[i]) // get spike times
}
print vec_v.size , vec_t.size, sT2.size // print vector sizes after the sT2 vector
for i=1,sT2.size-1 { // compute spike stats
y=sT2.x[i]-sT2.x[i-1]
n+=1
if(n==1) {
avg = y
SS=0
} else {
avgm1 = avg
avg = avgm1 + (y - avgm1)/n
SS = SS + (y - avgm1)*(y - avg)
}
}
sd = sqrt(SS/(n-1))
if (avg != 0.0) cv = sd/avg
rate = stim.amp
printf( "tstop %9g rate %8g n %6g avg %8g sd %8g cv %8g\n", tstop, rate, n, avg, sd, cv)
}
cvode.active(1)
cvode.atol(1e-3)
```