Page 1 of 1

Plot what... from a Python class

Posted: Fri Mar 11, 2011 3:20 am
by Nin
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.

Re: Plot what... from a Python class

Posted: Mon Mar 14, 2011 5:30 pm
by hines
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.

Re: Plot what... from a Python class

Posted: Tue Mar 15, 2011 10:58 am
by Nin
This might help, I wanted it just simply to test that both hoc and python routines give the same results!