Page 1 of 1

PyNeuron Model View Error while calling the Py Class

Posted: Wed Dec 14, 2011 6:54 am
by figoyouwei
Dear all:

With python, I am creating a cell class in a file name "MSP.py".

In the MSP.py, basically I define the cell class like
class Cell(object):
...
self.soma = h.Section(name='soma',cell=self)
self.dend = h.Section(name='dend',cell=self)
self.dend.connect(self.soma(1),0)
...

I can h.run() the model and save data, everything seems fine.
BUT the Model View is NOT working, it generates error as follow:
---------- error ----------
NEURON: syntax error
near line 0
{ModelViewRealCell[0].cellobj = <MSP}
^
ModelViewRealCell[0].execute("ModelViewRealCell[0].cellobj = <MSP")
ModelViewRealCell[0].init(ModelView[0])
ModelView[0].mkrlist()
ModelView[0].init(0)
---------- error ----------

Any suggestions ?

Youwei

Re: PyNeuron Model View Error while calling the Py Class

Posted: Thu Dec 15, 2011 11:06 am
by figoyouwei
Hi

Maybe I ask the other way around, how can I generate "mview.hoc" file manually instead of clicking on the GUI->Tools-> Model View ?

Youwei

Re: PyNeuron Model View Error while calling the Py Class

Posted: Wed Dec 21, 2011 2:22 pm
by ted
figoyouwei wrote:how can I generate "mview.hoc" file manually instead of clicking on the GUI->Tools-> Model View ?
You have just described how to bring up a Model View tool manually.

Are you asking "how can I bring up a Model View tool by executing code"? If the answer is yes, here's how:
execute these two hoc statements, or their Python equivalents:

Code: Select all

load_file("mview.hoc")
execute("mview()")

Re: PyNeuron Model View Error while calling the Py Class

Posted: Tue Dec 27, 2011 1:20 am
by figoyouwei
Thanks, Ted ! The model view code is useful ~

I guess here the main Python-Neuron problem is that ... when you load a hoc by calling h.load_file("bla.hoc"), the neuron model is callable from hoc. For example, suppose the neuron is called MSN in original hoc implementation. Then you can call it directly using h.MSN.soma, bla...bla...

But in python when I declare in a python class self.soma = h.Section(name='soma'), hoc is not recognizing any section that is created, because soma is created in the python class.

So what shall I do in a python class to make my model neuron callable by hoc ?

Hopefully that makes you better understand the problem.

Re: PyNeuron Model View Error while calling the Py Class

Posted: Wed Dec 28, 2011 12:02 pm
by ted

Re: PyNeuron Model View Error while calling the Py Class

Posted: Wed Jan 04, 2012 9:17 pm
by hines
It should work now. Some bugs in ModelView were fixed to allow viewing the properties of python cells.
http://www.neuron.yale.edu/hg/neuron/nr ... 67b0758be5
Note that the string name of a python object does not help one obtain a reference to the object.