Page 1 of 1

using neuron.h.Graph() through python

Posted: Thu Feb 11, 2010 7:14 pm
by adamimos
Hey, I'm trying to use the graphing using neuron.h.Graph() as opposed to converting the data to a numpy array and then using pylab. In order to test things out I'm trying to use the most simple code to make a graph (which I pretty much copied from the NEURON and Python paper):

Code: Select all

from neuron import h

soma = h.Section()
soma.insert('pas')
g=h.Graph()
g.size(0,5,-80,40)
g.addvar('v(0.5)', sec = soma)
h.dt = 0.025
tstop = 5
vinit = -65

def initialize():
    h.finitialize(vinit)
    h.fcurrent()

def integrate():
    g.begin()
    while h.t< tstop:
        h.fadvance()
        g.plot(h.t)
    g.flush()

initialize()
integrate()


raw_input("hi")

what happens is that I get a square window popping up that is blank (it's just white and blank). Any idea what is going on? Thanks.

Re: using neuron.h.Graph() through python

Posted: Fri Feb 12, 2010 8:02 pm
by adamimos
I hate to just bombard with questions. But here is a more important problem: When i try to import the GUI i get this:

Code: Select all

In [1]: from neuron import gui
MPI_Initialized==false, disabling MPI functionality.
NEURON -- Release 7.1 (359:7f113b76a94b) 2009-10-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

python(73824,0x7fff7004dbe0) malloc: *** error for object 0x1026d04b8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap
Similarly,

Code: Select all

In [1]: import neuron
MPI_Initialized==false, disabling MPI functionality.
NEURON -- Release 7.1 (359:7f113b76a94b) 2009-10-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html


In [2]: neuron.h.xopen("$(NEURONHOME)/lib/hoc/stdrun.hoc")
python(75273,0x7fff7004dbe0) malloc: *** error for object 0x1028dee98: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap

If anyone has any idea what is going on that would be greatly appreciated.

Re: using neuron.h.Graph() through python

Posted: Fri Feb 12, 2010 10:05 pm
by ted
adamimos wrote:Hey, I'm trying to use the graphing using neuron.h.Graph() as opposed to converting the data to a numpy array and then using pylab.
. . .
what happens is that I get a square window popping up that is blank (it's just white and blank). Any idea what is going on? Thanks.
Beats the heck out of me. I just tried your code and it worked perfectly well, right down to printing "hi" in the xterm and waiting for a user reply before returning to the >>> prompt. I see a typical NEURON Graph that shows a plot of v(0.5), which starts from an initial value of -65 mV at t=0 and decays monoexponentially toward -70 mV (e_pas).

But I'm using Linux, and I suspect you aren't. Do I correctly guess that you're using NEURON under MSWin? If so, which version of MSWin?

Re: using neuron.h.Graph() through python

Posted: Fri Feb 12, 2010 10:13 pm
by ted
adamimos wrote:I hate to just bombard with questions. But here is a more important problem: When i try to import the GUI i get this
I don't see any of this--no error msgs at all.

If you're using MSWin, maybe that's where the problem lies. If you haven't already said so, which version of what OS are you using?

If it's MSWin, I see that a new alpha installer came out just day before yesterday--at
http://www.neuron.yale.edu/ftp/neuron/versions/alpha/
look for
nrn-7.2.alpha-400-setup.exe
Seems like the problems you're encountering would be fairly common, hence likely to have been fixed in this more recent installer.

Re: using neuron.h.Graph() through python

Posted: Sat Feb 13, 2010 2:58 pm
by adamimos
hey, thanks for the reply. I'm actually using OS X.

Re: using neuron.h.Graph() through python

Posted: Sun Feb 14, 2010 4:50 am
by adamimos
Well in any case now, I've gotten acces to a linux box, so I should be good. However, it'd be helpful if anyone knew what was going on. Thanks.


I'm not sure if this helps solve the mystery at all: every once in a while when I try "from neuron import gui" in python it will actually work, and I will get the main menu bar popping up. However, the vast majority of the time I get that checksum error. Strange...

Re: using neuron.h.Graph() through python

Posted: Mon Feb 15, 2010 8:52 am
by hines
I can't reproduce the problem on my osx 10.4 i686 machine. Both the
standard 7.1 distribution and my latest sources are working for your
test case.

Re: using neuron.h.Graph() through python

Posted: Wed Feb 17, 2010 4:24 pm
by adamimos
hines wrote:I can't reproduce the problem on my osx 10.4 i686 machine. Both the
standard 7.1 distribution and my latest sources are working for your
test case.
no problem, thanks for your help. after playing around with it a bit more, if you do from neuron import * at the begining, and then do from neuron import gui at the end, it seems to work. I'm not sure exactly what the problem is, but this code works:

Code: Select all

from neuron import *

soma = h.Section()

soma.insert('pas')
g=h.Graph()
g.size(0,5,-80,-40)
g.addvar('v(0.5)', sec = soma)
h.dt = 0.025
tstop = 5
vinit = -65

def initialize():
    h.finitialize(vinit)
    h.fcurrent()

def integrate():
    g.begin()
    while h.t< tstop:
        h.fadvance()
        g.plot(h.t)
    g.flush()

initialize()
integrate()


from neuron import gui


raw_input("hi")

Re: using neuron.h.Graph() through python

Posted: Fri Dec 28, 2012 8:55 am
by patoorio
Hi,

I want to re-float this issue because I'm having it with Ubuntu 12.04 x64, with python 2.7.3 and Neuron 7.2. It also happens with Debian (latest 64bit), python 2.6.6 and neuron 7.2. In both cases I have spyder (2.1.9 in Ubuntu; 2.1.11 in Debian) but it also happens in ipython.
I have to say that successfully went to the process of compiling neuron as a python module, having to install one or another package until it compiled correctly. Maybe I'm still missing some package, library or module?
I know I can go with pylab's plotting facilities, but I want to know that everything else works as it should.
BTW, I'm using exaclty the same code as in the 'Python + Neuron' paper (Front Neurosci); i just added the raw_input line at the end

Best Regards

Re: using neuron.h.Graph() through python

Posted: Fri May 03, 2013 10:46 am
by patoorio
Solved by adding

Code: Select all

h.graphList[0].append(g)
That worked for me.

Also, the behavior of the plot is better if I use

Code: Select all

g.size(0,h.tstop,-80,40)
In this way the time scale will adjust automatically as tstop is changed.

Regards