Analyzing vector during record?

The basics of how to develop, test, and use models.
Post Reply
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Analyzing vector during record?

Post by mctavish »

I am doing some batch processing, recording a vector during each run. During the run, I would like to periodically analyze the vector being recorded to determine if I can abort the particular run instead of having it run to completion before analyzing the vector. Is this possible? How?

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

Post by ted »

The first question is whether it is necessary to do that. What criterion would dictate whether
it makes sense to continue or to stop the simulation?
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Post by mctavish »

I am modifying parameters then running my simulation to see if the neuron fires at a particular number of times during the simulation. If it becomes apparent that the neuron will not be able to attain the number I'm looking for, I'd like to abort. Note, this is a biophysical model.
ted
Site Admin
Posts: 6394
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

In pseudocode

Code: Select all

TTEST is the time at which you want to check the number of spikes.
For the sake of this example, 
let's say you want the number of spikes that occur 
within the first TTEST ms to lie in the range {MINSP, MAXSP]
TFULLRUN (which is > TTEST) is how long you'd let the simulation run 
if it passes the test you apply at TTEST.
objref spiketimes, nc, null
spiketimes = new Vector()
// assuming that the cell's spike trigger zone is the (0.5) location 
// of the default section
nc = new NetCon(&v(0.5), null)
nc.record(spiketimes) // records spike times to Vector spiketimes.
tstop = TTEST
func myrun() {
  run()
  if ((spiketimes.size()>=MINSP) && (spiketimes.size()<=MAXSP)) {
    // I just lifted these from the ses file for a RunControl panel
    // but you should also read about them in the chapter 7 
    // of The NEURON Book.
    // Also see the Programmer's Reference documentation on stoprun.
    continuerun(TFULLRUN)
    stoprun = 1
    return 1 // means "full run"
  } else {
    return 0  // means "short run"
  }
}
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Post by mctavish »

Thanks, Ted! I'll give it a whirl.
ted
Site Admin
Posts: 6394
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

Let me know how it works out. It's a very simple strategy; much more complexity is
possible, if warranted, by exploiting NEURON's event delivery system--conditional
interruption and resumption of simulations, where the condition may depend on almost
arbitrarily complex specifications.
Post Reply