Пример #1
0
data_masked = np.load('parcellation.npy').astype(int)
data_masked += 1
data = np.zeros(mask.shape, dtype=int)
data[mask] = data_masked

m = np.max(data) + 1
colors = np.asarray(colorlist)
cmap_vec = np.arange(m) % len(colors)
colors_vec = colors[cmap_vec]
cmap = matplotlib.colors.ListedColormap(colors_vec)

display_options = {}
display_options['interpolation'] = 'nearest'
display_options['cmap'] = cmap

v = Viewer3D.show((data, display_options), title='Demo')


def update_color(view, value):
    cmap_vec[value] = (cmap_vec[value] + 1) % len(colors)
    print '[',
    for i in cmap_vec:
        print '%d,' % i,
    print ']'
    colors_vec = colors[cmap_vec]
    cmap = matplotlib.colors.ListedColormap(colors_vec)
    for view, _ in v.views:
        view.layers[-1][1]['cmap'] = cmap
        view.redraw_layers()

Пример #2
0
from nisl import datasets, utils
from pynax import Viewer3D
import pylab as pl
import numpy as np

nyu = datasets.fetch_nyu_rest(n_subjects=1)
func = nyu.func[0]
niimg = utils.check_niimg(func)
data = niimg.get_data()[..., 0]
# Awesome example activation map : take whatever is > .6 max
data_act = np.ma.MaskedArray(data, mask=(data < .6 * np.max(data)))
vm = np.max(np.abs(data_act))

display_options = {}
display_options['interpolation'] = 'nearest'
display_options['cmap'] = pl.cm.gray

act_display_options = {}
act_display_options['interpolation'] = 'nearest'
act_display_options['cmap'] = pl.cm.jet
act_display_options['vmin'] = -vm
act_display_options['vmax'] = vm
act_display_options['pynax_colorbar'] = True

Viewer3D.show((data, display_options), (data_act, act_display_options),
              title='Demo')

pl.show()
Пример #3
0
data_masked = np.load('parcellation.npy').astype(int)
data_masked += 1
data = np.zeros(mask.shape, dtype=int)
data[mask] = data_masked

m = np.max(data) + 1
colors = np.asarray(colorlist)
cmap_vec = np.arange(m) % len(colors)
colors_vec = colors[cmap_vec]
cmap = matplotlib.colors.ListedColormap(colors_vec)

display_options = {}
display_options['interpolation'] = 'nearest'
display_options['cmap'] = cmap

v = Viewer3D.show((data, display_options),
                  title='Demo')


def update_color(view, value):
    cmap_vec[value] = (cmap_vec[value] + 1) % len(colors)
    print '[',
    for i in cmap_vec:
        print '%d,' % i,
    print ']'
    colors_vec = colors[cmap_vec]
    cmap = matplotlib.colors.ListedColormap(colors_vec)
    for view, _ in v.views:
        view.layers[-1][1]['cmap'] = cmap
        view.redraw_layers()