Skip to content

calc_seg_mesh_intersect

jaybgager edited this page Sep 29, 2026 · 3 revisions

Calculates the points at which the skeletons of a list of segments intersect a mesh, if any. By default returns a list of True/False values indicating whether or not any intersection exists. Optional toggle allows for lists of intersection points instead.

Arguments:

  • datastack (string, mandatory)
    • the name of the datastack that contains the segments (e.g. "brain_and_nerve_cord")
  • seg_ids (list of integers, mandatory)
    • the ids of the segments to check
  • mesh_address (string, mandatory)
    • the hosting address of the volume containing the mesh to check the skeletons against
    • e.g. "https://c10s.pni.princeton.edu/tracers/jay/mesher_demo/example_01|neuroglancer-precomputed:"
  • return_intersects (boolean, optional, default=False)
    • by default this function returns a list of True/False values
    • setting this option to True will return a list of all the intersection points between the segment skeletons and the mesh if any exists

Returns:

  • results (varies, see description)
    • default behavior returns list of boolean True/False values indicating whether each segment intersects the mesh
    • if return intersects argument is set to True, instead returns a list where each item is either a list of 3-item arrays of coordinates or a None value if no intersections exist e.g.:
[
    [
        array([1,2,3])       
    ],
    None,
    [
        array([4,5,6]),
        array([7,8,9]),
    ]
]

Examples

Default Behavior

INPUT:

import tracertools as tt

intersections = tt.calc_seg_mesh_intersect(
    datastack = "brain_and_nerve_cord", 
    seg_ids = [720575941526718564,720575941524165453], 
    mesh_address = "https://c10s.pni.princeton.edu/tracers/examples/banc_mesh_01|neuroglancer-precomputed:",
)

print(intersections)

OUTPUT:

[True,False]

Return Intersects

INPUT:

import tracertools as tt

intersections = tt.calc_seg_mesh_intersect(
    datastack = "brain_and_nerve_cord", 
    seg_ids = [720575941526718564,720575941524165453], 
    mesh_address = "https://c10s.pni.princeton.edu/tracers/examples/banc_mesh_01|neuroglancer-precomputed:",
    return_intersects = True,
)

print(intersections)

OUTPUT:

[
    [
        array([121305., 181906.,   4627.]),
        array([123200., 172384.,   4720.]),
        array([124027., 174945.,   5243.]),
        array([124240., 176101.,   5346.]),
        array([123934., 175092.,   5244.]),
        array([127158., 175525.,   4693.]),
        array([125175., 175250.,   5344.]),
        array([125127., 174504.,   5263.]),
        array([125315., 175057.,   5311.]),
        array([122142., 175971.,   4855.])
    ],
    None
]

Clone this wiki locally