Page 1 of 1

uninsert python

Posted: Sun Jul 05, 2015 9:40 am
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.

Re: uninsert python

Posted: Mon Jul 06, 2015 8:43 am
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.

Re: uninsert python

Posted: Mon Jul 06, 2015 11:26 am
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)

Re: uninsert python

Posted: Sun Jul 12, 2015 4:16 pm
by oren
Thank you for the reply,

Oren.

Re: uninsert python

Posted: Thu Jun 08, 2017 3:22 pm
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

Re: uninsert python

Posted: Fri Jun 09, 2017 12:33 am
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.

Re: uninsert python

Posted: Fri Jun 09, 2017 7:35 am
by ngreiner
Thank you for your prompt reply.
Nathan