Page 1 of 1

Posted: Sat Mar 03, 2007 2:43 pm
by ted
One way is to redefine the run() procedure (see chapter 7 of The NEURON Book).
Insert this statement at the end of your program:

Code: Select all

load_file("customrun.hoc")
Then make a hoc file called customrun.hoc and put this in it:

Code: Select all

how_much_longer = 5 // or however many milliseconds the simulation should run

func keepgoing() {
  // here you put your code that decides if the simulation should continue
  if (your code decides that the simulation should continue) // this line is pseudocode
    return 1
  } else {
    return 0
  }
}

proc run() {
  stdinit()
  while (keepgoing()) {
    continuerun(t + how_much_longer)
  }
}

Posted: Sat Mar 03, 2007 6:09 pm
by ted
Thank me when you know for sure that it works.

Posted: Mon Mar 05, 2007 7:45 am
by ted
A few things to keep in mind:
1. fadvance is a procedure, so it should be called fadvance().
2. If "dosomething" changes model parameters or state variables, the
simulation will not work with adaptive integration unless cvode is reinitialized.
3. If the purpose of "dosomething" is simply to decide whether to continue
the simulation or to stop, and the decision hangs on whether some variable
reaches a critical level, it would be more efficient to use a NetCon to
monitor that variable for threshold crossing, and use that NetCon's record()
method to execute the statement
stoprun = 1