import pandas as pd
import numpy as np
from caveclient import CAVEclient
import pyvista as pv
import cloudvolume
import seaborn as sns
Apply myelin labels to basket cell axon
This example uses the plotting package PyVista for interactive rendering. Any rendering program that takes vertices and edges can work.
Query a myelinated cell
# Set version to first data release with manual myelination labels
= CAVEclient("minnie65_public")
client = 1078
client.version
# Load the myelin values
= client.materialize.tables.vortex_manual_myelination_v0().query(
myelin_df =[1,1,1])
desired_resolution
# Load the nodes of Ranvier
= client.materialize.tables.vortex_manual_nodes_of_ranvier().query(
nodes_df =[1,1,1]) desired_resolution
Table Owner Notice on vortex_manual_myelination_v0: Myelination status assessed for the axon of the VALID_ID, not the pt_root_id.
Table Owner Notice on vortex_manual_nodes_of_ranvier: Nodes and myelination assessed for the VALID_ID; if pt_root_id does not match valid_id, the segment has undergone proofreading. Proceed with caution.
myelin_df.valid_id.unique()
array([864691135808631069, 864691136210378684, 864691135639556411,
864691135162983725, 864691136724881917])
# select an example myelinated basket cell
= 864691136210378684 root_id
Load the static mesh for one cell
# Set the static segmentaiton source to the most recent flat segmentation where that root id is valid
= 'precomputed://gs://iarpa_microns/minnie/minnie65/seg_m943'
seg_source
# load from cloudvolume
= cloudvolume.CloudVolume(seg_source, progress=False, use_https=True)
cv = cv.mesh.get(root_id, lod=2)[root_id] 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[:,
# Format the myelin annotations
= np.vstack(myelin_df.query(f"(valid_id=={root_id}) & (tag=='t')").pt_position.to_numpy()).astype(float)
myelin_points = pv.PolyData(myelin_points)
myelin_poly
# Flip with y axis
1] *= -1 myelin_poly.points[:,
# Format the node annotations
= np.vstack(nodes_df.query(f"(valid_id=={root_id})").pt_position.to_numpy()).astype(float)
ranvier_points = pv.PolyData(ranvier_points)
ranvier_poly
# Flip with y axis
1] *= -1 ranvier_poly.points[:,
Initialize plotting object, add mesh and annotations
"client")
pv.set_jupyter_backend(= pv.Plotter(image_scale=10)
plotter
= dict(
silhouette =[.06, .48, .67],
color=0.5,
line_width
)
=[.06, .48, .67], opacity=0.75, silhouette=silhouette)
plotter.add_mesh(mesh_poly, color=6, color="orange", opacity=0.5)
plotter.add_mesh(myelin_poly, point_size
= 'zy'
plotter.camera_position 1.0)
plotter.camera.zoom('#fbfbfb')
plotter.set_background(
plotter.show()