|
From: Nils W. <nw...@me...> - 2005-08-11 10:38:20
Attachments:
ding.py
|
Hi all,
Any pointer to resolve the problem within ding.py (see attachment) would
be appreciated.
I am using
>>> matplotlib.__version__
'0.84cvs'
Traceback (most recent call last):
File
"/usr/lib/python2.3/site-packages/matplotlib/backends/backend_gtk.py",
line 311, in expose_event
self._render_figure(self._pixmap, w, h)
File
"/usr/lib/python2.3/site-packages/matplotlib/backends/backend_gtkagg.py",
line 70, in _render_figure
FigureCanvasAgg.draw(self)
File
"/usr/lib/python2.3/site-packages/matplotlib/backends/backend_agg.py",
line 381, in draw
self.figure.draw(renderer)
File "/usr/lib/python2.3/site-packages/matplotlib/figure.py", line
511, in draw
for a in self.axes: a.draw(renderer)
File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 1389,
in draw
self.xaxis.draw(renderer)
File "/usr/lib/python2.3/site-packages/matplotlib/axis.py", line 552,
in draw
tick.draw(renderer)
File "/usr/lib/python2.3/site-packages/matplotlib/axis.py", line 151,
in draw
if self.label1On: self.label1.draw(renderer)
File "/usr/lib/python2.3/site-packages/matplotlib/text.py", line 848,
in draw
self._mytext.draw(renderer)
File "/usr/lib/python2.3/site-packages/matplotlib/text.py", line 335,
in draw
bbox, info = self._get_layout(renderer)
File "/usr/lib/python2.3/site-packages/matplotlib/text.py", line 184,
in _get_layout
w,h = renderer.get_text_width_height(
File
"/usr/lib/python2.3/site-packages/matplotlib/backends/backend_agg.py",
line 241, in get_text_width_height
Z = self.texmanager.get_rgba(s, size, dpi, rgb)
File "/usr/lib/python2.3/site-packages/matplotlib/texmanager.py", line
298, in get_rgba
X = readpng(pngfile)
RuntimeError: _image_module::readpng could not open PNG file
/home/nwagner/.matplotlib/tex.cache/2c6e169d72c80df1858b02af79bf8864_96.png
for reading
Nils
|
|
From: Les S. <sch...@op...> - 2005-08-17 17:34:43
|
John Hunter wrote:
> Try installing the latest release (0.83.2),
> removing your ~/.matplotlib/tex.cache, and rerunning your script.
i still get the problem:
<<<<<<<<<<<<
root@tma-1:~/install/matplotlib-0.83.2/examples# rm -rf
/root/.matplotlib/tex.cache
root@tma-1:~/install/matplotlib-0.83.2/examples# python2.4 tex_demo.py
Traceback (most recent call last):
File "tex_demo.py", line 31, in ?
savefig('tex_demo.ps')
File "/usr/lib/python2.4/site-packages/pylab.py", line 773, in savefig
File "/usr/lib/python2.4/site-packages/matplotlib/figure.py", line
636, in savefig
self.canvas.print_figure(*args, **kwargs)
File
"/usr/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py",
line 179, in print_figure
agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)
File
"/usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py",
line 444, in print_figure
self.draw()
File
"/usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py",
line 381, in draw
self.figure.draw(renderer)
File "/usr/lib/python2.4/site-packages/matplotlib/figure.py", line
511, in draw
for a in self.axes: a.draw(renderer)
File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1387,
in draw
self.xaxis.draw(renderer)
File "/usr/lib/python2.4/site-packages/matplotlib/axis.py", line 552,
in draw
tick.draw(renderer)
File "/usr/lib/python2.4/site-packages/matplotlib/axis.py", line 151,
in draw
if self.label1On: self.label1.draw(renderer)
File "/usr/lib/python2.4/site-packages/matplotlib/text.py", line 848,
in draw
self._mytext.draw(renderer)
File "/usr/lib/python2.4/site-packages/matplotlib/text.py", line 335,
in draw
bbox, info = self._get_layout(renderer)
File "/usr/lib/python2.4/site-packages/matplotlib/text.py", line 184,
in _get_layout
w,h = renderer.get_text_width_height(
File
"/usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py",
line 241, in get_text_width_height
Z = self.texmanager.get_rgba(s, size, dpi, rgb)
File "/usr/lib/python2.4/site-packages/matplotlib/texmanager.py", line
296, in get_rgba
X = readpng(pngfile)
RuntimeError: _image_module::readpng could not open PNG file
/root/.matplotlib/tex.cache/30565a8911a6bb487e3745c0ea3c8224_120.png for
reading
root@tma-1:~/install/matplotlib-0.83.2/examples# ls -l
/root/.matplotlib/tex.cache/
total 8
-rw-r--r-- 1 root root 204 Aug 17 12:51
30565a8911a6bb487e3745c0ea3c8224.dvi
-rw-r--r-- 1 root root 160 Aug 17 12:51
30565a8911a6bb487e3745c0ea3c8224.tex
>>>>>>>>>>
the problem -- on the surface -- appears to be that readpng is looking
for an existing file, but with _120 prepended to the . extension.
les schaffer
|
|
From: John H. <jdh...@ac...> - 2005-08-18 18:27:17
|
>>>>> "Les" == Les Schaffer <sch...@op...> writes:
>> Have you satisfied the requirements for usetex, eg, what does
>> this report
>>
>> > dvipng --version
Les> ahem ... all better after 'apt-get install dvipng'
Les> thnx
No problem. As penance, you can write the patch to texmanager.py or
__init__,py (on the usetex rc param check) that issues a proper
warning if dvipng is not installed. I personally think it should be
made in matplotlib.texmanager.TexManager.get_dvipng_version. Frankly,
I don't understand why the current implementation failed
def get_dvipng_version(self):
if self.dvipngVersion is not None: return self.dvipngVersion
sin, sout = os.popen2('dvipng --version')
for line in sout.readlines():
if line.startswith('dvipng '):
self.dvipngVersion = line.split()[-1]
return self.dvipngVersion
raise RuntimeError('Could not obtain dvipng version')
OK, on a second read of the texmanager code, I do understand.
Apparently the error is that this function is not called by make_png.
I think all that is needed is to add a version check to make_png
which calls get_dvipng_version which will raise if dvipng is not
defined. Send patches to me, to this thread, to the devel list, or to
the sourceforge site.
Thanks!
JDH
|
|
From: John H. <jdh...@ac...> - 2005-08-18 19:57:26
|
>>>>> "Les" == Les Schaffer <sch...@op...> writes:
Les> John Hunter wrote:
>> Try installing the latest release (0.83.2), removing your
>> ~/.matplotlib/tex.cache, and rerunning your script.
Les> i still get the problem:
Have you satisfied the requirements for usetex, eg, what does this
report
> dvipng --version
JDH
|
|
From: Graeme O'K. <gj...@ne...> - 2005-08-19 05:38:40
|
Hi,
is there a way to get an image of a patch? I'd like to use patches to
display Regions Of Interest and
also use then use them as masks on the image for subsequent region
based analysis.
regards,
Graeme
===== code snippet ======
#!/usr/bin/env python
import wasabi, ugm
import pylab
#
# 22-frames * 90-slices * 128-y * 128-x
#
dy = ugm.ugm('dy22.img')
#
# grab the 20th frame
#
vol = dy.vol([20])
#
# returns a series of roi's that are defined as a set of vertices of
a polygon
# eg.
# roi['cerebellum'] = numarray.array([[x0,y0], [x1,y1], ...., [xN, yN]])
# roi['caudate'] ...
#
roi = wasabi.roi('p2873s0_HAW_emdy22.xml')
pylab.figure()
ax = pylab.gca()
n = 0
col = 'rgbcmyk'
p = []
for fld in roi.keys() :
#
# draw the polygon regions as patches with transparency
#
p.append(ax.fill(roi[fld][:,0], roi[fld][:,1], col[n],
alpha=0.5, linewidth=0))
pylab.hold(True)
n += 1
#end for
pylab.imshow(vol[45,:,:], cmap = pylab.cm.hot, origin = 'lower')
print p
#
# is there a way to 'get' an array of pixels set in the patches p[0],
p[1] so that they can be used as masks
# on the image.
#
|
|
From: John H. <jdh...@ac...> - 2005-08-11 13:37:36
|
>>>>> "Nils" == Nils Wagner <nw...@me...> writes:
Nils> Hi all, Any pointer to resolve the problem within ding.py
Nils> (see attachment) would be appreciated.
Nils> I am using
>>>> matplotlib.__version__
Nils> '0.84cvs'
I do not recommend that you try and use tex support with matplotlib
CVS, since it is currently broken with some recent changes I made to
the image module, though I think the cause of your problem lies
elsewhere. Also, there is a problem I am experiencing trying to make
external calls (eg to latex) under GTKAgg, which I think may be
related to threading. Try installing the latest release (0.83.2),
removing your ~/.matplotlib/tex.cache, and rerunning your script.
JDH
|