This syntax
g_pas(0:1) = (0.001:.00001)
works, but nobody has used it in new code for a long time for two reasons: it's rather opaque, it can only produce linear gradients along the length of any section, and there's no good way to use it to set up even a linear gradient over a set of sections.
Far better is to implement parameterized variation of your density parameter, that is, something like
Code: Select all
forsec subset for (x,0) { rangevar_suffix(x) = f(p(x)) }
where subset is a SectionList (essentially a set of sections),
p is some measure of the position of the midpoint of the current segment in space, such as path distance from the 0 end of the soma, radial distance from the 0 end of the soma, or elevation above or below a plane (e.g. cell body layer, middle of some cortical layer, cortical surface . . .)
and f is a function that tells how rangevar_suffix should vary with position in space.
Of course, if you then change nseg, you should again execute
Code: Select all
forsec subset for (x,0) { rangevar_suffix(x) = f(p(x)) }
to ensure that the inhomogeneous range variable samples f at the proper locations in space.
In recent versions of NEURON, the CellBuilder can take care of setting up nonuniform biophysical properties very efficiently and flexibly--and it even automatically re-executes
Code: Select all
forsec subset for (x,0) { rangevar_suffix(x) = f(p(x)) }
if you do anything in the CellBuilder that changes nseg.
See the CellBuilder tutorial https://neuron.yale.edu/neuron/static/d ... /main.html, in particular the part about
Specifying parameterized variation of biophysical properties.
"I already have a model cell specified with hoc code. Do I have to use the CellBuilder to create a duplicate implementation of it?"
Not at all. Use the CellBuilder to create a toy model that has only three sections, and insert just one biophysical mechanism into it. Set up parameterized variation of that mechanism's channel density, and verify that the spatial variation is what you want. Then export the toy model to a hoc file, and mine that hoc file for code that you can reuse with your own model.