Timothy Lillicrap
unread,Mar 6, 2012, 10:18:23 AM3/6/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to glumpy-users
Hi There,
I'm trying to figure out a way to use a glumpy figure, then once i've
had the user interact with it, i want to carry on with some regular
python code. At the moment, every time I try to get rid of the glumpy
figure, the whole process dies.
I saw the old post about using window.exit() but this doesn't seem to
work for me. I've included a basic example at the end where, if the
user presses 'q' the program would ideally carry on and execute the
code after fig.show().
Is there an easy fix for this?
Tim.
ps, Once again, thank you for the ongoing help. In case you're
interested, I thought I'd write to tell you briefly what I'm trying to
do with glumpy. I work in a neuroscience lab in the Pharmacology
Dept. at Oxford. We collect a lot of image data of neural activity on
microscopes (using 2photon calcium imaging). I'm building tools to
register these images to counter small movements of the tissue/
microscope. There are of course automated tools for image
registration/alignment, but we have found these to be generally
inferior to good manual alignments. At the moment even the tools for
manual alignment are quite crude though, and I'm hoping to make a much
better interface for users. I'm hoping to eventually release the
software on an open license for other neuroscience labs to use.
################################################################
################################################################
import numpy, glumpy
import Image
import pdb
import numpy as np
import OpenGL
import OpenGL.GL as gl
import OpenGL.GLU as glu
import OpenGL.GLUT as glut
refimg = np.random.uniform(0,1, (512,512,2)).astype(np.float32)
img = np.ones((100,100,4)).astype(np.float32)
img *= (0,0,1.,.5)
fig = glumpy.figure( (512,512) )
grefimg = glumpy.Image(refimg)
image = glumpy.Image(img)
image.x = 0.
image.y = 0.
grefimg.x = 0.
grefimg.y = 0.
@fig.event
def on_init():
print 'Inititalization'
@fig.event
def on_draw():
print 'Drawing requested'
fig.clear()
gl.glEnable( gl.GL_BLEND )
gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA )
grefimg.update()
grefimg.draw(grefimg.x,grefimg.y,
0.,width=fig.width,height=fig.height)
image.draw(image.x,image.y,0.,width=fig.width/2.,height=fig.height/
2.)
@fig.event
def on_mouse_motion(x, y, dx, dy):
print 'Mouse motion (x=%.1f, y=%.1f, dx=%.1f, dy=%.1f)' % (x,y,dx,dy)
@fig.event
def on_mouse_drag(x, y, dx, dy, button):
print 'Mouse drag (x=%.1f, y=%.1f, dx=%.1f, dy=%.1f, button=%d)' %
(x,y,dx,dy,button)
image.x = image.x + dx
image.y = image.y + dy
fig.redraw()
@fig.event
def on_key_release(symbol, modifiers):
print 'Key released (symbol=%s, modifiers=%s)'% (symbol,modifiers)
if (symbol == 113):
print 'user exit requested...'
fig.window.hide()
fig.window.stop()
# fig.window.exit()
fig.show()
print 'the program continued as desired...'