Extract network connectivity

Moderator: wwlytton

Post Reply
manyi
Posts: 12
Joined: Mon Apr 02, 2012 6:48 am

Extract network connectivity

Post by manyi »

Hi there!

I want to extract the connectivity of the network. I'm using an artificial cell as Poisson input sources and a usual neuron model for neurons. When printing the pre and post cells with

Code: Select all

for i=0, nclist.count-1 {dfile.printf("%s\t%s\t%s\n", nclist.object[i].precell, nclist.object[i].postcell, nclist.object[i].syn)}
I got correct labels for neurons (Let's say "Cell[0]") but "NULLobject" for Poisson sources, and so I cannot trace the Poisson sources to a particular neuron. If I replace precell by pre, I got the correct labels for Poisson input sources (say "NetStim[0]") but "NULLobject" for neurons.

How can I get correct labels to both at the same time? Many thanks!
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extract network connectivity

Post by ted »

That's how the NetCon class's precell() and pre() methods work. The workaround is to write your own "precell" function that anticipates possible outcomes and takes appropriate action in each case. Something like this might work:

Code: Select all

// argument is a NetCon
obfunc myprecell() { local nil
  // nil points to NULLobject
  if ($o1.precell() == nil) {
    return $o1.pre()
  } else {
    return $o1.precell()
  }
}
A minor comment, for the benefit of subsequent readers of this thread: the square brackets [ ] in the example you provided should be parentheses ( ).
manyi
Posts: 12
Joined: Mon Apr 02, 2012 6:48 am

Re: Extract network connectivity

Post by manyi »

I have the following code in a proc

Code: Select all

for i=0, nclist.count-1 {
		dfile.printf("%s\t%s\n", myprecell(nclist.object(i)), nclist.object(i).postcell)}
obfunc myprecell(){...} is defined in the same file, just above the proc. I get the following error message and do not know what's wrong:

bad stack access: expecting (Object **); really (double)
/usr/local/nrn/i686/bin/nrniv: interpreter stack type error
in test.hoc near line 151
rrun()
^
myprecell(...)
saveNet()
rrun()
initcode failed with 2 left
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extract network connectivity

Post by ted »

Is the problem in myprecell(), or is it elsewhere?

First of all, what does
nclist.o(0)
return?
And what about
printf("%s\n", nclist.o(0))
?

Does
for i=0, nclist.count-1 printf("%s\n", nclist.o(i))
produce the expected result?

What about
myprecell(nclist.o(0))
?
And
for i=0, nclist.count-1 printf("%s\n", myprecell(nclist.o(i)))
?
manyi
Posts: 12
Joined: Mon Apr 02, 2012 6:48 am

Re: Extract network connectivity

Post by manyi »

It works when 'local nil' is removed from the obfunc.
Thanks!
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Extract network connectivity

Post by ted »

My mistake. The first line of the definition of myprecell() was supposed to be
obfunc myprecell() { localobj nil

If your code works with
obfunc myprecell() {
i.e. after deleting the declaration that nil is a localobj,
then there must have been a
localobj nil
statement somewhere else in your code at the top level, i.e. outside of any object.

For future readers of this thread: the corrected procedure is

Code: Select all

// argument is a NetCon
obfunc myprecell() { local nil
  // nil points to NULLobject
  if ($o1.precell() == nil) {
    return $o1.pre()
  } else {
    return $o1.precell()
  }
}
Post Reply