PyNeuron Model View Error while calling the Py Class

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

Moderator: hines

Post Reply
figoyouwei
Posts: 41
Joined: Sun Aug 08, 2010 11:09 am

PyNeuron Model View Error while calling the Py Class

Post by figoyouwei » Wed Dec 14, 2011 6:54 am

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

figoyouwei
Posts: 41
Joined: Sun Aug 08, 2010 11:09 am

Re: PyNeuron Model View Error while calling the Py Class

Post by figoyouwei » Thu Dec 15, 2011 11:06 am

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

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

Re: PyNeuron Model View Error while calling the Py Class

Post by ted » Wed Dec 21, 2011 2:22 pm

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()")

figoyouwei
Posts: 41
Joined: Sun Aug 08, 2010 11:09 am

Re: PyNeuron Model View Error while calling the Py Class

Post by figoyouwei » Tue Dec 27, 2011 1:20 am

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.

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

Re: PyNeuron Model View Error while calling the Py Class

Post by ted » Wed Dec 28, 2011 12:02 pm


hines
Site Admin
Posts: 1575
Joined: Wed May 18, 2005 3:32 pm

Re: PyNeuron Model View Error while calling the Py Class

Post by hines » Wed Jan 04, 2012 9:17 pm

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.

Post Reply