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 »

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 »

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: 6384
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 »

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 »

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: 6384
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 »

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

Re: PyNeuron Model View Error while calling the Py Class

Post 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.
Post Reply