get_bones - jaybgager/tracertools GitHub Wiki

This function gets an array of viewer-resolution endpoint pairs for each edge in a nanometer-resolution osteoid skeleton. This is mostly intended as a utility function for several others that compare skeletons or check them against other objects like meshes.

Arguments:

  • datastack (string, mandatory)
    • the name of the CAVE datastack the skeleton is from (e.g. "brain_and_nerve_cord")
  • skeleton (skeleton object, mandatory)
    • an osteoid skeleton object
    • coordinates must be in "nanometer" [1,1,1] resolution

Returns:

  • bones ((n,2,3)-shape numpy array of floats)
    • an array of pairs of endpoint coordinates for each edge of the skeleton
    • these will be in the resolution of the specified datastack's default viewer
[
    [
        [bone_1_x1, bone_1_y1, bone_1_z1],
        [bone_1_x2, bone_1_y2, bone_1_z2]
    ],
    [
        [bone_2_x1, bone2_y1, bone_2_z1],
        [bone_2_x2, bone2_y2, bone_2_z2]
    ],
    [
        [bone_3_x1, bone_3_y1, bone_3_z1],
        [bone_3_x2, bone_3_y2, bone_3_z2]
    ],
    ...
    [
        [bone_n_x1, bone_n_y1, bone_n_z1],
        [bone_n_x2, bone_n_y2, bone_n_z2]
    ]
]

Example

Since this code requires an osteoid-format skeleton, we can get that using the get_seg_skeletons function. Let's try it with the segment 720575941526718564 from the brain_and_nerve_cord datastack.

INPUT:

import tracertools as tt

skel = tt.get_seg_skeletons(
    datastack = "brain_and_nerve_cord",
    seg_ids = [720575941526718564]
)[0]

Now that we have a skeleton, we can feed it into the get_bones function:

bones = tt.get_bones(
    datastack = "brain_and_nerve_cord", 
    skeleton = skel
)

print(bones)

OUTPUT:

Skeletonization ETA 0.0 seconds.
[[[121096. 167508.   5140.]
  [121824. 168760.   5187.]]

 [[121824. 168760.   5187.]
  [121824. 171212.   5292.]]

 [[121824. 171212.   5292.]
  [121820. 172040.   5371.]]

 ...

 [[123048. 169816.   4599.]
  [123352. 169936.   4608.]]

 [[123352. 169936.   4608.]
  [123576. 170012.   4609.]]

 [[123576. 170012.   4609.]
  [124756. 170868.   4532.]]]