Forsec SecList { ... run() ... }

Managing anatomically complex model cells with the CellBuilder. Importing morphometric data with NEURON's Import3D tool or Robert Cannon's CVAPP. Where to find detailed morphometric data.
Post Reply
b1tna

Forsec SecList { ... run() ... }

Post by b1tna »

Hi,

I was trying to run simulations involving to successively locate a set of post-synaptic sites (clustered in space, i.e. within a single section) systematically across the entire dendritic tree in a detailed 3D reconstuction of a neuron, activate them near synchronously, and record the voltage trace at the soma.

For this I originally used code that looked like this in pseudocode:

Code: Select all

load_file("nrngui.hoc")

SecList = new SectionList()

populate SecList

forsec SecList { 
	set all parameters of the simulation, e.g. site location, site conductance level, etc.
	
	run()

	collect somatic voltage trace measures
}
However, I have come to realise that if I interrupted that set of simulations (ctrl+c), and launched a run from the NEURON interface using Init&Run, the newly simulated voltage trace recorded at the soma would not overlap with the latest one simulated from the scripts.

I have worked out a simple example of this:

Code: Select all

objref SecList, syn, nc, ns

celsius = 28
v_init  = -75

create soma, dend
access soma
connect soma(1), dend(0)

SecList = new SectionList()
dend SecList.append()

soma {
    L    = 5
    diam = 5
    cm   = 1
}

dend{
    L    = 50
    diam = 1.5
    nseg = 99
    cm   = 2
}

forall Ra    = 150
forall insert pas
forall g_pas = 1/6200
forall e_pas = v_init

dend ns     = new NetStim( 0.5 )
ns.interval = 1
ns.number   = 1
ns.start    = 100
ns.noise    = 0

dend syn    = new Exp2Syn( 0.5 )
syn.tau1    = 0.5
syn.tau2    = 5
syn.e       = 0

nc          = new NetCon( ns, syn )
nc.weight   = 0.0005

load_file("Session.ses")

Graph[0].family(1)
Graph[0].color(1)
Graph[0].brush(4)

run()

Graph[0].color(2)
Graph[0].brush(1)

forsec SecList { run() }
Which works with the following session file (to be called Session.ses):

Code: Select all

{load_file("nrngui.hoc")}
objectvar save_window_, rvp_
objectvar scene_vector_[3]
objectvar ocbox_, ocbox_list_, scene_, scene_list_
{ocbox_list_ = new List()  scene_list_ = new List()}
{pwman_place(0,0,0)}
{
xpanel("RunControl", 0)
v_init = -75
xvalue("Init","v_init", 1,"stdinit()", 1, 1 )
xbutton("Init & Run","run()")
xbutton("Stop","stoprun=1")
runStopAt = 5
xvalue("Continue til","runStopAt", 1,"{continuerun(runStopAt) stoprun=1}", 1, 1 )
runStopIn = 1
xvalue("Continue for","runStopIn", 1,"{continuerun(t + runStopIn) stoprun=1}", 1, 1 )
xbutton("Single Step","steprun()")
t = 300
xvalue("t","t", 2 )
tstop = 300
xvalue("Tstop","tstop", 1,"tstop_changed()", 0, 1 )
dt = 0.025
xvalue("dt","dt", 1,"setdt()", 0, 1 )
steps_per_ms = 40
xvalue("Points plotted/ms","steps_per_ms", 1,"setdt()", 0, 1 )
screen_update_invl = 0.05
xvalue("Scrn update invl","screen_update_invl", 1,"", 0, 1 )
realtime = 0.17
xvalue("Real Time","realtime", 0,"", 0, 1 )
xpanel(63,120)
}
{
save_window_ = new Graph(0)
save_window_.size(0,300,-80,40)
scene_vector_[2] = save_window_
{save_window_.view(0, -80, 300, 120, 363, 122, 300.6, 200.8)}
graphList[0].append(save_window_)
save_window_.save_name("graphList[0].")
save_window_.addexpr("v(.5)", 1, 1, 0.8, 0.9, 2)
}
objectvar scene_vector_[1]
{doNotify()}
Black trace results from a run() call outside of a section access loop.
Red trace results from a run() call inside of a section access loop.


So, now I know the workaround in my case: use section access (forall{}, forsec{}, ifsec{}, etc.) to set simulation parameters, then perform simulation always outside of such loops.

however I would like to understand the reason why the architecture my code was originally based on does not seem to be safe, but have been unable to pinpoint it in the documentation so far...

Thank you for your help.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Forsec SecList { ... run() ... }

Post by ted »

Every graph has a "plot list" that tells it what variables are to be plotted. Look at your Graph that plots membrane potential vs. time, and note that the variable name displayed on the Graph's canvas is v(.5)

But v(.5) is ambiguous--which section's v(.5) is actually plotted?

NEURON resolves this ambiguity by using the "currenly accessed section." Each iteration through the forsec { } loop makes a different section become the "currently accessed section." Verify this for yourself by changing
forsec SecList { run() }
to

Code: Select all

forsec SecList {
  print secname()
  run()
}
To avoid confusion and ensure that a particular section's range variable is plotted, use "dot notation" so that range variables in a graph's plot list are completely specified. Example: soma.v(0.5) (or even the shortcut soma.v).

Look in the .ses file and you'll find this statement
save_window_.addexpr("v(.5)", 1, 1, 0.8, 0.9, 2)

A "Voltage axis graph" will come up with v(.5) by default. You can use the Graph's primary menu to delete this and then use the primary menu again to select the "Plot what?" tool, which allows you to type the complete, unambiguous name of the variable, or construct it by clicking on section names and variable names (and then clicking in that tool's edit field to change the range value if necessary).

It is important to have a clear understanding of the concepts of "section access" and "currently accessed section." Be sure to read more here:
http://www.neuron.yale.edu/neuron/stati ... sedSection
b1tna

Re: Forsec SecList { ... run() ... }

Post by b1tna »

Thank you very much Ted for the detailed explanation.

I see what I was missing, and will be sure of unequivocally stating the variables to be plotted.
Post Reply