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
Metadata
Release files for niftimesh 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| niftimesh-0.1.1.tar.gz | 3.7 MB | With provenance | Details for niftimesh-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| niftimesh-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for niftimesh-0.1.1-py3-none-any.whl |
Total release size: 3.7 MB
Release files / niftimesh-0.1.1.tar.gz
| Download URL | niftimesh-0.1.1.tar.gz |
|---|---|
| Size | 3.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a33219cb422bb3618588d726fcb2b3ad8fd5055faac2c8373910a18d55d6508
|
|
BLAKE2b-256 checksum How to use checksums |
568c4791a1895a38db822975ae834b3d4d46b3a67424dddd935cc0a233de8eb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 19, 2026.
Transparency logRelease files / niftimesh-0.1.1-py3-none-any.whl
| Download URL | niftimesh-0.1.1-py3-none-any.whl |
|---|---|
| Size | 21.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eaec6a65582c38f1869e2e79fad72a430416be0e7a66dcca68a8e5ae8d67d95e
|
|
BLAKE2b-256 checksum How to use checksums |
f278235685e3eee7e29c64e5c1c5867e95c09e2eff302472d9ac8eff2ff3bbcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 19, 2026.
Transparency logSecurity for niftimesh 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for niftimesh-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.