nipy / PySurfer

Cortical neuroimaging visualization in Python
https://pysurfer.github.io/
BSD 3-Clause "New" or "Revised" License
240 stars 97 forks source link

tvtk displays empty then crashes #190

Closed bcmcpher closed 4 years ago

bcmcpher commented 7 years ago

I am trying to run a very basic example:

from surfer import Brain brain = Brain('bcmcpher', 'lh', 'inflated', subjects_dir='/home/bcmcpher/Documents/MyBrain/freesurfer')

but the tvtk(mayavi?) window is empty when it opens and crashes python with you click in it.

Within ipython when loading from pysurfer: Qt: Session management error: Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed

tvtk window crash: This window might be busy and is not responding. Do you want to terminate this application?

If I login as root I can get the display, but with a large number of warnings. (ipython:4796): Gdk-WARNING **: /home/jmm/scratch/gtk/gtk+2.0-2.24.25/gdk/x11/gdkdrawable-x11.c:952 drawable is not a pixmap or window

I have produced this error on: Debian 8 with pysurfer from neurodebian Debian 8 with pysurfer installed in python 2 and python 3 conda environments Ubuntu 16.04 w/ neurodebian and anaconda installations

FreeSurfer 6 is installed on both machines. I have been able to trace most of the errors to Qt not being defined correctly / having appropriate X access, but the fixes I have found are inconsistent and I am not going to randomly change display settings. Do you have any ideas?

Thanks, Brent McPherson

mwaskom commented 7 years ago

Can you say a bit more about how you're running the code? i.e. are you in terminal python, IPython, Jupyter notebook, etc.? Also how did you install mayavi and its dependencies? For debugging it might be good to try to work with a basic mayavi demo (e.g. here).

bcmcpher commented 7 years ago

I've been running this in ipython interactively from the terminal and calling it as a script (ipython test.py). The system mayavi is from the repos (Mayavi2, 4.3.1-3.1 in Debian), but I also installed it through anaconda as well (Mayavi 4.5.0).

bcmcpher@debian:~/Projects/pysurfer# mayavi2 --version Mayavi 4.3.1

(pysurfer) bcmcpher@debian:~/Projects/pysurfer$ mayavi2 --version Mayavi 4.5.0

That demo runs fine and provides an interactive output. I get the two warnings posted below:

(pysurfer) bcmcpher@debian:~/Projects/pysurfer$ ipython mayavi_test.py Qt: Session management error: Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed libpng warning: iCCP: known incorrect sRGB profile

bcmcpher commented 7 years ago

On Ubuntu we can get correct displays by importing mayavi first (adding "import mayavi" to the minimal example above). But according to the documentation / examples this shouldn't be necessary. And this doesn't fix the problem on Debian.

When it successfully runs on Ubuntu, the mayavi import returns: Changing backend for Qt to Mayavi

While on Debian I still receive the previous error: Qt: Session management error: Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed

When I try and launch ipython with a Qt gui (ipython --gui=qt test.py), I get a very long traceback with this message: ValueError: API 'QDate' has already been set to version 1

At this point I can tell this is a Qt problem, I don't understand what could be missing to cause the difference in how the packages are imported because they are both anaconda environments.

mwaskom commented 7 years ago

FWIW on Ubuntu 16.04 I don't have any of these problems. e.g. if I go to the examples folder in the pysurfer distribution and run ipython plot_basics.py thing run fine (it immediately exits because nothing in that script blocks, but I don't get any errors or warnings).

My guess would be that in mixing mayavi (and its dependencies) from system installs and anaconda things are crossed somewhere. I've also found that the conda mayavi recipe is not always fully complete — it's possible you're pulling in a different VTK than you should be, or maybe another dependency that wasn't an issue for me there but is for you.

mwaskom commented 7 years ago

For reference, here's what I have installed:

[~]$ conda list 'pysurfer|mayavi|qt|vtk|ipython'
# packages in environment at /home/mwaskom/anaconda2:
#
ipython                   5.2.2                    py27_0    conda-forge
ipython_genutils          0.1.0                    py27_0  
mayavi                    4.5.0               np111py27_1    conda-forge
pyqt                      4.11.4                   py27_3  
pysurfer                  0.6                       <pip>
qt                        4.8.7                         3  
qtconsole                 4.2.1                    py27_0  
qtpy                      1.0.2                    py27_0  
vtk                       7.1.0                    py27_2    conda-forge
larsoner commented 6 years ago

Closing this as a Mayavi bug. Feel free to reopen if you can successfully the Mayavi code examples, which would indicate that the problem is ours.

rmarren1 commented 6 years ago

I am having a similar issue when using ipython or notebooks. I can run the Mayavi examples fine: image but when I try to run the PySurfer example, I get a blank gray box: screenshot_2017-10-08_12-33-40 and when I try to close the blank gray box, the window crashes.

When I run the same code in a normal python interactive session, it works just fine

screenshot_2017-10-08_12-46-38

I am using fsfast tutorial data from here: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/Data

System information:

ryan@galliumos:~/Code/lemur/docs/rmarren1/weekly$ screenfetch
                          ./+o+-       ryan@galliumos
                  yyyyy- -yyyyyy+      OS: Ubuntu 16.04 xenial
               ://+//////-yyyyyyo      Kernel: x86_64 Linux 4.9.4-galliumos-braswell
           .++ .:/++++++/-.+sss/`      Uptime: 1d 13h 29m
         .:++o:  /++++++++/:--:/-      Packages: 1722
        o:+o+:++.`..```.-/oo+++++/     Shell: bash 4.3.48
       .:+o:+o/.          `+sssoo+/    Resolution: 1920x1080
  .++/+:+oo+o:`             /sssooo.   DE: XFCE
 /+++//+:`oo+o               /::--:.   WM: Xfwm4
 \+/+o+++`o++o               ++////.   WM Theme: Arc-Darker-GalliumOS
  .++.o+++oo+:`             /dddhhh.   GTK Theme: Arc-GalliumOS [GTK2]
       .+.o+oo:.          `oddhhhh+    Icon Theme: Numix-Circle-GalliumOS
        \+.++o+o``-````.:ohdhhhhh+     Font: Roboto 10
         `:o+++ `ohhhhhhhhyo++os:      CPU: Intel Celeron CPU N3160 @ 1.601GHz
           .o:`.syhhhhhhh/.oo++o`      RAM: 2618MiB / 3900MiB
               /osyyyyyyo++ooo+++/    
                   ````` +oo+++o\:    
                          `oo++.      
ryan@galliumos:~/Code/lemur/docs/rmarren1/weekly$ pip freeze
alabaster==0.7.10
apptools==4.4.0
Babel==2.5.1
backports-abc==0.5
backports.shutil-get-terminal-size==1.0.0
bleach==2.1.1
certifi==2017.7.27.1
chardet==3.0.4
configobj==5.0.6
configparser==3.5.0
cycler==0.10.0
decorator==4.1.2
docutils==0.14
entrypoints==0.2.3
enum34==1.1.6
functools32==3.2.3.post2
html5lib==1.0b10
idna==2.6
imagesize==0.7.1
ipykernel==4.6.1
ipython==5.5.0
ipython-genutils==0.2.0
ipywidgets==7.0.1
Jinja2==2.9.6
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.1.0
jupyter-console==5.2.0
jupyter-core==4.3.0
MarkupSafe==1.0
matplotlib==2.0.2
mayavi==4.5.0
mistune==0.7.4
mne==0.14.1
nbconvert==5.3.1
nbformat==4.4.0
nibabel==2.1.0
notebook==5.1.0
numpy==1.13.3
pandocfilters==1.4.2
pathlib2==2.3.0
pexpect==4.2.1
pickleshare==0.7.4
prompt-toolkit==1.0.15
ptyprocess==0.5.2
pycrypto==2.6.1
pyface==5.1.0
Pygments==2.2.0
pyparsing==2.2.0
pysurfer==0.8.0
python-dateutil==2.6.1
pytz==2017.2
pyzmq==16.0.2
qtconsole==4.3.1
requests==2.18.4
scandir==1.6
scipy==0.19.1
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.11.0
snowballstemmer==1.2.1
Sphinx==1.6.4
sphinxcontrib-websupport==1.0.1
subprocess32==3.2.7
terminado==0.6
testpath==0.3.1
tornado==4.5.2
traitlets==4.3.2
traits==4.6.0
traitsui==5.1.0
typing==3.6.2
urllib3==1.22
VTK==5.10.1
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.0.3
larsoner commented 6 years ago

Are you running conda? If so can you export an environment.yml file?

rmarren1 commented 6 years ago

Not using conda, everything installed through pip

mwaskom commented 6 years ago

I think you need to activate the event loop in IPython (e.g. %gui qt).

larsoner commented 4 years ago

Closing since I'm assuming this has been fixed by changes to GUI event handling and/or the suggestion to start an event loop in interactive mode