import pandas as pd
import numpy as np
from caveclient import CAVEclient
import pyvista as pv
import cloudvolume
import seaborn as sns
Download and render astrocyte meshes
This example uses the plotting package PyVista for interactive rendering. Any rendering program that takes vertices and edges can work.
Query the proofread astrocytes
# Set version to the most recent datastack with a flat segmentation
= CAVEclient("minnie65_public")
client = 1300
client.version
# Load the proofread astrocytes
= client.materialize.tables.vortex_astrocyte_proofreading_status(status='clean').query(
astrocyte_df =True)
split_positions
# sort by y position
= astrocyte_df.sort_values('pt_position_y')
astrocyte_df
= astrocyte_df.pt_root_id.unique()
root_ids print(root_ids)
[864691136057675736 864691135852189639 864691135995876778
864691135527301979 864691135955003656 864691134886294010
864691135970105957 864691135772920395 864691135384083674
864691135234576473 864691135164125997 864691136298097435]
Load the static meshes for all cells
# Set the static segmentaiton source
= 'precomputed://gs://iarpa_microns/minnie/minnie65/seg_m1300'
seg_source
# load from cloudvolume
= cloudvolume.CloudVolume(seg_source, progress=False, use_https=True)
cv = cv.mesh.get(root_ids, lod=3) all_meshes
Initialize plotting object, add all astrocytes
"client")
pv.set_jupyter_backend(= pv.Plotter()
plotter
= list(sns.color_palette('tab20').as_hex())
colormap
# Plot the first 6 astrocytes
for mm in range(6):
= all_meshes[root_ids[mm]]
mesh
# Render the mesh vertices for pyvista
= mesh.vertices
vertices = mesh.faces
faces
# add a column of all 3s to the faces
= np.concatenate([np.full((faces.shape[0], 1), 3), faces], axis=1)
padded_faces
= pv.PolyData(vertices, faces=padded_faces)
mesh_poly
# Flip with y axis
1] *= -1
mesh_poly.points[:,
= dict(
silhouette =colormap[mm],
color=0.5,
line_width
)
=colormap[mm], opacity=0.5, silhouette=silhouette)
plotter.add_mesh(mesh_poly, color
= 'zy'
plotter.camera_position 1.0)
plotter.camera.zoom('#fbfbfb')
plotter.set_background(
plotter.show()