# Find all synapses. all_man_syn = dl.query_synapses("gsynapse_ai_manual_v2") # Find the postsynaptic cell ID with the most synapses that are manually annotated. all_man_syn["syn_num"] = all_man_syn.groupby( "post_pt_root_id")["id"].transform(len) cellid = all_man_syn[all_man_syn.syn_num == 34]["post_pt_root_id"].values[0] print(cellid) # Visualize the cell. mm = trimesh_io.MeshMeta(disk_cache_path="test/test_files") mesh = mm.mesh( filename= "/data/dynamic_brain_workshop/electron_microscopy/2019/meshes/%d.h5" % cellid) mesh_poly = trimesh_vtk.trimesh_to_vtk(mesh.vertices, mesh.faces, None) plt_actor = vtkplotter.Actor(mesh_poly) vtkplotter.embedWindow(backend="k3d") vp = vtkplotter.Plotter(bg="b") myactor = vtkplotter.Actor(plt_actor, c="r") myactor.GetMapper().Update() vp += myactor vp.show() # Find 10 largest synapses automatically extracted on this cell. post_synapse_df = dl.query_synapses("pni_synapses_i3", post_ids=np.array([cellid])) biggest_synapses = post_synapse_df.sort_values(by=["size"], ascending=False).head(10) print(biggest_synapses)
def color_mesh_itkwidgets(color_vec, mesh): poly_data = trimesh_vtk.trimesh_to_vtk(mesh.vertices, mesh.faces) vtk_color_vec = trimesh_vtk.numpy_to_vtk(color_vec) vtk_color_vec.SetName('colors') poly_data.GetPointData().SetScalars(vtk_color_vec) return poly_data
# to all inhibitory postsynaptic neurons (e-i connections). A = np.minimum(J, np.ones(J.shape)) ex_dist = np.sum(A[Ni:, :Ni], axis=1) # Compute frequency distributions of the number of connections from inhibitory neurons # to all inhibitory postsynaptic neurons (i-i connections). nh_dist = np.sum(A[:Ni, :Ni], axis=1) # Load the mesh. mesh_file = os.path.join(mesh_folder + str(inh_id)+".h5") print(mesh_file) mm = trimesh_io.MeshMeta(disk_cache_path="test/test_files") mesh = mm.mesh(filename =mesh_file) # Extract vertices and faces to make an "Actor" for vtkplotter. mesh_poly = trimesh_vtk.trimesh_to_vtk(mesh.vertices, mesh.faces, None) plt_actor = vtkp.Actor(mesh_poly, c="m") # Create a window to show the mesh. vtkp.embedWindow(backend="k3d") # Setup a plot that you can add actors to vp = vtkp.Plotter(bg="w") # add it to your plotter. vp+=plt_actor vp.show() # Visualize mesh for inhibitory neuron connecting # to at least 10 excitatory neurons. inh_10conn = np.where(K >= 10)[0] print(inh_10conn) inh_ind = np.random.choice(inh_10conn)