NetCon detection threshold

General issues of interest both for network and
individual cell parallelization.

Moderator: hines

Post Reply
bkaplan
Posts: 10
Joined: Thu Apr 22, 2010 4:34 am

NetCon detection threshold

Post by bkaplan »

Hello,
I'm working on a model of dendro-dendritic interaction with the following code.
From the cell template which acts as a source:

Code: Select all

// this happens in the dendritic compartment:
// append a NetCon object to a public List, with an empty object 'nil' as target, and thresh_dd as threshold for signal detection, zero delay and an arbitrary weight
thresh_dd = -30
src_netcons_glom.append(new NetCon(&v(0.5), nil, thresh_dd, 0, 0.5))
Create and register source cell:

Code: Select all

if (pnm.gid_exists(gid)){ // if this gid has been assigned to the current machine
    cell = new Mit(rnd_int.repick()) // create the cell
    pnm.register_cell(gid, cell) // register the cell with the gid
    pnm.set_gid2node(gid + n_cells, pc.id()) // gid+n_cells is the gid of the NetCon above
    pc.cell(gid + n_cells, cell.src_netcons_glom.o(0)) // mark the NetCon from above as output source
}
Connecting the source compartment to some other cell's target compartment:

Code: Select all

td_gid = src_gid + n_cells// the gid of the threshold detecting NetCon object in the source cell's compartment, src_gid is the gid of the source cell
tgt_gid = pg_offset + j // target cell's gid
synapse_id = 0 // synapse id at the source cell in the target compartment
delay = 10 // doesn't matter if 0 ms or anything else
pnm.nc_append(td_gid, tgt_gid, synapse_id, w_mit_pg, delay)
So far so good, but now I have experienced the following weird behavior in a setup where the membrane potential in the source cell fires two spikes. Depending on the NetCons threshold "thresh_dd" the following things happen:
If thresh_dd >= -30, no "spike" or threshold crossing signal is transmitted to the target cell.
If thresh_dd = -40, both of the two "spikes" are detected and a response signal can be seen on the target cell.
If thresh_dd = -35, only the second time the membrane potential in the source compartment crosses the -35 mV is registered and sent to the target cell.
The cells I'm using are both real multi-compartment cells with some HH-type ion channels taken from existing models from ModelDB.
In a serial version this behavior does not appear.
Any ideas what's wrong?
Many thanks in advance!
Best regards,
Bernhard
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NetCon detection threshold

Post by ted »

Depending on the NetCons threshold "thresh_dd" the following things happen:
If thresh_dd >= -30, no "spike" or threshold crossing signal is transmitted to the target cell.
If thresh_dd = -40, both of the two "spikes" are detected and a response signal can be seen on the target cell.
If thresh_dd = -35, only the second time the membrane potential in the source compartment crosses the -35 mV is registered and sent to the target cell.
The cells I'm using are both real multi-compartment cells with some HH-type ion channels taken from existing models from ModelDB.
In a serial version this behavior does not appear.
Sounds like your source cell has different properties (specifically, is less excitable) in the parallelized code than it does in the serial code. Either that, or else the NetCon that monitors its membrane potential has different thresholds in the serial and parallelized implementations, or is attached to a different part of the cell so that it sees smaller spikes in the parallel implementation than in the serial implementation.
bkaplan
Posts: 10
Joined: Thu Apr 22, 2010 4:34 am

Re: NetCon detection threshold

Post by bkaplan »

Hi,
independent of the differences between the serial and the parallel implementations (which might well be there...) it is important to note, that the membrane potential in the source compartment clearly crosses 0 mV in all of the three above mentioned cases and this happens two times within one run, but only when the detection threshold of the NetCon in that compartment is low, both events are correctly detected and transmitted to another cell, which puzzles me quite a lot and I can't come up with any good reason for that (I've tried to change simulation time step size, but it didn't help). I could send you figures of the membrane potentials to clarify this.
Best regards,
Bernhard.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NetCon detection threshold

Post by ted »

Just on the off chance that this is caused by a bug that has since been fixed, what version of NEURON are you using? i.e. what is the first line that NEURON prints to the terminal when it starts?
bkaplan
Posts: 10
Joined: Thu Apr 22, 2010 4:34 am

Re: NetCon detection threshold

Post by bkaplan »

First line of nrniv gives: NEURON -- Release 7.1 (359:7f113b76a94b) 2009-10-26,
my OS: Ubuntu 10.04 64bit Linux kernel 2.6.32-33
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NetCon detection threshold

Post by ted »

Well, there have been a lot of bug fixes since then, so maybe the first thing to try is installing either the most recent 7.2 alpha version of NEURON from source code
http://www.neuron.yale.edu/ftp/neuron/v ... 524.tar.gz
or getting the very latest development code from the mercurial repository and compiling that, as described here
http://www.neuron.yale.edu/neuron/download/getdevel
bkaplan
Posts: 10
Joined: Thu Apr 22, 2010 4:34 am

Re: NetCon detection threshold

Post by bkaplan »

Hi,
I've just installed the latest version from the repository (NEURON -- VERSION 7.2 (527:a38b8d137de6) 2011-07-26), but the problem persists: event detection / transmission depends on the NetCon's threshold (defined in the source cell template) and event transmission does not happen reliably.
Another setup which clarifies the problem:
the source cell receives current injection via IClamp and fires a spike. When thresh_dd for the netcon in the source cell template is =-50 mV the target cell receives an event (also fires a spike), if thresh_dd=-40 the target cell stays absolutely silent (membrane potential is at baseline). Might it be a numerical problem, because the derivative of the membrane potential in the source cell is too high at -40 mV but small enough at -50 mV ... ? I'm just guessing ...
Best regards,
Bernhard
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NetCon detection threshold

Post by ted »

Without being able to examine your source code or reproduce your observations, I'm at a total loss to offer any advice.
bkaplan
Posts: 10
Joined: Thu Apr 22, 2010 4:34 am

Re: NetCon detection threshold

Post by bkaplan »

Hi,
sorry for the confusion, but I just figured out that I forgot to run with the -mpi flag, hence this does not happen in a parallel context. Anyway my problem is now more fundamental, since I couldn't figure out how to implement a dendrodendritic communication between two cells when using -mpi.
My approach which works on a single core was the following:
- set a NetCon object in the desired compartment in the source cell and store the NetCon in a public list (code snippet from the cell template is above, for the rest of the cell template I took the Mitral cell model from Andrew Davison ModelDB accession number:2730)
Code for the source cell creation looks like:

Code: Select all

        if (pnm.gid_exists(gid)){   // if cell has been assigned to this machine
            cell = new Mit(rnd_int.repick())
            pnm.register_cell(gid, cell)
            pnm.set_gid2node(gid + n_cells, pc.id()) // put another gid onto the same machine
            pc.cell(gid + n_cells, cell.src_netcons_glom.o(0)) // associate (gid+n_cells) with the netcon in the source cell's compartment
            pnm.pc.outputcell(gid)
            pnm.pc.outputcell(gid + n_cells)
        }
and for connecting to the target cell I have this code:

Code: Select all

// after having defined the gid of the target cell
            if (pnm.pc.gid_exists(tgt_gid)) {
                tgt_cell = pnm.pc.gid2cell(tgt_gid)
                dd_netcon = pnm.pc.gid_connect(td_gid, tgt_cell.synlist.o(0)) // NetCon for the dendrodendritic connection
                dd_netcon.weight = w_mit_gran // weight from Mitral to Granule cell 
                dd_netcon.threshold = -50
                all_netcons.append(dd_netcon)
            }
// dd_netcon and all_netcons are non-local objects
When this code runs with the -mpi flag, i.e. cells are on different machines, there is no signal transmitted from source to target cell.
Is it because target of the NetCon object stored in the source cell has a NULLobject as target which makes this NetCon inactive (what would be the way to get a threshold detection mechanism for parallel networks)? And why does it work then when it runs on a single machine when the NetCon is inactive?
I've tried to use the ThresholdDetection mechanism given in Migliore et. al 2010 ModelDB accession number 127995, but I couldn't get it to run.
Could you please post some example code in which events from a source cell's compartment with an arbitrary threshold for the membrane potential are sent to some target cell's synapse?
I would like to post more code, but I think it is impractical to post ALL the code I have, since it is set up to run large networks and thus includes a lot of unimportant overhead (but I could email it, of course).
Btw. when running on a single machine, the weird behavior describe above (some events get transmitted, some do not) does ONLY occur if I use

Code: Select all

pnm.nc_append(td_gid, tgt_gid, synapse_id, w_mit_gran, delay) // td_gid is the gid associated with the 'inactive' netcon in the source compartment, i.e. td_gid = src_gid + n_cells

(without checking if the tgt_gid exists) instead of the

Code: Select all

pnm.pc.gid_connect( ... )
statements from above...
Thanks in advance and best regards,
Bernhard
bkaplan
Posts: 10
Joined: Thu Apr 22, 2010 4:34 am

Re: NetCon detection threshold

Post by bkaplan »

Hi again,
I think I solved the issue, but still need to figure out where the problem in my previous code is...
So here is some code which works as it should, maybe you can still comment on the code if this is the way it is supposed to be done...
I think it is important to note that the threshold for event detection must be set in the NetCon object owned by the source cell (here in the template):

Code: Select all

// from mitral.tem see modeldb Davison 2003
glom{
        ... 
        // these lines were added:
        thresh_dd = -45
        delay = 30 // will be summed to the total delay
        weight = 0.1 // is ignored
        src_netcons_glom.append(new NetCon(&v(0.5), nil, thresh_dd, delay, weight)) // append to public list
}
and that the weight for the connection is controlled by the NetCon returned by the pc.gid_connect call (see below).
Delays of both NetCons will be summed to a total delay.
Here is the 'main.hoc' file:

Code: Select all

load_file("nrngui.hoc")     // needed to get stdrun methods
load_file("netparmpi.hoc")	// for mpi usage
xopen("tabchannels.hoc")
load_file("mitral.tem")
load_file("granule.tem")
celsius = 36

// init
n_cells = 2
objref pnm // Parallel Network Manager: manages the setup and running of a parallel network simulation
pnm = new ParallelNetManager(n_cells) // tell the parallel network manager how many cells to handle
objref pc
pc = new ParallelContext()
n_proc = pnm.pc.nhost()
pnm.round_robin()

// create MT cell
gid = 0
objref mit
if (pnm.gid_exists(gid)){	// if cell has been assigned to this machine
	mit = new Mit()
	printf("Create a MT cell with gid %d on process %d \n", gid, pc.id())
	pnm.register_cell(gid, mit)
	pnm.set_gid2node(gid + n_cells, pc.id()) // put another gid onto the same machine
	pc.cell(gid + n_cells, mit.src_netcons_glom.o(0)) // associate gid+n_cells with the netcon in the source cell's compartment
	pnm.pc.outputcell(gid)
	pnm.pc.outputcell(gid + n_cells)
}

// create granule cell
gid = 1
objref gran
if (pnm.gid_exists(gid)){	// if cell has been assigned to this machine
	gran = new Gran()
	pnm.register_cell(gid, gran)
	printf("Create a granule cell with gid %d on process %d \n", gid, pc.id())
}

t_sim = 1000
// insert current into MT cell with gid = 0
objref stim1, stim2
gid = 0
if (pnm.gid_exists(gid)) {
	mit = pnm.pc.gid2cell(gid)
	mit.glom stim1 = new IClamp(0.5)
	stim1.del = 50
	stim1.dur = 200
	stim1.amp = 0.15
	mit.glom stim2 = new IClamp(0.5)
	stim2.del = 450
	stim2.dur = 200
	stim2.amp = 0.15
}

// connect the dend compartment of the MT cell to the periph compartment of the granule cell
tgt_gid = 1
objref dd_netcon, all_netcons
all_netcons = new List()
td_gid = 2 // the gid of the NetCon object for threshold detection
if (pnm.pc.gid_exists(tgt_gid)) {
	gran = pnm.pc.gid2cell(tgt_gid)
	dd_netcon = pnm.pc.gid_connect(td_gid, gran.synlist.o(0))
	dd_netcon.weight = 0.001
        dd_netcon.delay = 20 // will be summed to the total delay
    // the following two line is ignored, since threshold is in the NetCon owned by the source cell (defined in the template)
/*    dd_netcon.threshold = 10*/ 
	all_netcons.append(dd_netcon)
}

// record voltages for different compartments into different files
gid = 0
if (pnm.gid_exists(gid)){
	mit = pnm.pc.gid2cell(gid)
	mit.record_v()
	mit.record_glom_v()
	mit.record_dend_v()
}

gid = 1
if (pnm.gid_exists(gid)){
	gran = pnm.pc.gid2cell(gid)
	gran.record_v()
	gran.record_periph_v()
}

// run
dt = 0.1 // [ms]
pnm.set_maxstep(dt)
pnm.want_all_spikes()

stdinit()
pnm.psolve(t_sim)
// print voltages
gid = 0
if (pnm.gid_exists(gid)){
	mit = pnm.pc.gid2cell(gid)
	strdef fn_mit_soma
	strdef fn_mit_glom
	strdef fn_mit_dend
	sprint(fn_mit_soma, "mit_volt_soma_%d.dat", gid)
	sprint(fn_mit_glom, "mit_volt_glom_%d.dat", gid)
	sprint(fn_mit_dend, "mit_volt_dend_%d.dat", gid)
	mit.print_v(fn_mit_soma)
	mit.print_glom_v(fn_mit_glom)
	mit.print_dend_v(fn_mit_dend)
}

gid = 1
if (pnm.gid_exists(gid)){
	gran = pnm.pc.gid2cell(gid)
	strdef fn_gran_soma
	strdef fn_gran_periph
	sprint(fn_gran_soma, "gran_volt_soma_%d.dat", gid)
	sprint(fn_gran_periph, "gran_volt_periph_%d.dat", gid)
	gran.print_v(fn_gran_soma)
	gran.print_periph_v(fn_gran_periph)
}

pnm.pc.runworker()
pnm.pc.done()
Thanks for pushing me to post code, a clean small setup really helps hunting down the 'bug' ...
Cheers,
Bernhard
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NetCon detection threshold

Post by ted »

Could you please post some example code in which events from a source cell's compartment with an arbitrary threshold for the membrane potential are sent to some target cell's synapse?
The following articles are authoritative and most illustrative of good programming practice. The first is the most "tutorial" in nature. The code for the second paper shows a very nice factorization of a network implementation into two kinds of components: those that are specific to the particular details of the model cells that are used, and those that pertain entirely to network architecture--so that it is possible to "plug" in different kinds of model cells into a given network architecture, and see how this affects network performance. All three papers are available from http://www.neuron.yale.edu/neuron/nrnpubs, and their source code is available from ModelDB.

Hines, M.L. and Carnevale, N.T. Translating network models to parallel hardware in NEURON. J. Neurosci. Methods 169:425-455, 2008.

Brette, R., Rudolph, M., Carnevale, T., Hines, M., Beeman, D., Bower, J.M., Diesmann, M., Goodman, P.H., Harris, F.C.J., Zirpe, M., Natschläger, T., Pecevski, D., Ermentrout, B., Djurfeldt, M., Lansner, A., Rochel, O., Vieville, T., Muller, E., Davison, A., El Boustani, S., and Destexhe, A. Simulation of networks of spiking neurons: a review of tools and strategies. J. Comput. Neurosci. 23:349-398, 2007.

Migliore, M, Cannia, C., Lytton, W.W., Markram, H. and Hines, M.L. Parallel network simulations with NEURON. Journal of Computational Neuroscience 21:119-129, 2006.
When this code runs with the -mpi flag, i.e. cells are on different machines, there is no signal transmitted from source to target cell.
Is it because target of the NetCon object stored in the source cell has a NULLobject as target which makes this NetCon inactive
I can see how the NetCon class documentation might lead to such an inference. The NetCon with NULLobject target is merely being used as a "spike detector." The "active" vs. "inactive" distinction applies only to whether a NetCon does or doesn't deliver spikes to a target; spike detection always works.

By the way, a program that has been parallelized correctly will produce the same result regardless of:
--whether it is executed on serial or parallel hardware
--whether it is executed with or without mpi
--the number of processors that are used or how the cells are distributed over the processors
--how many times it has been run

Code: Select all

// from mitral.tem see modeldb Davison 2003
 . . .
        src_netcons_glom.append(new NetCon
It is not necessary or always desirable to include NetCons into a cell class definition. I can see why it was done in this particular model, which involves dendrodendritic synapses, but an alternative implementation is possible in which no cell class has a built-in NetCon, and all synaptic connections (including dendrodendritic) are set up separately, i.e. a model setup strategy that preserves separation of
define cell classes
create all cell instances
connect cell instances
I think it is important to note that the threshold for event detection must be set in the NetCon object owned by the source cell . . .
The NetCon that does the spike detection is the one that is attached to the presynaptic neuron. The threshold parameter that matters is the one that belongs to this NetCon. The threshold parameters of the NetCons that deliver events to targets are irrelevant, because those NetCons can't discover the values of range variables in the presynaptic cell--they might not even be on the same processor as the presynaptic cell.

On the other hand, as you note, the weight parameters that matter are those that belong to the NetCons that are attached to targets. The NetCon attached to the presynaptic cell has no way to know whether the threshold crossings it detects are ever communicated to anything. And even if it did, it would make no sense for it to manage the synaptic weights because that would require mpi to communicate a lot more data (not just the time of the presynaptic threshold crossing, but also the weight(s)).
Delays of both NetCons will be summed to a total delay.
Does that work? It should be guaranteed not to work, that is, the total latency between the presynaptic threshold crossing and event delivery should be controlled entirely by the NetCons that handle event delivery, i.e. those that deliver events to "real" targets such as synaptic mechanisms or artificial spiking cells. The spike detecting NetCon's delay parameter should have no effect at all.

Finally, you'll probably notice that the first two papers cited above don't use the ParallelNetManager. The software patterns that they demonstrate seem easier to deal with.
Post Reply