RuntimeError: _image_module

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@...734...:~/install/matplotlib-0.83.2/examples# rm -rf /root/.matplotlib/tex.cache

root@...734...:~/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@...734...:~/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

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.
#