[Neuroimaging] [PySurfer] Brain's save_image method produces images with only background color
John Pellman
pellman.john at gmail.com
Fri Sep 16 17:59:26 EDT 2016
I'm running in a Miniconda environment using Python 2.7.12. The original
version numbers are slightly different from what I first had because I
tried to create a new environment. This is the output of *conda env export*
:
name: surfer
> channels: !!python/tuple
> - !!python/unicode 'defaults'
> dependencies:
> - apptools=4.2.1=py27_0
> - cairo=1.12.18=6
> - configobj=5.0.6=py27_0
> - envisage=4.4.0=py27_1
> - fontconfig=2.11.1=6
> - freetype=2.5.5=1
> - glib=2.43.0=1
> - harfbuzz=0.9.39=1
> - jpeg=8d=1
> - lcms=1.19=0
> - libffi=3.2.1=0
> - libgfortran=1.0=0
> - libpng=1.6.22=0
> - libxml2=2.9.2=0
> - mayavi=4.4.0=np19py27_0
> - mkl=11.3.3=0
> - numpy=1.9.3=py27_3
> - openssl=1.0.2h=1
> - pango=1.39.0=1
> - pil=1.1.7=py27_2
> - pip=8.1.2=py27_0
> - pixman=0.32.6=0
> - pyface=4.4.0=py27_0
> - pyqt=4.11.4=py27_4
> - python=2.7.12=1
> - qt=4.8.7=4
> - readline=6.2=2
> - scipy=0.15.1=np19py27_0
> - setuptools=26.1.1=py27_0
> - sip=4.18=py27_0
> - six=1.10.0=py27_0
> - sqlite=3.13.0=0
> - tk=8.5.18=0
> - traits=4.4.0=py27_0
> - traitsui=4.4.0=py27_0
> - vtk=5.10.1=py27_1
> - wheel=0.29.0=py27_0
> - wxpython=3.0.0.0=py27_2
> - zlib=1.2.8=3
> - pip:
> - backports.shutil-get-terminal-size==1.0.0
> - cycler==0.10.0
> - decorator==4.0.10
> - enum34==1.1.6
> - ipython==5.1.0
> - ipython-genutils==0.1.0
> - matplotlib==1.5.3
> - nibabel==2.1.0
> - nilearn==0.1.4.post1
> - pathlib2==2.1.0
> - pexpect==4.2.1
> - pickleshare==0.7.4
> - prompt-toolkit==1.0.7
> - ptyprocess==0.5.1
> - pygments==2.1.3
> - pyparsing==2.1.9
> - pysurfer==0.6
> - python-dateutil==2.5.3
> - pytz==2016.6.1
> - simplegeneric==0.8.1
> - traitlets==4.3.0
> - wcwidth==0.1.7
> - wxpython-common==3.0.0.0
> - xvfbwrapper==0.2.8
> prefix: /usr/local/bin/miniconda/envs/surfer
I've tried using Xvfb both with and without xvfbwrapper, but get the same
result both ways. I've also been getting the following GTK-related errors:
Gtk-Message: Failed to load module "gail"
Gtk-Message: Failed to load module "atk-bridge"
(mayavi_test.py:33137): Gtk-WARNING **: GModule
(/usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-ibus.so)
initialization check failed: GLib version too old (micro mismatch)
(mayavi_test.py:33137): Gtk-WARNING **: Loading IM context type 'ibus'
failed
Is Brain.save_image among the functions you use in headless mode regularly,
or is the class of plotting functions you're using more broad? If not,
which functions do you use?
On Fri, Sep 16, 2016 at 4:14 PM, Roan LaPlante <rlaplant at nmr.mgh.harvard.edu
> wrote:
>
> On Sep 16, 2016 4:13 PM, "Roan LaPlante" <aestrivex at gmail.com> wrote:
>
>> That's weird, I use xvfb with pysurfer to plot in a headless context
>> regularly.
>>
>> Have you confirmed that there is not a missing or outdated library
>> version? What python distribution are you running?
>>
>> On Sep 16, 2016 3:55 PM, "John Pellman" <pellman.john at gmail.com> wrote:
>>
>>> Running the basic visualization code for Pysurfer followed by
>>> Brain.save_image() gave the following results with when run with
>>> xvfbwrapper:
>>>
>>> On the server under x2go/nx : An all-black image.
>>> On the server under a regular ssh session : An all-black image.
>>> On my local computer: An all-black image.
>>>
>>> So it doesn't look like that's going to work. :/
>>>
>>> wxPython is also installed- is it possible that that is affecting the
>>> image rendering too?
>>>
>>> On Fri, Sep 16, 2016 at 2:36 PM, Roan LaPlante <
>>> rlaplant at nmr.mgh.harvard.edu> wrote:
>>>
>>>> If that's the problem, xvfb should still be a viable workaround in the
>>>> nx context, right?
>>>>
>>>> On Sep 16, 2016 12:30 PM, "Gael Varoquaux" <
>>>> gael.varoquaux at normalesup.org> wrote:
>>>>
>>>>> Nx has always been a problem with Mayavi (or actually VTK, which is the
>>>>> underlying technology). Basically, it interfers with the openGL
>>>>> contexts,
>>>>> and in some cases the buffer cannot be captured well. Hence the black
>>>>> image.
>>>>>
>>>>> IMHO, the bug is in NX or the mesa driver, or both.
>>>>>
>>>>> Gaël
>>>>>
>>>>> On Fri, Sep 16, 2016 at 12:00:15PM -0400, John Pellman wrote:
>>>>> > Pysurfer isn't running headless- it's using x2go, which is based
>>>>> upon the nx
>>>>> > protocol, a technology that improves the ability of X11 to function
>>>>> over a
>>>>> > network connection. Therefore, I don't think that Xvfb is related.
>>>>> xvfbwrapper
>>>>> > might be usable as a workaround, however.
>>>>>
>>>>> > As I mentioned in my last post, I traced the offending method back
>>>>> to mayavi.
>>>>> > I've opened an issue related to this here.
>>>>>
>>>>> > Kirstie- if you'd be willing to refer your sysadmin to this thread I
>>>>> think that
>>>>> > would be great, as I would be interested in hearing what theories or
>>>>> potential
>>>>> > fixes he/she might have for this issue as well.
>>>>>
>>>>> > --John
>>>>>
>>>>> > On Fri, Sep 16, 2016 at 5:43 AM, JB Poline <jbpoline at gmail.com>
>>>>> wrote:
>>>>>
>>>>> > That's a cool idea and package - thanks for pointing to this !
>>>>>
>>>>> > On 16 September 2016 at 02:40, Ariel Rokem <arokem at gmail.com>
>>>>> wrote:
>>>>>
>>>>>
>>>>> > On Thu, Sep 15, 2016 at 1:33 PM, Kirstie Whitaker <
>>>>> kw401 at cam.ac.uk>
>>>>> > wrote:
>>>>>
>>>>> > Hi John,
>>>>>
>>>>> > I'm travelling at the moment but I've had problems with
>>>>> pysurfer
>>>>> > showing beautiful brains on the screen but only saving a
>>>>> black box
>>>>> > to file. It happened right after our systems admin
>>>>> updated a few
>>>>> > things but I haven't been able to get a clear list from
>>>>> him of what
>>>>> > changed except: everything should work.
>>>>>
>>>>> > My point with this email is please do share back what you
>>>>> > learn.....even if it ends up being not a pysurfer
>>>>> problem. At the
>>>>> > moment my workaround is to move everything I do to a
>>>>> different
>>>>> > cluster that works!! Non efficient to say the least!
>>>>>
>>>>> > Thank you
>>>>> > Kirstie
>>>>>
>>>>> > Sent from my iPhone, please excuse any typos or
>>>>> excessive brevity
>>>>>
>>>>> > On 15 Sep 2016, at 12:44, John Pellman <
>>>>> pellman.john at gmail.com>
>>>>> > wrote:
>>>>>
>>>>>
>>>>> > I've had at this a little bit more and my current
>>>>> suspicion is
>>>>> > that this behavior is the result of an interaction
>>>>> between our
>>>>> > remote desktop service (x2go) and Mayavi.
>>>>>
>>>>> > I created a an identical Miniconda environment for
>>>>> Pysurfer on
>>>>> > both our server and my laptop and ran the following
>>>>> code to
>>>>> > test this theory:
>>>>>
>>>>>
>>>>> > # The Basic Visualization demo from the Pysurfer
>>>>> gallery.
>>>>> > from surfer import Brain
>>>>>
>>>>> > print(__doc__)
>>>>>
>>>>> > """
>>>>> > Define the three important variables.
>>>>> > Note that these are the first three positional
>>>>> arguments
>>>>> > in tksurfer (and pysurfer for that matter).
>>>>> > """
>>>>> > subject_id = 'fsaverage'
>>>>> > hemi = 'lh'
>>>>> > surface = 'inflated'
>>>>>
>>>>> > """
>>>>> > Call the Brain object constructor with these
>>>>> > parameters to initialize the visualization
>>>>> session.
>>>>> > """
>>>>> > brain = Brain(subject_id, hemi, surface)
>>>>>
>>>>> > # Save an image out to /tmp
>>>>> > print 'Saving out an image to /tmp using
>>>>> Brain.save_image.'
>>>>> > brain.save_image('/tmp/brain.png')
>>>>>
>>>>> > # Looking at just the screenshot method of
>>>>> pysurfer's Brain
>>>>> > object.
>>>>> > # This is called by save_image and is fed into
>>>>> > scipy.misc.imsave.
>>>>> > # If the boolean expression evaluated here is
>>>>> true, then
>>>>> > only a black
>>>>> > # background is being fed into scipy's
>>>>> misc.imsave method
>>>>> > for evaluation.
>>>>> > x = brain.screenshot()
>>>>> > print 'Test pysurfer\'s Brain.screenshot.'
>>>>> > if sum(x.flatten()==0)!=len(x.flatten()):
>>>>> > print 'Pass'
>>>>> > else:
>>>>> > print 'Fail'
>>>>>
>>>>> > # Looking at the Mayavi mlab.screenshot method.
>>>>> > # This is called by screenshot_single, which is
>>>>> called by
>>>>> > Brain's screenshot.
>>>>> > # If the boolean expression evaluated here is
>>>>> true, then
>>>>> > only a black
>>>>> > # background is being fed into Brain.screenshot()
>>>>> > from mayavi import mlab
>>>>> > x = mlab.screenshot(brain.brain_matrix[0,0]._f,
>>>>> 'rgb',
>>>>> > False)
>>>>> > print 'Test mayavi\'s mlab.screenshot'
>>>>> > if sum(x.flatten()==0)!=len(x.flatten()):
>>>>> > print 'Pass'
>>>>> > else:
>>>>> > print 'Fail'
>>>>>
>>>>>
>>>>> > On the server through an x2go session both
>>>>> Brain.screenshot and
>>>>> > mlab.screenshot failed to produce a non-blank image,
>>>>> while on
>>>>> > my laptop's local environment both of these methods
>>>>> did produce
>>>>> > the desired output (i.e., there were some nonzero
>>>>> outputs).
>>>>>
>>>>> > Since this doesn't seem to be an error with pysurfer
>>>>> in
>>>>> > particular, I'm going to proceed to see if anyone
>>>>> using Mayavi
>>>>> > with x2go or nx has encountered similar issues by
>>>>> querying
>>>>> > their forums / issue pages. I just wanted to leave
>>>>> this here
>>>>> > if someone else encounters the same issue in the
>>>>> future.
>>>>>
>>>>>
>>>>> > A shot in the dark: Could it be something to do with running
>>>>> headless?
>>>>> > Maybe running this under XVFB (e.g. through xvfbwrapper)
>>>>> would help?
>>>>>
>>>>> > Ariel
>>>>> >
>>>>>
>>>>> > --John
>>>>>
>>>>> > On Tue, Sep 13, 2016 at 1:24 PM, John Pellman <
>>>>> > pellman.john at gmail.com> wrote:
>>>>>
>>>>> > It looks like it might be related to the
>>>>> following issue
>>>>> > described at StackOverflow:
>>>>>
>>>>> > http://stackoverflow.com/questions/16543634/
>>>>> > mayavi-mlab-savefig-gives-an-empty-image
>>>>>
>>>>> > On Mon, Sep 12, 2016 at 2:00 PM, John Pellman <
>>>>> > pellman.john at gmail.com> wrote:
>>>>>
>>>>> > Hi all,
>>>>>
>>>>> > I'm encountering a peculiar Pysurfer error
>>>>> on our
>>>>> > server and I was wondering if anyone has
>>>>> encountered
>>>>> > anything similar or might have some insight
>>>>> into how I
>>>>> > can tackle it. Basically, when our
>>>>> researchers try to
>>>>> > save a png image using Brain.save_image() or
>>>>> > Brain.save_imageset() the images produced
>>>>> only contain
>>>>> > the background color (as you may have
>>>>> inferred from the
>>>>> > subject line). I've traced this back to
>>>>> Scipy method
>>>>> > (scipy.misc.imsave), but it looks like this
>>>>> would only
>>>>> > output an empty png if the image passed in
>>>>> were
>>>>> > completely zeroed out. Our setup uses the
>>>>> following
>>>>> > versions of pysurfer/its dependencies:
>>>>>
>>>>> > Numpy: 1.10.0.dev0+1fe98ff
>>>>> > Scipy: 0.17.0.dev0+f2f6e48
>>>>> > Ipython: 3.1.0
>>>>> > nibabel: 2.0.0
>>>>> > Mayavi: 4.4.2
>>>>> > matplotlib: 1.4.3
>>>>> > PIL: 1.1.7
>>>>> > Pysurfer: 0.5
>>>>>
>>>>> > This setup is running within a Miniconda
>>>>> environment
>>>>> > using Python 2.7.11. I'm uncertain if this
>>>>> is related,
>>>>> > but running the example code here produces
>>>>> the
>>>>> > following warning:
>>>>>
>>>>> > (ipython:20765): Gdk-WARNING **:
>>>>> /build/buildd/
>>>>> > gtk+2.0-2.24.27/gdk/x11/gdkdrawable-x11.c:952
>>>>> drawable
>>>>> > is not a pixmap or window
>>>>>
>>>>> > Any insight would be greatly appreciated.
>>>>>
>>>>> > Best,
>>>>> > John Pellman
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> > _______________________________________________
>>>>> > Neuroimaging mailing list
>>>>> > Neuroimaging at python.org
>>>>> > https://mail.python.org/mailm
>>>>> an/listinfo/neuroimaging
>>>>>
>>>>>
>>>>> > _______________________________________________
>>>>> > Neuroimaging mailing list
>>>>> > Neuroimaging at python.org
>>>>> > https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> > _______________________________________________
>>>>> > Neuroimaging mailing list
>>>>> > Neuroimaging at python.org
>>>>> > https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> > _______________________________________________
>>>>> > Neuroimaging mailing list
>>>>> > Neuroimaging at python.org
>>>>> > https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> > _______________________________________________
>>>>> > Neuroimaging mailing list
>>>>> > Neuroimaging at python.org
>>>>> > https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>
>>>>>
>>>>> --
>>>>> Gael Varoquaux
>>>>> Researcher, INRIA Parietal
>>>>> NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France
>>>>> Phone: ++ 33-1-69-08-79-68
>>>>> http://gael-varoquaux.info
>>>>> http://twitter.com/GaelVaroquaux
>>>>> _______________________________________________
>>>>> Neuroimaging mailing list
>>>>> Neuroimaging at python.org
>>>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>
>>>>>
>>>>>
>>>>> The information in this e-mail is intended only for the person to whom
>>>>> it is
>>>>> addressed. If you believe this e-mail was sent to you in error and the
>>>>> e-mail
>>>>> contains patient information, please contact the Partners Compliance
>>>>> HelpLine at
>>>>> http://www.partners.org/complianceline . If the e-mail was sent to
>>>>> you in error
>>>>> but does not contain patient information, please contact the sender
>>>>> and properly
>>>>> dispose of the e-mail.
>>>>>
>>>>>
>>>> _______________________________________________
>>>> Neuroimaging mailing list
>>>> Neuroimaging at python.org
>>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Neuroimaging mailing list
>>> Neuroimaging at python.org
>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>
>>>
>>> The information in this e-mail is intended only for the person to whom
>>> it is
>>> addressed. If you believe this e-mail was sent to you in error and the
>>> e-mail
>>> contains patient information, please contact the Partners Compliance
>>> HelpLine at
>>> http://www.partners.org/complianceline . If the e-mail was sent to you
>>> in error
>>> but does not contain patient information, please contact the sender and
>>> properly
>>> dispose of the e-mail.
>>>
>>>
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20160916/7ad5544b/attachment-0001.html>
More information about the Neuroimaging
mailing list