Skip to main content

Watertight, smooth STL reconstruction from NIfTI segmentations (boolean-CSG peel or independent organs).

Reason this release was yanked:

Relicensed to Apache-2.0; please use 0.1.1+

Project description

NiftiMesh

Watertight, smooth STL reconstruction from NIfTI segmentations.

PyPI Python License: MIT

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.

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

MIT © 2026 Justin

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

niftimesh-0.1.0.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

niftimesh-0.1.0-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file niftimesh-0.1.0.tar.gz.

File metadata

  • Download URL: niftimesh-0.1.0.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

Hashes for niftimesh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 675be032167ce2508306a743b75baebf5227a83db317598ba37a0baf9e07f243
MD5 9a6c3d2118eb3f93d38a681c0a82465b
BLAKE2b-256 e5c2e7f06a2cd66255c3cc4c5fe1af0039e102d945ac4c07c5ae9c52f38ee5d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for niftimesh-0.1.0.tar.gz:

Publisher: publish.yml on 77even/NiftiMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file niftimesh-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: niftimesh-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for niftimesh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e34e74b16ead0f4e47c69b347eb384f793b739426dc0959f07ba36a152054219
MD5 32eb3d59f70f84f18cad736d8bd0e85e
BLAKE2b-256 1f6a5ecafa81cf31ee031ba973bc9497c4e24c875b2ebbd8cab8a5c74b91b880

See more details on using hashes here.

Provenance

The following attestation bundles were made for niftimesh-0.1.0-py3-none-any.whl:

Publisher: publish.yml on 77even/NiftiMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page