uninsert python

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
oren
Posts: 55
Joined: Fri Mar 22, 2013 1:03 am

uninsert python

Post by oren »

Hello,
I am trying to use uninsert in python.
as I read form the documentation using insert is as follows

Code: Select all

sec.insert("hh") 
so I assumed that uninsert will work like this:

Code: Select all

sec.uninsert("hh") 
but I get the follwoing error code:

Code: Select all

In [11]: sec.uninsert("hh") 
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-e55a73adc72b> in <module>()
----> 1 sec.uninsert("hh")

AttributeError: 'nrn.Section' object has no attribute 'uninsert'
Is this feature missing from the python wrapper ?
Thanks,
Oren.
romain.caze

Re: uninsert python

Post by romain.caze »

Dear Oren,

There is no uninsert procedure in NEURON (to my knowledge). It explains the error message (Section has no attribute "uninsert"). A solution might be to create a new section and insert only the things you want in it and not insert the "hh".

Best,
R.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: uninsert python

Post by ted »

dend = h.Section()
dir(dend)
shows that sections know insert, but not uninsert. This syntactic gap will be corrected in a future version of NEURON.

h('forall uninsert hh')
works as long as all existing sections have hh.

h('uninsert hh', sec=dend)
is a workaround that does what you want, i.e. uninserts a mechanism from an individual section.


I had hoped that one could
dend = h.Section(name='dend')
dend.insert('hh')
and then
h('dend uninsert hh') # avoid the mix of hoc and Python and the extra typing in h('uninsert hh', sec=dend)
but even though
dend.hname()
returns
'dend'
my hoped-for syntax does not work. According to Michael Hines, this is because
The 'name' arg for the section constructor . . . only refers to the label printed by GUI tools and topology and psection. That label cannot be used by the hoc interpreter as it is not added to the hoc symbol table. Hoc can only refer to a python section via the Section.hoc_internal_name() method.
And sure enough, that is correct, since either this

Code: Select all

>>> dend.hoc_internal_name()
'__nrnsec_0x9b34f78'
>>> h('uninsert hh', sec=h.__nrnsec_0x9b34f78)
1
or this much simpler (but still a bit tedious)

Code: Select all

>>> h('__nrnsec_0x9b34f78 uninsert hh')
1
will work. Either of which is nice and internally consistent but not very practical since it is much easier to type (and read)
h('uninsert hh', sec=dend)
oren
Posts: 55
Joined: Fri Mar 22, 2013 1:03 am

Re: uninsert python

Post by oren »

Thank you for the reply,

Oren.
ngreiner
Posts: 11
Joined: Tue Feb 28, 2017 8:12 am

Re: uninsert python

Post by ngreiner »

Dear Ted,

I am encountering the following issues when trying to uninsert the extracellular mechanism from a section using python:

Code: Select all

>>> fiber.internodes[1].hoc_internal_name()
'__nrnsec_0x7ff9e6804bc0'
>>> h('__nrnsec_0x7ff9e6804bc0 uninsert extracellular')
NEURON: Can't uninsert mechanism extracellular
 near line 1
 __nrnsec_0x7ff9e6804bc0 uninsert extracellular
                                               ^
1
and

Code: Select all

>>> h('uninsert extracellular', sec=fiber.internodes[1])
NEURON: Can't uninsert mechanism extracellular
 near line 1
 uninsert extracellular
                       ^
1
while I get no error when writing:

Code: Select all

>>> h('uninsert axnode', sec=fiber.internodes[1])
1
In the previous, fiber.internodes is a list of python references to HOC sections, and 'axnode' is McIntyre's mechanism (MRG model).

Do you know why extracellular cannot be uninserted?

Thanks in advance for your reply.

Nathan
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: uninsert python

Post by ted »

extracellular cannot be "uninserted" regardless of how you try to do it--whether you're using Python or hoc. It is not a "mechanism" in the same sense as any density mechanism because, unlike any density mechanism, "inserting" extracellular causes a profound alteration of the structure of the model's Jacobian matrix in order to represent the additional cable layers.
ngreiner
Posts: 11
Joined: Tue Feb 28, 2017 8:12 am

Re: uninsert python

Post by ngreiner »

Thank you for your prompt reply.
Nathan
Post Reply