how to use SaveState()?

Moderator: wwlytton

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

Post by ted »

Am I missing something obvious here?
Given the amount of text that has accumulated in this thread, it's not too
obvious, but something is missing. Your code reads the states from the file
into a SaveState object, and then . . . does nothing with them. The missing
item is a custom proc init() that calls the restore() method. It was buried
way back in an earlier message, so I have repeated it here:

Code: Select all

proc init() {
  finitialize(v_init)
  svstate.restore()
  t = 0 // t is one of the "states"
  if (cvode.active()) {
    cvode.re_init()
  } else {
    fcurrent()
  }
  frecord_init()
}
Just be sure to organize your program so that this custom proc init() is
parsed _after_ the standard run library is loaded, so that it redefines the
init() that is part of the standard run library and not the other way around.
fred

Post by fred »

OK, as long as I restore within init(), my states are restored. My question now is: Why can't I init(), then add a point process, then run() in hoc? It works when entered at the command line, but not when I write the same process entirely in hoc. My problem goes like this:

Code: Select all

load_file("make_cell.hoc")    //re-creates the segments correctly
load_file("restore_states.hoc")       //restores states successfully
init()    //init has been changed exactly as in your last post
objref stim
    stim = new VClamp(0.5)
    stim.dur[0] = 5
    stim.amp[0] = 12
run()
I get the "Segmentation violation" error.

Is there a way to do this, or do I need to create the VClamp, "stim," in the original simulation (the restored one)?
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

It is possible that you have discovered a bug. To diagnose the problem, it
will be necessary for me to reproduce it. If you zip up all necessary source
code and attach it to an email that you send to me at
ted dot carnevale at yale dot edu
I will tell you what I discover. I am away from Yale this week, with modem
access only (s...l...o...w...) so please try to keep the size of the zip file to
a minimum--no dll, .c, or .o files, please.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

The problem was that this caveat about SaveState was being violated:
Between a save and a restore, it is important not to create or delete sections,
NetCon objects, or point processes.

(see http://www.neuron.yale.edu/neuron/stati ... state.html ).
Specifically, a VClamp was being added.

The workaround is to make sure that the VClamp is present in the original model (this
avoids the caveat), but to set its gain to 1 and its rstim to 1e9 so it won't affect the cell.
Then the saved states can be restored to the same model, but with the VClamp's gain
1e5 and rstim 1 megohm.

A suggestion: use SEClamp instead of VClamp--see
https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=505
Post Reply