nipy / PySurfer

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

Problem with add_overlay #193

Closed bthirion closed 7 years ago

bthirion commented 7 years ago

I have the fiollowing problem: I am displying stat msaps on the surface, and would like to show both positive and negative parts. For certain images --not all of them-- I get an error message from VTK

ERROR: In /home/ilan/minonda/conda-bld/work/VTK-6.3.0/Common/Core/vtkLookupTable.cxx, line 144
vtkLookupTable (0xcc23d70): Bad table range: [1e+299, -1e+299]

and the negtaive part appears with absolute values. The behavior is not consistant across images and I could not figure out the reson for that. For instance, taking data.zip from https://filesender.renater.fr/?s=download&token=84efa671-c7c0-3884-ae0c-f9c41c5c5274 The following script outputs very heterogeneous results (see images):

from surfer import Brain
import numpy as np
from nibabel import load
import zipfile
zip_ref = zipfile.ZipFile('data.zip', 'r')
zip_ref.extractall()
zip_ref.close()

tex1 = np.array(load('sample_map_lh.gii').darrays[0].data)
tex2 =  np.array(load('grp_stat_lh.gii').darrays[0].data)

brain = Brain("fsaverage", 'lh', "inflated",  title='', views=['lat'])
brain.add_overlay(tex1, hemi='lh', min=3., max=8.)
brain.save_montage('sample_map_lh.png')
# this one is fine with both positive and negative value

brain = Brain("fsaverage", 'lh', "inflated",  title='', views=['lat'])
brain.add_overlay(tex2, hemi='lh', min=3., max=8.)
brain.save_montage('grp_stat_lh.png')
# this one is wrong, only positive

sample_map_lh grp_stat_lh

Can anybody reproduce / give advice ?

mwaskom commented 7 years ago

I can reproduce. Not sure yet what's going on.

mwaskom commented 7 years ago

@bthirion I'm not certain this is a pysurfer issue. If I just make a simple scatterplot of the values (plt.scatter(tex1, tex2)) it corresponds with the colors of the surface overlay:

bthirion_plot

bthirion commented 7 years ago

Oops. I'll have to revise my scripts. Thx for checking !