def test_full_cell_with_links(full_cell_mesh, full_cell_merge_log, tmp_path, monkeypatch): class MyChunkedGraph(object): def __init__(a, **kwargs): pass def get_merge_log(self, atomic_id): return full_cell_merge_log monkeypatch.setattr(trimesh_io.trimesh_repair.chunkedgraph, 'ChunkedGraphClient', MyChunkedGraph) full_cell_mesh.add_link_edges('test', 5) mesh_actor = trimesh_vtk.mesh_actor(full_cell_mesh) eval_actor_image([mesh_actor], 'full_cell_with_links.png', tmp_path, scale=1) mesh_actor = trimesh_vtk.mesh_actor(full_cell_mesh, opacity=1.0, show_link_edges=True) m1 = np.array(full_cell_merge_log['merge_edge_coords'][0]) ctr = np.mean(m1, axis=0) camera = trimesh_vtk.oriented_camera(ctr, backoff=5, up_vector=(0, 0, 1), backoff_vector=(0, 1, 0)) eval_actor_image([mesh_actor], 'full_cell_show_links.png', tmp_path, camera=camera)
def test_full_cell_with_links(full_cell_mesh, full_cell_merge_log, tmp_path): full_cell_mesh.add_link_edges(merge_log=full_cell_merge_log, base_resolution=[1, 1, 1]) mesh_actor = trimesh_vtk.mesh_actor(full_cell_mesh) eval_actor_image([mesh_actor], 'full_cell_with_links.png', tmp_path, scale=1) mesh_actor = trimesh_vtk.mesh_actor(full_cell_mesh, opacity=1.0, show_link_edges=True) m1 = np.array(full_cell_merge_log['merge_edge_coords'][0]) ctr = np.mean(m1, axis=0) camera = trimesh_vtk.oriented_camera(ctr, backoff=5, up_vector=(0, 0, 1), backoff_vector=(0, 1, 0)) eval_actor_image([mesh_actor], 'full_cell_show_links.png', tmp_path, camera=camera)
def test_full_cell_movie(full_cell_mesh, full_cell_soma_pt, tmp_path): mesh_actor = trimesh_vtk.mesh_actor(full_cell_mesh) camera = trimesh_vtk.oriented_camera(full_cell_soma_pt, backoff=100) eval_actor_360([mesh_actor], 'full_cell_movie', tmp_path, camera=camera, scale=1)
def test_full_cell_camera(full_cell_mesh, full_cell_soma_pt, tmp_path): mesh_actor = trimesh_vtk.mesh_actor(full_cell_mesh) camera = trimesh_vtk.oriented_camera(full_cell_soma_pt, backoff=100) eval_actor_image([mesh_actor], 'full_cell_orient_camera.png', tmp_path, camera=camera, scale=1) scale_bar_actor = trimesh_vtk.scale_bar_actor( full_cell_soma_pt - [15000, 0, 0], camera) eval_actor_image([mesh_actor, scale_bar_actor], 'full_cell_scale_bar.png', tmp_path, camera=camera, scale=1)
def test_point_cloud(full_cell_mesh, full_cell_synapses, full_cell_soma_pt, tmp_path): mesh_actor = trimesh_vtk.mesh_actor(full_cell_mesh) camera = trimesh_vtk.oriented_camera(full_cell_soma_pt, backoff=300) sizes = full_cell_synapses['sizes'] # size points by size, fixed color syn_actor = trimesh_vtk.point_cloud_actor(full_cell_synapses['positions'], size=sizes, color=(1, 0, 0)) eval_actor_image([mesh_actor, syn_actor], 'full_cell_with_synapes_size_scaled.png', tmp_path, camera=camera) # color points by size, mapping sizes syn_actor = trimesh_vtk.point_cloud_actor(full_cell_synapses['positions'], size=500, color=np.clip(sizes, 0, 1000)) eval_actor_image([mesh_actor, syn_actor], 'full_cell_synapes_colored_size.png', tmp_path, camera=camera) # color and size points syn_actor = trimesh_vtk.point_cloud_actor(full_cell_synapses['positions'], size=sizes, color=np.clip(sizes, 0, 1000)) eval_actor_image([mesh_actor, syn_actor], 'full_cell_synapes_colored_and_size.png', tmp_path, camera=camera) # random colors x = np.linspace(0, 1.0, len(sizes)) rand_colors = np.hstack([ x[:, np.newaxis], np.abs(x - .5)[:, np.newaxis], (1 - x)[:, np.newaxis] ]) syn_actor = trimesh_vtk.point_cloud_actor(full_cell_synapses['positions'], size=500, color=rand_colors) eval_actor_image([mesh_actor, syn_actor], 'full_cell_synapes_random_colors.png', tmp_path, camera=camera) # random colors uint8 rand_colors_uint8 = np.uint8(rand_colors * 255) syn_actor = trimesh_vtk.point_cloud_actor(full_cell_synapses['positions'], size=500, color=rand_colors_uint8) eval_actor_image([mesh_actor, syn_actor], 'full_cell_synapes_random_colors_uint8.png', tmp_path, camera=camera) # test failure modes with pytest.raises(ValueError) as e: syn_actor = trimesh_vtk.point_cloud_actor( full_cell_synapses['positions'], size=np.random.rand(10, 10), color=(1, 0, 0)) with pytest.raises(ValueError) as e: syn_actor = trimesh_vtk.point_cloud_actor( full_cell_synapses['positions'], size=300, color=np.random.rand(len(x), 2))