General questions on initializing

The basics of how to develop, test, and use models.
Post Reply
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

General questions on initializing

Post by Bill Connelly »

Firstly, this counts as abandoning the standard run system, doesn't it, and hence is a bad idea, right? So what should I do instead? That is to say, is it really more efficient to record the voltage trajectories of 200 cells, and then step back through them (and what would be the best way to do this, if it is?).

while (t<tstop) {
for i = 0,ncells-1 {
if (cl.o(i).soma.v(0.5) > 0 && cl.o(i).old_v < 0) {
some stuff

Secondly, I wrote a new proc init() (which essentially contained the above statement), such that someone could click on the init and run button, and execute the simulation; however, it gave the impression of hanging NEURON. Is there anyway to get around that? Or again, is this bad behaviour?
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: General questions on initializing

Post by ted »

This isn't quite a question on initializing. It has more to do with the standard run system and networks, so I may eventually move it to a different thread.

There is rarely any need to abandon the standard run system. Much to lose, little to gain. Anyone with an application that demonstrates something gained is invited to demonstrate it.

Now for the particular application that led to your specific question:
The "best" approach depends on your intention. It looks like you're detecting positive-going threshold crossings. This is most efficiently done with NetCons, which perform the comparisons at compiled language speed and do not require modifications to the standard run system.

The real question is what action should occur when a threshold crossing is detected. If you're merely interleaving simulation and analysis, it's probably best not to. Just record the spike times to Vectors (use the NetCon class's record() method--see ... tml#record)--and postpone analysis until after the end let the simulation. This is because much analysis can be carried out by Vector operations, which use compiled code and are therefore much faster than a spike-by-spike analysis which requires reinterpretation of a series of hoc statements every time a new spike occurs. Post-run analysis can be automated by using a custom run() that calls the analysis procedure, e.g.

Code: Select all

proc run() {
where postprocess() is a user-defined proc that does whatever analysis you like.

If the spike-triggered action is one that would affect the subsequent course of the simulation, e.g. changing a parameter after a particular cell spikes, or stopping the simulation after a certain number of spikes has occurred, you should probably use the NetCon class's record("statement") syntax to accomplish it. Here's a toy example: sta.hoc, which sets up NetCons that monitor all cells in the network for positive-going 0 crossings of soma.v(0.5), and triggers a cell-specific action when such an event occurs:

Code: Select all

proc spike_triggered_action() {
  print "cell ", $1, "crossed threshold"

objref ncx, nil // nil will remain NULLobject
strdef cmdstr

proc mkncx() { local i  localobj nc
  ncx = new List()
  for i=0,cl.count-1 {
    cl.o(i).soma nc = new NetCon(&v(0.5),  nil) // target is NULLobject
    // build command string that includes index of cell in cells
    sprint(cmdstr, "spike_triggered_action(%d)", i)
    nc.threshold = 0

Post Reply