Rasterizing a thin vessel STL onto a CT/MR grid usually fractures it into disconnected blobs at narrow junctions. VesselKnit keeps the vessel a single connected structure — faithful to the original mesh in morphology and calibre — via progressive gap-bridging during voxelization plus 26-/6-connectivity repair. Built for medical-imaging workflows; coordinate alignment (LPS/RAS, Z-reflection, direction matrix) is automatic.
pip install vesselknitOptional extras: [dicom] for DICOM input, [all] for everything.
Python ≥ 3.9.
vesselknit --stl vessel.stl --reference ct_scan/ --output vessel.nii.gzMultiple STLs into one multi-label volume, with connectivity repair:
vesselknit \
--stl portal_vein.stl --label 1 \
--stl hepatic_vein.stl --label 2 \
--reference ct_scan/ --output vessels.nii.gz \
--bridge-26connfrom vesselknit import load_reference_image, stl_to_mask, save_nifti
ref = load_reference_image("ct_scan/") # DICOM dir or .nii.gz
mask = stl_to_mask("vessel.stl", ref) # (z, y, x) uint8
save_nifti(mask, ref, "vessel.nii.gz")See examples/basic_usage.py for multi-label and
connectivity-repair examples.
Apache 2.0 © 2026 Justin
