cvode.record problem

Anything that doesn't fit elsewhere.
Post Reply
Bill Holmes
Posts: 3
Joined: Thu Nov 03, 2005 6:18 pm
Location: Ohio University

cvode.record problem

Post by Bill Holmes » 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.

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)

Any suggestions will be appreciated.

ted
Site Admin
Posts: 5590
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: cvode.record problem

Post by ted » Mon Apr 29, 2013 7:49 pm

I can't reproduce the symptom. Maybe the problem is a bug in the version of NEURON that you're using (what's the first line that the interpreter prints to its xterm on startup?), or maybe it's in the "complex model cell." If the latter, I'll have to try it myself.

A side question: is there a reason why you're not using the NetCon class's record() method to capture spike times to a Vector?

Bill Holmes
Posts: 3
Joined: Thu Nov 03, 2005 6:18 pm
Location: Ohio University

Re: cvode.record problem

Post by Bill Holmes » Tue Apr 30, 2013 10:00 am

I did not know about the record option on NetCon. Works like a charm. Thanks.

I will see if I can narrow down the cvode.record problem a bit more with the non-toy model. The problem occurs on a Win 7 PC with Neuron 7.2. Also on 7.3, 64 bit, but I don't trust my installation--I believe I have a 64 bit i7 processor but mknrndll, although "successful", also says "wrong machine type". That plus the Neuron command window is now black background, whereas in 7.2 it was white. I will reinstall 7.3 and maybe try the 32 bit version. I also see the cvode.record problem on the intel Mac with earlier versions of Neruon (6.x)

ted
Site Admin
Posts: 5590
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: cvode.record problem

Post by ted » Tue Apr 30, 2013 11:13 am

The 64 bit NEURON 7.3 installer for MSWin uses mingw, which offers a terminal that has a black background; the 32 bit installer uses cygwin, same as previous installers have. I believe that mingw's terminal doesn't allow "select by highlighting, then copy," unlike cygwin's terminal. Also, the 64 bit version is quite new and may have some undiscovered bugs unique to itself. Its primary reason for existing is to serve those users who need arrays larger than 2 GB.
Bill Holmes wrote:The problem occurs on a Win 7 PC with Neuron 7.2. . . . also see the cvode.record problem on the intel Mac with earlier versions of Neruon (6.x)
So it's not related to mingw or 64 bits. Maybe a problem with cvode.record itself. Local variable time step hasn't proven to be as beneficial as we first imagined, so maybe it hasn't seen as much usage as the other integration methods, and consequently might have some yet unrecognized bugs.
Also on 7.3, 64 bit, but I don't trust my installation--I believe I have a 64 bit i7 processor but mknrndll, although "successful", also says "wrong machine type".
Strange.

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: cvode.record problem

Post by hines » Tue Apr 30, 2013 11:42 am

I believe I have a 64 bit i7 processor but mknrndll, although "successful", also says "wrong machine type"
Sorry. That can be ignored. Cygwin requires use of the rebase program to avoid conflicts with other 32 bit dll's. Its failure on a 64 bit machine does no harm
but to avoid concern I should skip it when building a 64 bit dll.

Bill Holmes
Posts: 3
Joined: Thu Nov 03, 2005 6:18 pm
Location: Ohio University

Re: cvode.record problem

Post by Bill Holmes » Tue Apr 30, 2013 2:43 pm

Thanks. This makes me more confident in my 7.3 install.

I have found that if I delete and recreate the cell between using cvode.record in runs, that cvode.record works as expected. That is, I have a do_cell() which starts with forall delete_section() and then reads in morphology, does channel inserts and sets up synapse lists and netcons involving an artificial stimulator. So if I do arun1() do_cell() arun1() then the time vector from cvode.record in the second arun1() has the proper size. Since do_cell() executes instantly, this is a work-around I can live with. However I think I will take Ted's suggestion and use the record option of netcon. Much nicer!

Thanks very much for your near-instant responses. Got me by this hurdle.

ted
Site Admin
Posts: 5590
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: cvode.record problem

Post by ted » Wed May 01, 2013 11:29 am

Sounds like cvode.record has a bug. In cases where it is necessary to record the time course of one or more variables, including time, I'd suggest sticking with the Vector class's record() method which has seen a lot of use and is quite robust. cvode.record is only necessary when the local variable time step method is used, and apparently that method hasn't been applied much.

Post Reply