nipy / PySurfer

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

brain.add_annotation does not display annotation #250

Closed EhsanTadayon closed 6 years ago

EhsanTadayon commented 6 years ago

Hi,

I am trying to display Freesurfer annotation using brain.add_annotation('aparc'). However, pysurfer does not display the annotation. I'm using Mac OS and qt backend. I appreciate any input on this.

thanks Ehsan.

agramfort commented 6 years ago

this example runs on your system:

https://pysurfer.github.io/auto_examples/plot_parcellation.html#sphx-glr-auto-examples-plot-parcellation-py

?

EhsanTadayon commented 6 years ago

Hi,

thanks. Nope. I ran my code on another machine ( macOS) and it works just fine. I updated my mayavi ( conda), reinstalled my pysurfer and changed my browser. But nothing worked on my office Macbook (macOS Sierra).

thanks

agramfort commented 6 years ago

maybe you can try to follow these instructions:

http://martinos.org/mne/stable/install_mne_python.html#get-mne-and-its-dependencies

it works well for me on a mac.

fliem commented 6 years ago

Hi, I have the same issue with add_annotation on OSX. Interestingly, add_label is working as expected. Here is my conda list

# packages in environment at /anaconda3/envs/py2:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.10           py27h9dd7d6e_0  
anaconda                  custom           py27h2cfa9e9_0  
anaconda-client           1.6.9                    py27_0  
anaconda-project          0.8.2            py27h2dc806c_0  
appnope                   0.1.0            py27hb466136_0  
appscript                 1.0.1            py27h451298e_1  
apptools                  4.4.0                    py27_1  
asn1crypto                0.24.0                   py27_0  
astroid                   1.6.1                    py27_0  
astropy                   2.0.3            py27h1de35cc_0  
attrs                     17.4.0                   py27_0  
babel                     2.5.3                    py27_0  
backports                 1.0              py27hb4f9756_1  
backports.functools_lru_cache 1.4              py27h2aca819_1  
backports.shutil_get_terminal_size 1.0.0            py27hc9115de_2  
backports_abc             0.5              py27h6972548_0  
beautifulsoup4            4.6.0            py27h9416283_1  
bitarray                  0.8.1            py27h1de35cc_1  
bkcharts                  0.2              py27haafc882_0  
blas                      1.0                         mkl  
blaze                     0.11.3           py27hb49378a_0  
bleach                    2.1.2                    py27_0  
bokeh                     0.12.13          py27h5233db4_0  
boto                      2.48.0           py27hacdd0fd_1  
bottleneck                1.2.1            py27h71f98a3_0  
bzip2                     1.0.6                hd86a083_4  
ca-certificates           2018.03.07                    0  
cdecimal                  2.3              py27h1de35cc_3  
certifi                   2018.8.24                py27_1  
cffi                      1.11.4           py27h342bebf_0  
chardet                   3.0.4            py27h2842e91_1  
click                     6.7              py27h2b86a94_0  
cloudpickle               0.5.2                    py27_1  
clyent                    1.2.2            py27hc0ae608_0  
colorama                  0.3.9            py27hbbe92b6_0  
configobj                 5.0.6                    py27_1  
configparser              3.5.0            py27hc7edf1b_0  
contextlib2               0.5.5            py27h9cb85f4_0  
cryptography              2.1.4            py27hdbc5e8f_0  
curl                      7.58.0               ha441bb4_0  
cycler                    0.10.0           py27hfc73c78_0  
cython                    0.27.3           py27h6429b90_0  
cytoolz                   0.9.0            py27h1de35cc_0  
dask                      0.16.1                   py27_0  
dask-core                 0.16.1                   py27_0  
datashape                 0.5.4            py27hd6a1745_0  
dbus                      1.12.2               h5243cc1_1  
decorator                 4.2.1                    py27_0  
distributed               1.20.2                   py27_0  
docutils                  0.14             py27h0befae3_0  
entrypoints               0.2.3            py27hd680fb1_2  
enum34                    1.1.6            py27hf475452_1  
envisage                  4.7.0                    py27_0  
et_xmlfile                1.0.1            py27hc42f929_0  
expat                     2.2.5                hb8e80ba_0  
fastcache                 1.0.2            py27h1de35cc_2  
filelock                  2.0.13           py27h2c227fa_0  
flask                     0.12.2           py27h3ac5568_0  
flask-cors                3.0.3            py27h13db576_0  
freetype                  2.8                  h12048fb_1  
funcsigs                  1.0.2            py27hb9f6266_0  
functools32               3.2.3.2          py27h8ceab06_1  
future                    0.16.0                   py27_2  
futures                   3.2.0            py27h1b80678_0  
get_terminal_size         1.0.0                h7520d66_0  
gettext                   0.19.8.1             h15daf44_3  
gevent                    1.2.2            py27hc02608c_0  
glib                      2.53.6               h33f6a65_2  
glob2                     0.6              py27h55c9705_0  
gmp                       6.1.2                hb37e062_1  
gmpy2                     2.0.8            py27h4bc979a_2  
greenlet                  0.4.12           py27h081ed54_0  
grin                      1.2.1                    py27_4  
h5py                      2.7.1            py27h75626f5_0  
hdf5                      1.10.1               ha036c08_1  
heapdict                  1.0.0                    py27_2  
html5lib                  1.0.1            py27h5233db4_0  
icu                       58.2                 h4b95b61_1  
idna                      2.6              py27hedea723_1  
imageio                   2.2.0            py27h37746d9_0  
imagesize                 0.7.1            py27h4f7bcc8_0  
intel-openmp              2018.0.0             h8158457_8  
ipaddress                 1.0.19                   py27_0  
ipykernel                 4.8.0                    py27_0  
ipython                   5.4.1                    py27_2  
ipython_genutils          0.2.0            py27h8b9a179_0  
ipywidgets                7.1.1                    py27_0  
isort                     4.2.15           py27h5bf637f_0  
itsdangerous              0.24             py27h3948ded_1  
jbig                      2.1                  h4d881f8_0  
jdcal                     1.3              py27hfeaf94f_0  
jedi                      0.11.1                   py27_0  
jinja2                    2.10             py27h70b8dc5_0  
jpeg                      9b                   he5867d9_2  
jsoncpp                   1.8.3                ha5298f7_0  
jsonschema                2.6.0            py27hd9b497e_0  
jupyter                   1.0.0                    py27_4  
jupyter_client            5.2.2                    py27_0  
jupyter_console           5.2.0            py27h9702a86_1  
jupyter_core              4.4.0            py27h5ea6ba4_0  
jupyterlab                0.31.5                   py27_0  
jupyterlab_launcher       0.10.2                   py27_0  
lazy-object-proxy         1.3.1            py27h712ce3f_0  
libcurl                   7.58.0               hf30b1f0_0  
libcxx                    4.0.1                h579ed51_0  
libcxxabi                 4.0.1                hebd6815_0  
libedit                   3.1                  hb4e282d_0  
libffi                    3.2.1                h475c297_4  
libgfortran               3.0.1                h93005f0_2  
libiconv                  1.15                 hdd342a3_7  
libpng                    1.6.34               he12f830_0  
libsodium                 1.0.15               hd9e47c5_0  
libssh2                   1.8.0                h322a93b_4  
libtiff                   4.0.9                h0dac147_0  
libxml2                   2.9.7                hab757c2_0  
libxslt                   1.1.32               hb819dd2_0  
llvmlite                  0.21.0           py27hac8ee23_0  
locket                    0.2.0            py27ha10513d_1  
lxml                      4.1.1            py27hef8c89e_1  
lzo                       2.10                 h362108e_2  
markupsafe                1.0              py27hd3c86fa_1  
matplotlib                2.1.2            py27h6d6146d_0  
mayavi                    4.5.0                    py27_0  
mccabe                    0.6.1            py27h1f69e8d_0  
mistune                   0.8.3                    py27_0  
mkl                       2018.0.1             hfbd8650_4  
mkl-service               1.1.2            py27hcba3029_4  
mpc                       1.0.3                h7a72875_5  
mpfr                      3.1.5                h711e7fd_2  
mpmath                    1.0.0            py27h6b0eff6_2  
msgpack-python            0.5.1            py27h04f5b5a_0  
multipledispatch          0.4.9            py27h10993aa_0  
nbconvert                 5.3.1            py27h6455e4c_0  
nbformat                  4.4.0            py27hddc86d0_0  
ncurses                   6.0                  hd04f020_2  
networkx                  2.1                      py27_0  
nibabel                   2.3.0                     <pip>
nltk                      3.2.5            py27h2e86947_0  
nose                      1.3.7            py27h2ee3cb8_2  
notebook                  5.4.0                    py27_0  
numba                     0.36.2          np114py27he3a832a_0  
numexpr                   2.6.4            py27hf375000_0  
numpy                     1.14.0           py27h8a80b8c_1  
numpydoc                  0.7.0            py27h022f19e_0  
odo                       0.5.1            py27h992a9f7_0  
olefile                   0.45.1                   py27_0  
openpyxl                  2.4.10                   py27_0  
openssl                   1.0.2p               h1de35cc_0  
packaging                 16.8             py27h24b219a_0  
pandas                    0.22.0           py27h0a44026_0  
pandoc                    1.19.2.1             ha5e8f32_1  
pandocfilters             1.4.2            py27hed78c4e_1  
parso                     0.1.1            py27he57c4c6_0  
partd                     0.3.8            py27h7560dbf_0  
path.py                   10.5             py27h0d68f8b_0  
pathlib2                  2.3.0            py27he09da1e_0  
patsy                     0.5.0                    py27_0  
pcre                      8.41                 hfb6ab37_1  
pep8                      1.7.1                    py27_0  
pexpect                   4.3.1                    py27_0  
pickleshare               0.7.4            py27h37e3d41_0  
pillow                    5.0.0            py27hfcce615_0  
pip                       9.0.1            py27h1567d89_4  
pkginfo                   1.4.1            py27ha9221e7_0  
pluggy                    0.6.0            py27had36429_0  
ply                       3.10             py27h6279b8a_0  
prompt_toolkit            1.0.15           py27h4a7b9c2_0  
psutil                    5.4.3            py27h1de35cc_0  
ptyprocess                0.5.2            py27h70f6364_0  
py                        1.5.2            py27he6783ac_0  
pyaudio                   0.2.7            py27h3777516_1  
pycodestyle               2.3.1            py27h5b634e0_0  
pycosat                   0.6.3            py27h6c51c7e_0  
pycparser                 2.18             py27h0d28d88_1  
pycrypto                  2.6.1            py27h1de35cc_7  
pycurl                    7.43.0.1         py27hdbc3d79_0  
pyface                    6.0.0                    py27_0  
pyflakes                  1.6.0            py27h4446e76_0  
pygments                  2.2.0            py27h1a556bb_0  
pylint                    1.8.2                    py27_0  
pyodbc                    4.0.22           py27h0a44026_0  
pyopenssl                 17.5.0           py27hfda213f_0  
pyparsing                 2.2.0            py27h5bb6aaf_0  
pyqt                      4.11.4                   py27_4  
pysocks                   1.6.7            py27h1cff6a6_1  
pysurfer                  0.8.0                     <pip>
pytables                  3.4.2            py27ha4551b8_2  
pytest                    3.3.2                    py27_0  
python                    2.7.14              hde5916a_29  
python-dateutil           2.6.1            py27hd56c96b_1  
python.app                2                py27hf2d5e94_7  
pytz                      2017.3           py27h803c07a_0  
pywavelets                0.5.2            py27hd99e88a_0  
pyyaml                    3.12             py27ha7932d0_1  
pyzmq                     16.0.3           py27h91ccc67_0  
qt                        4.8.7                         4  
qtawesome                 0.4.4            py27hdeb2f59_0  
qtconsole                 4.3.1            py27hdc90b4f_0  
qtpy                      1.3.1            py27h39159f8_0  
readline                  7.0                  hc1231fa_4  
requests                  2.18.4           py27h9b2b37c_1  
rope                      0.10.7           py27hffa1879_0  
ruamel_yaml               0.15.35          py27h1de35cc_1  
scandir                   1.6              py27h97aa1ee_0  
scikit-image              0.13.1           py27h1de35cc_1  
scikit-learn              0.19.1           py27h9788993_0  
scipy                     1.0.0            py27h793f721_0  
seaborn                   0.8.1            py27h6bd0ddc_0  
send2trash                1.4.2                    py27_0  
setuptools                38.4.0                   py27_0  
simplegeneric             0.8.1                    py27_2  
singledispatch            3.4.0.3          py27he22c18d_0  
sip                       4.18                     py27_0  
six                       1.11.0           py27h7252ba3_1  
snowballstemmer           1.2.1            py27h68ac032_0  
sortedcollections         0.5.3            py27h8094be4_0  
sortedcontainers          1.5.9                    py27_0  
sphinx                    1.6.6                    py27_0  
sphinxcontrib             1.0              py27hd2ed746_1  
sphinxcontrib-websupport  1.0.1            py27h857890b_1  
spyder                    3.2.6                    py27_0  
sqlalchemy                1.2.1            py27h1de35cc_0  
sqlite                    3.22.0               h3efe00b_0  
ssl_match_hostname        3.5.0.1          py27h8780752_2  
statsmodels               0.8.0            py27h6d68dbf_0  
subprocess32              3.2.7            py27h24b2887_0  
sympy                     1.1.1            py27hce55102_0  
tbb                       2018.0.5             h04f5b5a_0  
tblib                     1.3.2            py27ha684fc4_0  
terminado                 0.8.1                    py27_1  
testpath                  0.3.1            py27h72d81a5_0  
tk                        8.6.7                h35a86e2_3  
toolz                     0.9.0                    py27_0  
tornado                   4.5.3                    py27_0  
traitlets                 4.3.2            py27hcf08151_0  
traits                    4.6.0            py27h1de35cc_3  
traitsui                  6.0.0                    py27_1  
typing                    3.6.2            py27h646fea0_0  
unicodecsv                0.14.1           py27h170f95c_0  
unixodbc                  2.3.4                h4cb4dde_1  
urllib3                   1.22             py27hc3787e9_0  
vtk                       6.3.0                    py27_1  
wcwidth                   0.1.7            py27h817c265_0  
webencodings              0.5.1            py27h19a9f58_1  
werkzeug                  0.14.1                   py27_0  
wheel                     0.30.0           py27h677a027_1  
widgetsnbextension        3.1.0                    py27_0  
wrapt                     1.10.11          py27hd341262_0  
xlrd                      1.1.0            py27hbd41ed1_1  
xlsxwriter                1.0.2            py27h7f1064a_0  
xlwings                   0.11.5                   py27_0  
xlwt                      1.2.0            py27hbeec4ae_0  
xz                        5.2.3                h0278029_2  
yaml                      0.1.7                hc338f04_2  
zeromq                    4.2.2                ha360ad0_2  
zict                      0.1.3            py27h5fff8b1_0  
zlib                      1.2.11               hf3cbc9b_2

The mne environment is also not working:

  File "/anaconda3/envs/mne/lib/python3.6/site-packages/surfer/viz.py", line 461, in __init__
    interaction)
  File "/anaconda3/envs/mne/lib/python3.6/site-packages/surfer/viz.py", line 215, in _make_viewer
    figure = mlab.figure(title, size=(w, h))
  File "/anaconda3/envs/mne/lib/python3.6/site-packages/mayavi/tools/figure.py", line 64, in figure
    engine = get_engine()
  File "/anaconda3/envs/mne/lib/python3.6/site-packages/mayavi/tools/engine_manager.py", line 92, in get_engine
    return self.new_engine()
  File "/anaconda3/envs/mne/lib/python3.6/site-packages/mayavi/tools/engine_manager.py", line 137, in new_engine
    check_backend()
  File "/anaconda3/envs/mne/lib/python3.6/site-packages/mayavi/tools/engine_manager.py", line 40, in check_backend
    raise ImportError(msg)
ImportError: Could not import backend for traitsui.  Make sure you
        have a suitable UI toolkit like PyQt/PySide or wxPython
        installed.

Any ideas? Thanks.

agramfort commented 6 years ago

you're using python 2.7 for which I agree it should not (yet) be broken.

in the mean time can you try to install a python 3 env as explained here:

http://martinos.org/mne/stable/install_mne_python.html#get-a-python-interpreter

fliem commented 6 years ago

Thanks for the reply. Here it says "PySurfer requires Python 2.7, and it does not work on Python 3."

The MNE env gives me an error (see bottom of previous post). Thanks.

mwaskom commented 6 years ago

Might be a breaking change in the latest nibabel

fliem commented 6 years ago

Thanks @mwaskom. That's it. Annotations display correctly with nibabel 2.2.1

mwaskom commented 6 years ago

Great, ideally we should sort out exactly what the issue is and report upstream

larsoner commented 6 years ago

With something like:

import nibabel as nib
labels, cmap, _ = nib.freesurfer.read_annot('/Users/larsoner/mne_data/MNE-sample-data/subjects/fsaverage/label/lh.aparc.annot', orig_ids=True)

The third column of cmap has changed from 255 in 2.2.2 to 0 in nibabel master at least. Also the data type changed from int64 to uint32. And finally, the first entry of HCPMMP1 annot has changed from [255, 255, 255, 255, 16777215] in 2.2.2 to [255, 255, 255, 255, -1] in master.

I think this has to do with the weird format that annot files use, related to this PR:

https://github.com/nipy/nibabel/pull/592

larsoner commented 6 years ago

https://github.com/nipy/nibabel/issues/663

mwaskom commented 6 years ago

I’m confused about how someone on the west coast was able to figure this all out before I even was able to make coffee! Thanks @larsoner

larsoner commented 6 years ago

Don't worry, I'm not currently on the west coast :)

EhsanTadayon commented 6 years ago

Thanks, @larsoner. Now, It works for me as well.