[Neuroimaging] [PySurfer] Brain's save_image method produces images with only background color
Roan LaPlante
rlaplant at nmr.mgh.harvard.edu
Fri Sep 16 16:14:32 EDT 2016
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/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
>>>>
>>>>
>>>>
>>>>
>>>> > _______________________________________________
>>>> > 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.
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20160916/d7055033/attachment.html>
More information about the Neuroimaging
mailing list