Plot what... from a Python class

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

Moderator: hines

Post Reply
Nin
Posts: 41
Joined: Thu May 03, 2007 4:04 pm
Location: Institute of Science and Technology (IST Austria)
Contact:

Plot what... from a Python class

Post by Nin » Fri Mar 11, 2011 3:20 am

Hi everybody

I created a cell class with Python and wanted to use the Neuron gui, so that I can play around with some parameters. In principle this is an easy job for the current accessed section, but if I want to see other compartments, I have to change the currently accessed section all the time.

In this class

Code: Select all

from neuron import h

class FooCell(object):
    def __init__(self, ndend):
        """ simple cell with a soma and ndend dendrites """
        self.soma = h.Section(name = 'soma', cell = self)
        
        self.dend = list()

        for dend in range(ndend):
            myname = 'dend%d'%dend
            self.dend.append(h.Section(name = myname, cell = self))
        
        # connect dendrites
        self.dend[0].connect(self.soma,1, 0 )
        for i in range(1,ndend):
            self.dend[i].connect(self.dend[i-1], 1, 0)


          
I type in the console

Code: Select all

>>> from neuron import h, gui
>>>  mycell = FooCell(ndend=10)
>>> h.cas().name()
>>> <foo.FooCell object at 0xb6cf4bcc>.soma'
I was wondering if it is possible to access some other compartments easily via the Neuron gui. For example, in voltage axis, I can not choose compartments other than the currently accessed section. Would it be possible to see simulation in mycell.dend[4](x) and mycell.soma simultaneously? (without writing a Matplotlib routine for that)

Thanks in advance.

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

Re: Plot what... from a Python class

Post by hines » Mon Mar 14, 2011 5:30 pm

objref p
p = new PythonObject()

then you ought to be able to type
p.mycell.dend[4](.5)
into a "Plot What" field editor.
Unfortunately, I do not yet have a way of building lists for the symbol chooser that
involve Python objects. I'm still considering various possibilities.

Nin
Posts: 41
Joined: Thu May 03, 2007 4:04 pm
Location: Institute of Science and Technology (IST Austria)
Contact:

Re: Plot what... from a Python class

Post by Nin » Tue Mar 15, 2011 10:58 am

This might help, I wanted it just simply to test that both hoc and python routines give the same results!

Post Reply