Open ramcdougal opened 1 year ago
As far as I can tell, you can create two different sections with the same name:
>> axon1 = n.Section("axon");
>> axon2 = n.Section("axon");
>> axon1.nseg = 10;
>> axon2.nseg = 100;
>> axon1.nseg % this asks the C++ object about the value of (sec.nnode - 1)
ans = 10
>> axon2.nseg
ans = 100
The behavior is already inconsistent between HOC and Python, so this may not make a lot of sense:
In HOC, you can only ever have one instance of a thing with a given name; creating another one isn't an error, but the old one and any of its properties goes away... so here, for example, there are 5 dashes in the original topology for the 5 segments, but after recreating it, there's only one:
oc>create axon
oc>axon.nseg=5
oc>topology()
|-----| axon(0-1)
1
oc>create axon
oc>topology()
|-| axon(0-1)
1
(There are other mechanisms to separate axons
belonging to different cells, so this isn't as limiting as it seems.)
In Python, like the MATLAB version, it'll happily let you have two sections with the same name:
>>> from neuron import h
>>> axon = h.Section(name="axon")
>>> axon.nseg = 5
>>> axon2 = h.Section(name="axon")
>>> h.topology()
|-----| axon(0-1)
|-| axon(0-1)
1.0
None of those are accessible by name, e.g. if you try to do h.axon
, it'll error:
>>> h.axon
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'hoc.HocObject' object has no attribute 'axon'
If, however, the section is created in HOC, since there can be only one such section with a given name, then it can be accessed from Python by name, e.g.
>>> h("create axon")
1
>>> h.axon
axon
So you might think no-one would ever do that so it's kind of irrelevant, BUT the library that we use for importing neuron morphologies is written in HOC, so we often do have the ability to access things like h.dend
... except to make it messier still, when we use that library we get an array of dendrites, so it's actually h.dend[4]
.
@hermanncuntz Any thoughts on what is necessary to efficiently work with morphologies?
In Python, if a Section was known to NEURON as
soma
, we can access it viah.soma
. It would be nice to do something similar in MATLAB. With theallsec()
pull request, people can acheive the same thing by looping over all sections and checking the name, but that's not pretty.I think sections will show up with some unknown type number when we're trying to get everything that's available from the top level from NEURON.