Page 1 of 1

nseg not a USEPROPERTY

Posted: Thu Jun 22, 2017 4:38 am
by merkdeturk
When I use the Pycharm IDE to import neuron and run code, everything works fine. But when I use the Python Console, or Jupyter notebook, to run the following code snippet:

from neuron import h
soma = h.Section(name='soma')
h.psection()

I get the following error immediately after I type the period following 'h' in h.psection():

NEURON: nseg not a USEPROPERTY that can be pointed to
near line 0
create soma

Again, it's very strange because when I run the same code in the IDE, it works fine...

By the way, I'm using OS X El Capitan version 10.11.6, Python 2.7.13, and IPython 5.1.0

Thanks in advance for your time!

Re: nseg not a USEPROPERTY

Posted: Tue Jun 27, 2017 7:42 pm
by hines
I have not been able to reproduce that problem on Sierra python 2.7.10 or anaconda ipython (2.7.13).
You did not mention the NEURON version you are using. If you are not building NEURON from sources, can you try the latest
http://www.neuron.yale.edu/ftp/neuron/v ... 64-osx.pkg
and see if the problem still exists.
Is your export PYTHONPATH =/Applications/NEURON-7.5/nrn/lib/python

Re: nseg not a USEPROPERTY

Posted: Thu Jun 29, 2017 4:27 am
by merkdeturk
I'm using NEURON-7.4, and yup, export PYTHONPATH=/Applications/NEURON-7.4/nrn/lib/python, as well as export PYTHONHOME="/Users/merkdeturk/anaconda/", are both there.

I'll try the latest build, NEURON-7.5, and see if it still persists. Thank you!

Re: nseg not a USEPROPERTY

Posted: Mon Jul 03, 2017 1:00 pm
by patoorio
Hi,

I'm getting the same error under a completely different circumstance. Windows+Python3+Neuron7.5 (See below the details), if I'm within iPython and press TAB for autocompletion of h.IClamp, or h.load_file, the kernel dies with that same message. Autocompletion for other things like h.Section(), works OK (I haven't tried too many things to be honest). Interestingly, autocompletion for 'soma.diam' brings up soma.diam3d instead of diam. So there is something else broken there.
If I do the same in an iPython console under Spyder, the kernel dies but without the error message (or maybe the message is there but the kernel is thrown away too quickly).
I'm not sure if this is related to the thread, actually, but it caught my attention that the error is the same. Forgive me if I'm mixing unrelated stuff.

Here is a transcript. The error appeared when I had typed 'h.load_' and then pressed TAB. Note that there is a previous error because h.stop was not yet available; that's why I wanted to do h.load_file("stdrun.hoc"). This time, I typed h.IClamp without autocompletion.

Code: Select all

In [1]: from neuron import h
NEURON -- VERSION 7.5 master (a535c69) 2017-07-03
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits


In [2]: soma=h.Section()

In [3]: st1=h.IClamp(0.5)

In [4]: st1.delay
Out[4]: 0.0

In [5]: st1.delay=1

(...)

In [9]: h.stop
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-c88186819cbe> in <module>()
----> 1 h.stop

TypeError: Cannot access stop (NEURON type 289) directly.

In [10]: h.load_NEURON: nseg  not a USERPROPERTY that can be pointed to
 near line 0
 objref hoc_obj_[2]

I'm trying to switch everything to Python3 under windows, so I'm using:
Windows 10
Python 3.6 under Anaconda3 (actually miniconda)
nrn-7.5.master-1618.w64-mingw-py-36-35-27

In another computer, the same happened with master-1616.

Regards.

Re: nseg not a USEPROPERTY

Posted: Tue Jul 04, 2017 8:01 am
by hines
Sorry, I did not catch at first that this was an issue with tab completion with ipython. The problem has been fixed by properly handling nseg as an integer and the fix is pushed to http://github.com/nrnhines/nrn.
Up to date installers for mswin and mac os x are at
http://www.neuron.yale.edu/ftp/neuron/versions/alpha (in particular get the relevant nrn-7.5.master-1620...)

Re: nseg not a USEPROPERTY

Posted: Tue Jul 04, 2017 1:17 pm
by patoorio
Great! Thanks

Still, when I do autocompletion on a Section's name, 'diam' does not appear as an option:

Code: Select all

In [2]: soma=h.Section()

In [3]: soma.
              allseg()            diam3d()            L                   parentseg()         trueparentseg()
              arc3d()             has_membrane()      n3d()               push()              uninsert()
              cell()              hname()             name()              Ra                  x3d()
              children()          hoc_internal_name() nseg                rallbranch          y3d()
              connect()           insert()            orientation()       same()              z3d()
typing 'di' + TAB, selects 'diam3d'

Re: nseg not a USEPROPERTY

Posted: Tue Jul 04, 2017 2:00 pm
by ramcdougal
NEURON's directory information is technically incomplete here, but please don't use section.diam as it is potentially confusing: diam is naturally a property of a segment not of a section, so reading section.diam will return the middle diameter and writing it will set all segments:

Code: Select all

>>> dend = h.Section(name='dend')
>>> dend.nseg = 3
>>> dend(0.1).diam = 1
>>> dend(0.5).diam = 2
>>> dend(0.9).diam = 3
>>> dend.diam
2.0
>>> dend(0.9).diam
3.0
>>> dend.diam = 4
>>> dend(0.9).diam
4.0
Tab completion on dend(0.9). should work as expected.

Re: nseg not a USEPROPERTY

Posted: Tue Jul 04, 2017 2:15 pm
by patoorio
Oh, I see.
Thanks for the explanation!!

Re: nseg not a USEPROPERTY

Posted: Tue Jul 04, 2017 2:53 pm
by hines
That is the tip of an iceberg and I'm not quite sure what is the best way to handle the dict for neuron.h. It is basically a copy of the hoc symbol table and as such contains a lot of names that are useless in python such
as all the hoc keywords, mechanism names, and range varaiables (such as nseg) which really should only be used as a field of a nrn.Section or nrn.Segment . One can see the issues with

Code: Select all

from neuron import h
for i in dir(h):
  try:
    print (h.__getattribute__(i))
  except:
    print ("error: ", i)