Map data on mesh#

from vedo import *

settings.default_backend = "vtk"  # or k3d, ipyvtk, or 2d
# Gene expression data
gene_path = '../data/gene_data.npy'

# Mesh data
faces_path = '../data/mesh_faces.npy'
verts_path = '../data/mesh_nodes.npy'
# Read data
faces = np.load(faces_path)
verts = np.load(verts_path)
# Create the mesh 
msh = Mesh([verts, faces]).linewidth(1)
msh

vedo.mesh.Mesh
bounds
(x/y/z)
-450.0 ... 1998
-930.0 ... 900.0
0 ... 0
center of mass (693, -12.5, 0)
average size 785.066
nr. points / faces 3881 / 7021
show(msh, bg="#282a36").close()
# Adding scalar values
n = faces.shape[0] # number of faces
values = np.random.random(n)
msh.celldata["fake_data"] = values
msh.cmap("viridis")
msh.linewidth(0)

vedo.mesh.Mesh
bounds
(x/y/z)
-450.0 ... 1998
-930.0 ... 900.0
0 ... 0
center of mass (693, -12.5, 0)
average size 785.066
nr. points / faces 3881 / 7021
cell data array fake_data
show(msh, bg="#282a36").close()
values = np.load(gene_path)
msh.celldata["gene_data"] = values
msh.cmap("viridis")

vedo.mesh.Mesh
bounds
(x/y/z)
-450.0 ... 1998
-930.0 ... 900.0
0 ... 0
center of mass (693, -12.5, 0)
average size 785.066
nr. points / faces 3881 / 7021
cell data array gene_data
show(msh, bg="#282a36", zoom='tight').close()