Accessing functions in a cell template with a NetStim

Moderator: wwlytton

Post Reply
neuromau
Posts: 97
Joined: Mon Apr 20, 2009 7:02 pm

Accessing functions in a cell template with a NetStim

Post by neuromau »

Hi, I have an artificial cell template that contains a NetStim. I added an "is_art" function to this cell template, but when I try to access it from the parallel context, NEURON is looking for it to be part of the NetStim within the cell template, instead of just a function available as part of the cell instance. Here is my cell definition:

Code: Select all

begintemplate ppspont
	public pp, is_art, acell, connect_pre
	create acell
	objref pp

	proc init() {
		actemp() 	
	}
	proc actemp() {
		acell pp = new MyNetStim(.5)
	}
	func is_art() {return 1}
	proc connect_pre() {acell $o2 = new NetCon(pp, $o1)}	
endtemplate ppspont
Then I create an instance of this cell template, and is_art works fine. But when I associate the cell with a gid and then try to recreate the cell object from the gid using the parallel context, is_art no longer works:

Code: Select all

{load_file("nrngui.hoc")}
{load_file("netparmpi.hoc")}
ncell=1
objref pnm, pc, nc, nil
proc parallelizer() {
	pnm = new ParallelNetManager(ncell)
	pc = pnm.pc
	pnm.round_robin()
}
parallelizer()

pc.nhost // returns 1

objref mycell
mycell = new ppspont()
mycell.is_art() // works fine, returns 1
objref nc
mycell.connect_pre(nil, nc)
pc.cell(0, nc)
pc.gid_exists(0) // returns 1
objref thecell
thecell = pc.gid2cell(0)
thecell.is_art() // errors out with the error:
// is_art not a public member of MyNetStim
// nrniv: MyNetStim is_art
Do I need to edit "MyNetStim" and create an is_art function in there or is there a way I can make the pc.gid2cell generated object's functions available?
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Accessing functions in a cell template with a NetStim

Post by ted »

Short answer is yes, MyNetStim must have a public is_art() if you want thecell.is_art() to succeed. I verified this by trying the code you provided (after the expedient of changing
acell pp = new MyNetStim(.5)
to
acell pp = new NetStim(.5)
since I didn't have your MyNetStim template). Sure enough,

Code: Select all

oc>objref thecell
oc>thecell=pc.gid2cell(0)
oc>thecell
	NetStim[0]
I'm curious about why your ppspont template bothers to create a dummy section--what purpose does acell serve?
neuromau
Posts: 97
Joined: Mon Apr 20, 2009 7:02 pm

Re: Accessing functions in a cell template with a NetStim

Post by neuromau »

Short answer is yes, MyNetStim must have a public is_art() if you want thecell.is_art() to succeed.
Okay, I added the following to my MyNetStim.mod file and recompiled, now I can use "thecell.is_art()" with an object created by the pc.gid2cell function:

Code: Select all

FUNCTION is_art() {
	is_art=1
}
what purpose does acell serve?
None, as far as I can tell. I just removed it without any issues. Not sure why it was in there; grandfathered in from work by a previous coder. Thanks for noticing that.
Post Reply