Input Variables into Templates

NMODL and the Channel Builder.
Post Reply
blhuynh

Input Variables into Templates

Post by blhuynh »

I've currently got a template for collateral axons that makes repeated collaterals. However, I'd like to be able to vary these collaterals based on the fiber diameter designated in my main file. Is it possible for templates to take in input variables? Thanks.
blhuynh

Re: Input Variables into Templates

Post by blhuynh »

Figured it out:

Code: Select all

// Build collaterals
objectvar collat[nocol]
for i=0,nocol-1 {
	collat[i]=new collateral(5)
}

Code: Select all

begintemplate collateral
print "loading collateral.hoc"
public collsec
create collsec[1]

proc init(){
	fiberD = $1
	print "fiberD=",fiberD
}
endtemplate collateral
blhuynh

Re: Input Variables into Templates

Post by blhuynh »

However, I notice that there is a significant reduction in computational speed when using input arguments rather than hard-coding values in. Any insight into this?
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Input Variables into Templates

Post by hines »

There is obviously more to your cell building strategy than the fragments you presented since all the collaterals are independent cells unless colat.collsec[0] gets connected to some parent.
My preference generally, is to keep all the sections of a cell in a single cell object. The exception is spines which might usefully be associated with a synapse wrapper object.
In your case, a Cell template can declare
create collateral[0]
and the in the proc init() redeclare with the statement
create collateral[$1]
Anyway, I would not expect a noticable reduction in setup time (or any reduction at all in simulation time) due to the object wrapping differences. If you send me your code which compares
input args vs hard coded values I would be interested in diagnosing the reason for the poor perforamace of the former. Send to michael dot hines at yale dot edu.
Post Reply