Brook TEASAR skeletonization on NVIDIA GPUs
Brook turns a 3D label volume, such as a neuron segmentation in connectomics, into one skeleton per object. Connected components, distance transforms, path tracing and, when memory allows, skeleton assembly run on the NVIDIA GPU. It takes the arguments of kimimaro.skeletonize and returns osteoid.Skeleton objects.
Get started
A drop-in replacement for Kimimaro’s skeletonize, also usable from C and C++. Labels can already be on the GPU: CuPy and PyTorch arrays are read without a trip through host memory.
Linux x86-64; NVIDIA GPU of compute capability 8.0+ (Ampere or later); NVIDIA driver supporting CUDA 12.3+; wheels for CPython 3.12 to 3.14. There are no macOS wheels, and Windows is untested.
Install
python -m pip install brook-cu12
# or from source (CUDA Toolkit 12.3+)
pip install build
python -m build --wheel
pip install dist/brook-*.whlPython
import brook
skeletons = brook.skeletonize(
labels, anisotropy=(16, 16, 40))
# many volumes in one call
batch = brook.skeletonize_batch(volumes)C++
#include <brook/brook.hpp>
brook_volume v{}; // host or device labels
v.struct_size = sizeof(v);
v.abi_version = BROOK_ABI_VERSION;
v.data = labels; v.dtype = BROOK_U32;
v.memory = BROOK_DEVICE;
// v.shape, v.strides in elements / bytes
brook::api::Context context;
auto skeletons = context.skeletonize(v);How TEASAR becomes more parallel
Rings instead of a queue
A new path searches back to the skeleton one ring of voxels at a time, in parallel, and stops at first contact.
One wave, many objects
Distance fields for many objects come from one flood over the volume. The wave never crosses from one object into another.
Drafting ahead
Like speculative decoding: Brook drafts the next paths of a long object in parallel and keeps only those one-at-a-time tracing would have drawn.
Two lanes
The longest objects move to a second loop that runs alongside the first, so they stop setting the pace.
Batches in one call
skeletonize_batch traces several volumes together, with the same result as separate calls.
Twelve datasets
On these twelve datasets Brook returns the same objects as Kimimaro. Brook’s total skeleton length is 0.5% to 7.9% shorter, mostly because equal-cost routes are broken differently.