nipy / PySurfer

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

Pysurfer basic example does not execute. #142

Closed TheChymera closed 7 years ago

TheChymera commented 8 years ago

I am trying to run this script from the pysurfer example 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)

This fails with

None
Traceback (most recent call last):
  File "/home/chymera/test.py", line 18, in <module>
    brain = Brain(subject_id, hemi, surface)
  File "/usr/lib64/python2.7/site-packages/surfer/viz.py", line 356, in __init__
    subjects_dir = _get_subjects_dir(subjects_dir=subjects_dir)
  File "/usr/lib64/python2.7/site-packages/surfer/io.py", line 35, in _get_subjects_dir
    raise ValueError('The subjects directory has to be specified '
ValueError: The subjects directory has to be specified using either the subjects_dir parameter or the SUBJECTS_DIR environment variable.
[Finished in 1.052s]

Can you help me out? I remember I was told here before that I really really need Freesurfer for Pysurfer to work. is that why I am getting this issue? is there any way to make this basic example work without Freesurfer?

mwaskom commented 8 years ago

No, you need Freesurfer. Sorry.

TheChymera commented 8 years ago

@mwaskom and that is what is causing this issue, right?

mwaskom commented 8 years ago

Well the issue is specifically caused by the fact that you did not either a) have a SUBJECTS_DIR environment variable declared or b) pass a path to the subjects_dir parameter of that function. However, just declaring the variable or giving the path won't fix the issue, as you also need to have it populated properly with all of the Freesurfer-based files that PySurfer needs to work.

caglorithm commented 8 years ago

For further reference: You have to install Freesurfer from http://freesurfer.net/ first, then either set the environment variable SUBJECTS_DIR or you call the Brain class with something like brain = Brain(..., subjects_dir="/Applications/freesurfer/subjects/")

lrq3000 commented 8 years ago

I was in the same situation as @TheChymera : running Windows, I didn't have access to FreeSurfer, and pysurfer didn't work without an obvious error telling me that it was because of missing FreeSurfer.

I now have NeuroDebian running in a VirtualBox VM and inside I installed FreeSurfer and Anaconda 4 (with Python 2.7) and all the dependencies required to run pysurfer. But it doesn't. Or rather, it does, but the basic example opens an empty grey window that becomes unresponsive. Nothing is shown inside at all.

Any idea on how to debug that? It seems the issue can be from mayavi, but I don't know enough about mayavi to test this hypothesis.

lrq3000 commented 8 years ago

Ok, I spent the whole day debugging the issue, and did not find a solution. The issue is already known with Mayavi:

Display bugs: Mayavi, and VTK, heavily use hardware rendering, as a result are very sensitive to hardware rendering bugs. Common issues include surfaces showing up as black instead of colored (mostly on windows or in virtual machines, I believe), z-ordering bugs where hidden triangles are displayed in front of the triangles that should hide them (a common bug on Linux with intel graphics cards), or the rendering windows becoming grey when the focus is moved out (often seen on Linux, when compiz is enabled). The solution is most often simply to turn off hardware rendering in the system settings (turn off compiz under Linux) or change graphics-card drivers (under Linux, try switching between the open source one, and the proprietary one).

However, I tried with either 3D acceleration disabled or enabled, but it did nothing to help. I also raised the video buffer and memory to the maximums, but no difference either here.

My first VM was NeuroDebian 8.0 on VirtualBox 5.VirtualBox's website states that it may have some issues with 3D drivers on some computers (the infamous "couldn't load driver vboxvideo" issue).

So, I tried a second VM using VMware Workstation 12 Player with Ubuntu 16.04. Once again I reinstalled Anaconda, Freesurfer, mayavi and then pysurfer. The same issue happened, but no error about 3D drivers. I also tried with and without 3D acceleration, the "TVTK" window grays out and freezes as soon as it opens. I must note here that Freesurfer GUI runs fine on both VMs.

Has anyone else tried to run pysurfer inside a VM? If not, it may well be possible that pysurfer can't be run inside a VM. In that case, you guys should maybe put a notice on the website install instructions page to prevent other people losing their time like I did...

larsoner commented 7 years ago

@lrq3000 feel free to open a PR clarifying about hardware requirements if you have time. In the meantime I'll close this