Watertight, smooth STL reconstruction from NIfTI segmentations (boolean-CSG peel or independent organs).
Project description
Turn a multi-label .nii.gz segmentation into one clean, closed STL surface per
label — solid, watertight, manifold, self-intersection-free. In csg mode,
adjacent regions share their interface seam bit-identically, so the parts
assemble seamlessly in 3D Slicer / Mimics.
Left → right: naive marching cubes (voxel staircase) · a typical 3D Slicer default export · NiftiMesh (smooth, watertight, seamless).
What it's for
A multi-label segmentation volume → per-label STL meshes. Two modes:
csg— for one structure split by internal interfaces: lung lobes / segments, Couinaud liver segments. Neighbouring labels share their cut seam exactly (no crack, no black line).independent— for disjoint organs (liver + spleen + kidneys, vessels): each label becomes its own closed, smoothed surface.
You define the output names — nothing is hard-coded to any anatomy.
Install
pip install "niftimesh[csg]" # csg mode (needs meshlib)
pip install niftimesh # independent + naive modes only
Python ≥ 3.9. NIfTI is read via nibabel (bundled) or SimpleITK if installed.
Prebuilt wheels are also attached to each
GitHub Release.
Usage
# names from a JSON file: {"1": "left_lower_lobe", "2": "left_upper_lobe", ...}
niftimesh seg.nii.gz out/ --mode csg --label-names names.json --suffix _3d
# omit --label-names to get label_1.stl, label_2.stl, ...
niftimesh organs.nii.gz out/ --mode independent
from niftimesh import nifti_to_stl
nifti_to_stl("seg.nii.gz", "out/", mode="csg",
label_names={1: "left_lower_lobe", 2: "left_upper_lobe"})
# in-memory: numpy (z, y, x) label volume -> {label: vtkPolyData}
from niftimesh import reconstruct
meshes = reconstruct(seg, spacing=(0.84, 0.84, 1.0), mode="independent")
License
Apache 2.0 © 2026 Justin
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file niftimesh-0.1.1.tar.gz.
File metadata
- Download URL: niftimesh-0.1.1.tar.gz
- Upload date:
- Size: 3.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a33219cb422bb3618588d726fcb2b3ad8fd5055faac2c8373910a18d55d6508
|
|
| MD5 |
cb68e7ecbef4d3ccff5202feaf8fef56
|
|
| BLAKE2b-256 |
568c4791a1895a38db822975ae834b3d4d46b3a67424dddd935cc0a233de8eb2
|
Provenance
The following attestation bundles were made for niftimesh-0.1.1.tar.gz:
Publisher:
publish.yml on 77even/NiftiMesh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
niftimesh-0.1.1.tar.gz -
Subject digest:
3a33219cb422bb3618588d726fcb2b3ad8fd5055faac2c8373910a18d55d6508 - Sigstore transparency entry: 1871541872
- Sigstore integration time:
-
Permalink:
77even/NiftiMesh@8f2b8f6c2d38dfe5a6515b8b8306ebcd12d42a5c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/77even
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8f2b8f6c2d38dfe5a6515b8b8306ebcd12d42a5c -
Trigger Event:
push
-
Statement type:
File details
Details for the file niftimesh-0.1.1-py3-none-any.whl.
File metadata
- Download URL: niftimesh-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaec6a65582c38f1869e2e79fad72a430416be0e7a66dcca68a8e5ae8d67d95e
|
|
| MD5 |
09edc1c0287e37bdfaff193593346434
|
|
| BLAKE2b-256 |
f278235685e3eee7e29c64e5c1c5867e95c09e2eff302472d9ac8eff2ff3bbcc
|
Provenance
The following attestation bundles were made for niftimesh-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on 77even/NiftiMesh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
niftimesh-0.1.1-py3-none-any.whl -
Subject digest:
eaec6a65582c38f1869e2e79fad72a430416be0e7a66dcca68a8e5ae8d67d95e - Sigstore transparency entry: 1871541920
- Sigstore integration time:
-
Permalink:
77even/NiftiMesh@8f2b8f6c2d38dfe5a6515b8b8306ebcd12d42a5c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/77even
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8f2b8f6c2d38dfe5a6515b8b8306ebcd12d42a5c -
Trigger Event:
push
-
Statement type: