A lightweight skeletonizer that converts neuron meshes into biophysical‑modelling‑ready morphologies. Built for Eyewire II, in Rust, with Python binding.
- Mesh Preprocessing
- remove mesh anomolies such as parallel faces due to chunk merging failures, gaps (broken neurites), fusions (wrong connections)
- find and classify soma, organelles, and neurites (and also fragments that should be descarded)
Disconnected Mesh |
Gaps Detection |
Gaps Bridging
|
Original Mesh |
Organelles Detection |
Mesh breakdown into components
|
- Mesh → SWC skeletons
- Center‑line, acyclic skeleton.
- Per‑node radii with multiple estimators (centerline/median/mean/trim) and an automatic recommendation.
- Ellipsoidal soma detection near the soma centroid.
- Bridges disconnected mesh components back to the soma (gap‑closing) and prunes tiny peri‑soma artefacts.
- SWC and NPZ export with metadata;
Origin Mesh |
Geodesic Binnings |
Skeleton
|
- Pairwise contact sites (two cells)
- Skeleton‑based seeding: fast KD‑tree search finds node↔node proximity pairs with tolerance; returns contact midpoints and per‑node loci.
- Mesh‑based patches: around seeds, projects to both meshes and extracts touching triangle patches; returns per‑site areas on A/B and their mean, plus compact AABBs for downstream use.
- Optional skeleton‑only approximation of contact sites/areas when meshes are unavailable.
All contacts sites of two cells |
Contact sites with mesh |
Contact sites only
|
- I/O, visualization, diagnostics and post-processing
- Read/write SWC and compact NPZ;
- 2D projections and 3D viewers for meshes, skeletons, and contact patches.
- Various diagnostics and post-processing tools.
pip install skelineror from source, which builds the Rust core and so needs a Rust toolchain (rustup):
git clone https://github.com/berenslab/skeliner.git
# with uv
uv sync --all-extras
# or not
pip install -e "skeliner[dev]"Since v0.4.0, the preprocessing pipeline is the recommended route, while the original raw mesh direct skeletonization route is kept as a faster but less accurate alternative. The mesh preprocessing will clean up most artifacts that would potentially degrade the quality of the skeletons, which includes identifying internal organelles surfaces, locating the soma, and also bridging disconnected paths. All these are done in one call automatically. The skeleton then can be estimated from the cleaned mesh and the identified components (organelles, soma, and neurites):
import skeliner as sk
mesh = sk.io.load_mesh("cellA.obj")
mesh, components = sk.preprocess(mesh, compact=True, verbose=True)
skel = sk.skeletonize(mesh, components, unit="nm", verbose=True)
# Save SWC (e.g. convert nm → µm on write)
skel.to_swc("cellA.swc", scale=1e-3)
# Also persist a compact NPZ for fast reload
skel.to_npz("cellA.npz")import skeliner as sk
meshA = sk.io.load_mesh("cellA.obj")
meshB = sk.io.load_mesh("cellB.obj")
sites = sk.pair.scan_contact(meshA, meshB, unit="nm^2")
print("contact patches:", len(sites.faces_A))
print("mean areas (mesh units^2):", sites.area_mean)
# Optional: visualize patches
# sk.view.view_contacts(meshA, meshB, sites, sides="A")The Rust core runs its heaviest loops on every core by default. To use fewer
(a shared machine, or several cells at once on one node), set
RAYON_NUM_THREADS before Python starts, or in a notebook's first cell
(%env RAYON_NUM_THREADS=4), or switch at any time from Python:
sk.threads(4) # from now on
with sk.threads(2): # for this block only
mesh, components = sk.preprocess(mesh)
sk.threads(None) # back to the default: every core, or RAYON_NUM_THREADS
sk.threads.get() # how many threads the next parallel loop runs onSee example notebooks for more usage.











