get_mesh_triangles - jaybgager/tracertools GitHub Wiki
Gets a numpy array of point coordinates for the vertices of each face of a single-resolution legacy-format mesh in a neuroglancer volume. If the volume is bucket-hosted (the default assumption), it requires read access set up through cloudvolume.
Arguments:
volume_path(string, mandatory)- the absolute path to the directory of the volume that contains the mesh
- the last directory should be the top-level folder of the volume
- e.g.
/home/username/ng_meshes/image01would get theimage01volume in theng_meshesfolder
mesh_seg_id(int, optional, default=1)- the segment ID of the mesh within the neuroglancer volume
local(bool, optional, default=False)- if set to
True, treats volume_path as a file path on your local machine - by default, assumes the volume_path is a bucket-hosted file
- if set to
Returns:
triangles((n,3,3)-shape numpy array of floats)- the point coordinates of the face vertices for each triangle
Example
The example below gets the faces of a mesh with a segment ID 1 in a volume called banc_mesh_01 on a remote bucket.
INPUT:
import tracertools as tt
triangles = tt.get_mesh_triangles(
volume_path = "https://c10s.pni.princeton.edu/tracers/examples/banc_mesh_01|neuroglancer-precomputed:",
)
print(triangles)
OUTPUT (truncated for space):
[
[
[108968.75 178911.5 4687.48888889]
[113279.75 179077.25 4747.48888889]
[109466.25 180402.75 4687.48888889]
],
...
[
[139306. 182083.25 4317.48888889]
[139389. 183077.5 4317.48888889]
[136902. 183740.25 4427.48888889]
]
]
[!NOTE] Although point coordinates are often stored as integers in most contexts, meshes (particularly those that were programmatically generated) often store them as floats to maintain accuracy.