Labels to 3D models
Turns labelled volumes (a CT segmentation, any label map or masks) into a clean 3D model per structure: one coloured GLB scene per case for the 3D view, and STL files for 3D printing.
How it works
Connect label volumes (NIfTI, NRRD or MHA): a label map per case, where each number is a structure (names from a table: id, name, and optionally group and color), or masks, one file per structure in a folder such as segmentations/ (the file name is the structure, as in the TotalSegmentator dataset). Scans connected by mistake (a CT) are recognised and skipped.
Each structure becomes a surface (marching cubes on a slightly softened mask), smoothed without shrinking (Taubin), reduced to at most Triangles, closed at the edges of the scan, and checked: pieces, open edges, watertight, so the table says which models are ready to print.
Models are in the patient's frame, in millimetres in STL and metres in GLB (head up, face towards you), grouped as skeleton, organs, vessels, heart, lungs and airways, muscles, and coloured as anatomy atlases do (lungs see-through). Structures picks some by name or group: liver, kidney_*, vessels, skeleton.
The 3D scene of a case is kept under Scene triangles (and stored compactly) so it reaches EsaSim and opens quickly; the STL files keep the full detail. Runs on any worker; a full TotalSegmentator case (about 100 structures) takes a minute or two.
Inputs
| Input | Takes | What it is |
|---|---|---|
Labelslabels | Files gz, nii, nrrd, nhdr, mha, mhd | A label map per case, or masks (one file per structure) in a folder such as segmentations/ Takes several connections. |
Namesnames | Table csv, tsv | For label maps: id, name (and group, color as #rrggbb) Optional. Takes several connections. |
Outputs
| Output | Gives | What it is |
|---|---|---|
3D scenesmodels | Files glb | <case>/<case>_anatomy.glb: every structure of the case, named, coloured and grouped, for the 3D view |
STL for printingstl | Files stl | <case>/<structure>.stl, in millimetres |
Modelstable | Table csv | models.csv: case, structure, group, volume_ml, triangles, pieces, watertight, open_edges, color, note (ready to print or why not) |
Live telemetrytelemetry | Live telemetry | What the block sends while it runs, for views such as Chart or 3D view. |
Settings
| Setting | Default | What it does |
|---|---|---|
Structuresstructures |
empty | Names or groups, separated by commas (liver, kidney_*, vessels, skeleton); empty: all |
Smallest (ml)min_ml |
1 | Structures smaller than this are listed but not built From 0 |
Smoothingsmooth |
15 | Rounds of smoothing that keep the volume (Taubin); 0: the voxels' steps stay From 0 to 200 |
Trianglestriangles |
20000 | Most triangles per structure (fewer: a lighter scene); 0: no limit From 0 |
Scene trianglesscene_triangles |
300000 | Most triangles in a case's 3D scene (about 3.5 MB at 300,000, so it opens in the browser); the STL files are not reduced. 0: no limit From 0 |
Step (voxels)step |
1 | 2 or more: coarser surfaces, built faster From 1 to 4 |
Largest piece onlylargest |
off | Drop small islands of each structure (not for structures made of pieces) |
Formatsformats |
glb + stl | One of: glb + stl, glb, stl |
Where it runs
On one of your computers with the EsaSim worker: Any worker.
The worker installs the Python packages it needs when they are missing: numpy</code>, <code>scipy</code>, <code>scikit-image</code>, <code>trimesh</code>, <code>fast-simplification</code>, <code>SimpleITK.
In its code, settings are ctx.params["key"], inputs ctx.inputs["id"] and outputs ctx.output("id", "name.ext"); see Custom blocks.