Skip to content

Changelog

User-facing changes only, organised by what a user experiences.

0.8.0 — 2026-11-26

dw2d joins dw3d in the repository delaunay-watershed

  • One repository, one version, one changelog, three distributions. delaunay-watershed-3d carries dw3d, as it always has; delaunay-watershed-2d carries dw2d, as it always has; delaunay-watershed, new, holds no code and requires both at its own version, with their extras (viewing, benchmarks) forwarded. pip install delaunay-watershed installs both packages; delaunay-watershed-3d also requires delaunay-watershed-2d at the same version, so it installs both too; delaunay-watershed-2d installs dw2d alone. The imports are unchanged: from dw3d import ..., from dw2d import .... dw2d's code, tests, examples and masks now live in this repository (src/dw2d, tests/two_dimensional, Examples/two_dimensional, data/two_dimensional), with its history; its distribution is built from distributions/delaunay-watershed-2d and the metapackage from distributions/delaunay-watershed. delaunay-watershed-2d 0.1.5 was its last release from its own repository.
  • Upgrading from delaunay-watershed-3d 0.7.1 or delaunay-watershed-2d 0.1.5 needs nothing special. Because each package stays in the distribution that has always installed it, no installed file changes owner, and pip, uv, and an upgrade of foambryo all replace the old release in place. Measured on 24 fresh environments (from 0.7.1, from 0.1.5, from foambryo 0.7.1, and fresh; with pip install --upgrade, after uninstalling first, and with uv pip): no installed file missing or altered, each package listed by its own distribution only, pip check clean, both packages importing and reconstructing.
  • dw2d is licensed under the GNU General Public License, version 3 or (at your option) any later version (SPDX GPL-3.0-or-later), like dw3d, with the agreement of its authors. Its repository's licence file said CC BY-NC-SA 4.0 and its package metadata MIT; dw2d 0.1.5 and earlier keep the licence they were published under.
  • dw2d's requirements are a subset of dw3d's. Python 3.12 or later (dw2d 0.1.5 said 3.6), iorec 1.4.1, NumPy 2.0, SciPy 1.13, scikit-image 0.23.1 and networkx 2.8 or later; dw2d no longer requires Polyscope, which it never imported, nor matplotlib, which it needs only to draw figures and which comes with the viewing extra (pip install "delaunay-watershed-2d[viewing]"). Without it, import dw2d and every reconstruction work, and a plotting call raises an ImportError that names the extra. The test of whether a point lies inside a boundary loop, which dw2d took from matplotlib when it orients the loops of a material with several loops, is now its own exact test; it gives matplotlib's answer on every loop of the golden cases and shipped masks, and no mesh changes.
  • requirements.txt and addition_requirements.txt are removed: the first contradicted pyproject.toml (NumPy 1.24, scikit-image 0.20.0), the second listed what two example notebooks need, which the notebooks say themselves.

One experience in 2D and 3D

The same calls mesh a 2-D or a 3-D mask: dw3d's algorithm hands a 2-D mask to dw2d, and dw2d offers dw3d's names. The new names compute nothing new: on dw2d's 18 golden cases and its 4 shipped masks, every route (the deprecated 0.1.5-style call, dw2d's new names, dw3d's algorithm, foambryo's mask function) gives bit for bit the same points, segments, labels and image-border vertices, with and without junction relocation.

Added

  • A 2-D label image given to dw3d's reconstruction is meshed by dw2d. construct_mesh_from_segmentation_mask and construct_mesh_in_physical_units hand a 2-D mask to dw2d (imported then, on first use) and return dw2d's (points (n, 2), segments (m, 2), labels (m, 2)). dw2d is configured from the algorithm's settings that have a 2-D meaning (min_distance, junction relocation, canonical order, print_info); until a 3-D mask comes again, last_constructed_mesh, last_compressed_segmentation, save_to_rec_mesh, relocation_report, cut_cells and medium_labels are dw2d's, two_dimensional_algorithm is the dw2d object, the 3-D-only reports are None and set_pixel_size, set_global_min_max, center_around_zero and save_to_vtk_mesh raise ValueError. A configuration with no 2-D meaning (boundary-layer, junction-protected or link-checked placement, another EDT, tesselation or face score, physical image faces, mesh surgery off) raises ValueError naming it. dw2d has no dither: the default (dithered) and the deterministic configurations both mesh a 2-D mask with dw2d's placement.
  • dw2d offers dw3d's names. dw2d.get_default_mesh_reconstruction_algorithm(min_distance=4, print_info=False) and dw2d.MeshReconstructionAlgorithmFactory (set_peak_local_points_placement_method, set_junction_relocation, set_canonical_triangle_order, and the 2-D-only set_interface_projection, set_pinch_vertex_repair, set_near_tie_sliver_relabelling, set_label_expansion, set_score_samples) build a dw2d.MeshReconstructionAlgorithm with construct_mesh_from_segmentation_mask, construct_mesh_in_physical_units (square pixels only), last_constructed_mesh, compress_segmentation_mask, last_compressed_segmentation (keys points, segments, labels, seeds, image_shape, image_border_vertices), both_construct_mesh_and_compressed_segmentation, save_to_rec_mesh (text by default, as dw3d), relocation_report, interface_projection_report, image_border_vertices, cut_cells (the cells with a vertex on the image border), unresolved_cells, enclosed_medium_pockets and last_constructed_dcel; one object meshes several masks. Module-level: save_mesh_to_rec_mesh, save_compressed_segmentation, reconstruct_mask_from_dict(dictionary), reconstruct_mask_from_saved_file_dict(filename), relocate_junction_vertices(mask, points, segments, labels, *, gate=3.0, fixed_vertices=()) and project_interface_vertices(mask, points, segments, labels, *, fixed_vertices=()). dw2d.__all__ lists them. Each package keeps its measured default point spacing: 3 voxels in dw3d, 4 pixels in dw2d.
  • Reports and warnings in 2D, with dw3d's names: JunctionRelocationReport and InterfaceProjectionReport (frozen dataclasses with as_dict()), EnclosedMediumWarning (a piece of label 0 that touches no side of the image is meshed as the outer medium: dw2d has no enclosed-medium region yet) and UnresolvedCellWarning (a label of the mask absent from the mesh, named). They are dw2d's own classes, distinct from dw3d's classes of the same names: neither package imports the other at module level.
  • .rec files record their dimension. dw2d's save_to_rec_mesh always writes an appendix (version 1) with dimension = 2, axis_order = yx, source_shape, the image-border vertices and, in physical units, the frame and spacing; dw3d's writes dimension = 3 whenever it writes an appendix, and a file without an appendix is written byte for byte as before. dw3d.io.rec_dimension(filename) tells a 2-D file from a 3-D one by that key, else by its layout (the coordinates per point row of a text file; which binary layout accounts exactly for the geometry's bytes), and refuses a file it cannot classify. dw3d.io.load_rec refuses a 2-D file, naming dw2d.io.load_rec.
  • Every entry point checks the mask's dimension. A 3-D mask with an axis of length 1 is refused with a message suggesting mask[0] (it is never squeezed: one plane may be a 2-D image or a stack cut to one slice); a mask that is neither 2-D nor 3-D is refused; a mask whose dtype is not an integer type warns, and is meshed as before.
  • dw3d's Polyscope viewer draws a 2-D mesh. dw3d.viewing.plot_cells_polyscope takes dw3d's algorithm after a 2-D mask, dw2d's algorithm, or a mesh as three arrays (dw2d's (points, segments, labels), or dw3d's (points, triangles, labels)), and the mesh decides the dimension. A 2-D mesh opens a 2-D window: each cell's boundary as a curve, in the colour the 3-D view gives the same label (the cells are not filled, so no polygon triangulation is needed); Polyscope's (x, y) is (column, -row), a rotation, so the image appears as in napari and matplotlib (row 0 at the top); a camera straight down, with planar navigation while the window is open; Scattered moves the cells apart as in 3D; the new keyword image= draws an image or a mask under the curves on its pixel grid (also for a mesh built in physical units). The 3-D window is unchanged: on benchmark case 000 its recorded calls (simple, scattered, anisotropy, transparency) are bit for bit those of before. An option without a meaning in the mesh's dimension raises ValueError naming it: anisotropy_factor other than 1 with a 2-D mesh (2-D meshes have square pixels), image with a 3-D mesh; so does an unknown view (it opened an empty window).

Changed

  • The viewing extra needs Polyscope 2.5.0 or later (was 2.2.0). The 2-D window of plot_cells_polyscope draws the image through a texture with nearest filtering (filter_mode, from Polyscope 2.4.0) and frames the tissue with get_vertical_fov_degrees (from 2.5.0); with 2.2.0 to 2.4.0 it raised on opening (measured with 2.2.0, 2.2.1, 2.3.0 and 2.4.0; it opens with 2.5.0, 2.6.0 and 2.6.1).
  • min_distance defaults to None in get_default_mesh_reconstruction_algorithm, get_dithered_mesh_reconstruction_algorithm, get_deterministic_mesh_reconstruction_algorithm and the factory's set_peak_local_points_placement_method and set_dithered_peak_local_points_placement_method: 3 voxels in 3D, as before (the meshes are unchanged), and dw2d's 4 pixels for a 2-D mask; a value given is used in both dimensions. The algorithm's requested_min_distance records it.
  • dw2d.io.load_rec returns dw3d's three arrays, (points, segments, labels), and dw2d.io.save_rec(filename, points, segments, labels, binary_mode=False, metadata=None) takes them; both are in dw2d.io only, as in dw3d. They were never released in their (verts, edges) form, so there is no alias; the 0.1.5 readers and writers keep their own form.
  • dw2d prints nothing unless asked (print_info=True): it printed the size of the triangulation's dual graph on every reconstruction, and the mask rebuild printed array shapes.
  • dw2d's options added for 0.8.0 take their mirrored names, without alias (they were never released): deterministic is set_canonical_triangle_order (the analogue of dw3d's canonical_tetrahedron_order; dw3d's "deterministic" configuration means a placement without dither), and relocate_junctions, project_interface_vertices, repair_pinch_vertices and relabel_near_tie_slivers are the factory's set_junction_relocation, set_interface_projection, set_pinch_vertex_repair and set_near_tie_sliver_relabelling. The 2D section below names them as the deprecated geometry_reconstruction_2d takes them. relocate_junction_vertices and project_interface_vertices take dw3d's argument order (the mask first) and return a report dataclass instead of a dict.

Deprecated

  • dw2d.geometry_reconstruction_2d, with its min_dist, return_mesh, return_dcel, export_mesh, export_segmentation and plotting methods: use get_default_mesh_reconstruction_algorithm(...).construct_mesh_from_segmentation_mask(mask). It warns once, when constructed, and computes exactly as before. Every other name dw2d 0.1.5 exported from its top level (the half-edge and plotting helpers of dw2d.Dcel, trace_line, Delaunay_Graph, seeded_watershed_map, the plotting helpers of dw2d.Plotting_tools, ...) still resolves, with a DeprecationWarning naming its module; reconstruct_mask_from_dict given a file name warns and reads the file. All are removed in 0.9.
  • export_mesh with a mode other than 'bin' or 'txt' raises ValueError; it printed "Please choose a valid format" and wrote nothing.

Removed

  • The third-party names that dw2d 0.1.5's star imports leaked (dw2d.np, dw2d.plt, dw2d.pickle, dw2d.struct, dw2d.math, dw2d.dataclass, dw2d.field, dw2d.list2cmdline, dw2d.expand_labels, dw2d.interpolate) are no longer attributes of dw2d. Imports from the modules themselves (dw2d.Dcel, dw2d.functions, ...) are unchanged.

Fixed

  • dw2d's mask rebuild no longer loops for ever when the mesh's vertices are off the pixel lattice, as they are after the junction relocation, on by default since 0.8.0 (it puts junctions on pixel corners, at half-integers). trace_line stepped from one end of an edge by whole pixels until it met the other end exactly, so it never met an end that differed by a non-integer: reconstruct_mask_from_dict hung on every relocated mesh, and so did the 2-D example notebook's mask rebuild. Each end is now rounded to the nearest pixel centre (and clipped into the image). On a 40 × 60 three-cell mask the rebuild did not end within 20 s before; it ends at once, with more than 95 % of the pixels agreeing with the mask. Integer ends are traced as before.

Documentation

  • One orientation rule for dw3d's triangles and dw2d's edges, stated once with the test that decides it (docs/user-guide/orientation-in-two-and-three-dimensions.md): in the mask's index frame, each mesh element is the positively oriented boundary of its first label. A triangle's right-hand normal in (z, y, x) points out of its first label; an edge p0 -> p1 has its first label on its left in (row, column), so its normal (dc, -dr) points out of the first label too. Measured on one cell in the medium, a ball of radius 9 voxels and a disk of radius 20 pixels: the signed volume, −2407 cubic voxels, and the signed area, −1244 square pixels, are both negative (each element bounds the medium). Until this release the two rules were opposite in index order (dw2d's edges bounded their second label, and the disk's signed area was +1244); dw2d's edges were reversed to make them one rule (2D, "Changed (changes results)"), and dw3d's triangles do not change.
  • docs/two_dimensional/README.md states dw2d's licence, GPL-3.0-or-later, in place of the CC BY-NC-SA badge and sentence of its former repository.

Both packages

Changed

  • The .rec format is read and written by iorec (iorec>=1.4.1, a new dependency of both distributions) instead of the copy of iorec 1.0.5 that dw3d.io carried. dw3d.io keeps its names and signatures (load_rec, save_rec, load_rec_appendix, load_rec_with_crop_faces, parse_rec_appendix, write_rec_appendix) and types its own appendix keys as before (APPENDIX_KEY_TYPES: source_shape, crop_offset, crop_faces, media, enclosed_media_voxels, unresolved_regions, unresolved_regions_voxels as tuples of integers, spacing and enclosed_media_inscribed_radius as tuples of floats, resampled_spacing as a float); dw2d's new load_rec and save_rec call iorec's 2-D functions. Measured on every .rec file the tests write, on the 47 benchmark meshes, the 76 converged meshes and foambryo's three golden meshes (163 files, 15 with an appendix): the same arrays (bit for bit, same dtypes) and the same typed appendix values as with the copy. A file without appendix is written byte for byte as before (binary and text); a binary file is now little-endian on every machine (it was in the machine's order, the same on x86 and ARM); points of a dtype other than float64 are written in text as the float64 they are read back as. Appendices written in iorec's version 2 (# key: <JSON> lines) are read too, their values typed by their JSON.
  • The appendix written is version 1 (# key = value lines), on purpose. iorec writes version 2 by default; delaunay-watershed-3d 0.7.1 and foambryo 0.7.1 read a version-2 block without any error but lose every key of it, because their parser splits each line on =: measured on the 15 files with an appendix, rewritten in version 2, a file's crop faces (read as contact with the medium, which foambryo 0.7.1 flags only by its heuristic UnrecordedCropFacesWarning), its media, its unresolved regions and its physical spacing all vanish. In version 1 both read every key. dw3d.io.APPENDIX_VERSION_WRITTEN is 1. The appendix now also carries writer_library = iorec <version> after written_by (dw3d's version, as before).
  • Python 3.12 or later (3.11 before): iorec 1.4.1 requires it, and the CI tests 3.12, 3.13 and, for dw2d, 3.14.
  • ThinMediumMarginWarning gives each named cell's mesh volume over its voxel count (in 2D, its mesh area over its pixel count), to two decimals, after the reason the face was not padded: "..., mesh volume 2.10 times its voxel count". On a real 1 866-cell stack the warning named cells whose volumes were normal; the ratio tells them from a cell that took the medium between it and the face (a ratio above 1). The ratio is computed as cell_volume_report computes it. Both warnings now end "The mesh of such a cell may include medium between it and the face, which makes its volume larger than its voxel count".
  • dw3d.mask_preprocessing and dw2d.io declare their public names in __all__: every function, class and constant each defines (isotropic_spacing, coarse_axis_and_factor, resample_to_isotropic, ...; load_rec, save_rec, load_rec_appendix, ...), the names napari-foambryo uses among them. Nothing is renamed or removed; from dw3d.mask_preprocessing import * no longer brings the modules they import (numpy, ...).

3D (dw3d)

Fixed

  • A cell a few voxels from the image box no longer takes the medium between them. The distance field is 0 on the image box's outer voxels, below the membranes (0.73 on a flat membrane), and a minimum is placed only where no lower voxel lies within min_distance; so the membrane facing a nearby face of the box lost its points to the box (at a margin of 2 or 3 voxels it had none at all, at min_distance 3), the tetrahedra joining the cell to the box spanned the medium, and the watershed gave them to the cell. At min_distance 3 a 12-voxel cube 4 voxels from every face meshed to 2.98 times its voxel count, the two boxes of a 24-voxel smoke mask to 2.46 and 2.44 times; the range grows with min_distance (up to margins of 5–7 voxels at 3, 7–8 at 4, 8–10 at 5). Now, when the first mesh has a vertex on a face of the image box that no cell reaches, the mask is meshed again padded with label 0 on every such face whose margin is below 2 * min_distance + 2 voxels, up to that margin, and the mesh is returned in the mask's frame (medium_margin_padding names the faces and widths). The mask's own voxels keep the random dither of the point placement that they have unpadded, so the mesh changes only within the padded faces' reach. On cubes of side 12 to 24 at margins of 2 to 5 voxels the volume ratio is now 0.75–1.09 (the 12-voxel cube 4 voxels away: 1.09), the smoke mask's boxes 1.01 and 0.81; an 8-voxel cube no longer exceeds 1.5 times its voxels, though it can fall to 0.10, as it does on 2 of 20 dither seeds 8 voxels from every face without any padding. No triangle of a cell is left on a face it does not reach, no mesh gains an abnormal edge or a self-intersection, and every region stays closed. Because the box no longer clips the cell, its surface may reach past the image box on a padded face, by at most the padding: measured at up to 7 voxels on a 16-voxel cube 1 voxel from every face, 1 to 4 voxels on foambryo's test masks, 0 to 2 voxels on the lab's data (below). A face that a cell reaches is a crop, is never padded, and no vertex passes it; a cell left with triangles on a face it does not reach is named by the new ThinMediumMarginWarning, with the face and its margin. pad_thin_medium_margins=False (constructor argument or attribute) gives the previous meshes. construct_mesh_in_physical_units does not pad a mask it resamples (voxels longer along one axis) unless asked for that call (its new pad_thin_medium_margins=True), because there the padding made the watershed lose cells more often (Known issues); such a mask keeps 0.7's thin-margin meshes, and ThinMediumMarginWarning names each cell that lies on a face it does not reach. Masks of cubic voxels are padded on both routes. Which meshes change: "Changed (changes results)" below. See dw3d.thin_medium_margins and the user guide's page on cropped tissues.
  • A mask whose mesh has no triangle no longer raises AxisError; the mesh is returned empty and its cells are named. A cell too small to hold a tetrahedron's centroid (a cube of side 1 to 4 voxels at min_distance 3), or a mask of label 0 only, gave a mesh with no triangle, whose empty triangle array lost its column and made np.cross raise AxisError: axisa: axis 1 is out of bounds. The triangles are now (0, 3), the labels (0, 2), and UnresolvedCellWarning names each cell (no tetrahedron in its voxels); save_to_rec_mesh writes the empty mesh, which load_rec reads back.
  • save_to_vtk_mesh (and dw3d.io.save_vtk) refuses a mesh without triangles with a ValueError that says why, and writes nothing. meshio 5.3 raised IndexError writing such a .vtk file, binary or not, and wrote .vtu files that its own reader then failed to read; it cannot read an empty binary legacy .vtk file either, so an empty file of these formats would not come back as a mesh. The message points to save_to_rec_mesh, which writes an empty .rec file.
  • Every label of the mask that the finished mesh lacks is now named, whatever the cause. Since 0.7.1 a region with no tetrahedron in its voxels was named (UnresolvedCellWarning, enclosed_medium_report.unresolved, the .rec file's unresolved_regions). A region that was seeded but lost in the watershed was not: the seeded watershed can leave a cell only its seed tetrahedron (the rest of the cell, grouped without the seed, goes whole to the first seeded neighbour it reaches), mesh surgery then relabels that tetrahedron, and only CellVolumeDisagreementWarning listed the cell, among the cells whose volume disagrees. The reconstruction now checks the finished mesh against the labels of the mask it meshed, adds every absent region to unresolved, and emits UnresolvedCellWarning once, after the mesh is finished, naming each region with its voxel count and its cause. UnresolvedRegion gains cause ("no tetrahedron in its voxels", "removed by mesh surgery", "no watershed seed" or "no triangle in the mesh"), tetrahedra_after_the_watershed and tetrahedra_in_its_voxels; the three default to the 0.7.1 meaning. The mesh does not change. Measured with the default configuration: on the cut ball of the known issue below, cell 1 is named (removed by mesh surgery, 1 of the 33 tetrahedra centred in its voxels); on the default meshes of two real embryo series (492 frames), 54 cells are absent from the mesh in 8 frames, of which 26 were named only by CellVolumeDisagreementWarning (25 of them in 7 frames that real-data work leaves out as over-segmented; the other, in a frame that is used, is a cell of 12 260 voxels that keeps 1 of the 73 tetrahedra centred in it, while a neighbour comes out at 1.99 times its voxels); on the 47 benchmark masks and on 433 plane crops of them, every absent cell (2 and 21) has no tetrahedron in its voxels and was already named. foambryo's foambryo mesh summary and MaskReconstruction.unresolved read the regions from the report, so they now list these cells too.

Known issues

  • The seeded watershed can lose a cell, often a cell cut by the image box, and with it the crop report names the wrong cell. A cell's seed is the tetrahedron whose centroid is nearest to the cell's deepest voxel. Against the image box this can be a sliver whose faces all score below a face through which the rest of the cell, grouped without its seed, reaches a seeded neighbour; that neighbour takes the group whole, and the cell keeps only its seed. On a test mask of four cells filling a ball that the 36³ image box cuts (cells 1, 3 and 4 have voxels on the box), at the default min_distance 3 on cubic voxels (unit or 0.5), cell 1 (1 648 voxels, 262 on the cut face) is absent from the mesh and cell 2 comes out at 1.37 times its voxels; cut_cells then reports 2, 3 and 4, cell 2 holding the crop faces that would have been cell 1's, and crop_face_report.cells_reaching_a_crop_without_a_crop_face names cell 1. At min_distance 1 and 2, and with z twice as long as x and y (resampled), every cell is meshed and cut_cells is 1, 3 and 4. On the same ball at 36 positions along z, from cut through its centre to uncut, at min_distance 2 to 5, 16 cells are absent in 144 reconstructions (2 of them in an uncut ball, at min_distance 4 and 5); on 433 plane crops of the benchmark masks, cut_cells misses a cell on the box in 5, each lost or nearly lost by the watershed (4 absent and named, one at 0.015 of its voxels), and names in addition, by its definition, cells with a vertex on a crop face (51 crops). Since this release the absent cell is named (above). A cut cell's mesh volume can be at most about the volume of its voxels inside the box of voxel centres, since the mesh stops at the centres of the outermost voxels: 0.92 of the voxel count for cell 1 here. These counts were measured without the padding of thin medium margins (above). With it, the default, the test mask's four faces that no cell reaches are padded (the ball is 4 voxels from them) and cell 1 is in the mesh only as a fragment of 4 triangles, 0.010 of its voxel volume inside the box of voxel centres, while cell 2 comes out at 1.25 and cell 4 at 0.42 times their own; cut_cells is then 1, 2, 3 and 4. The watershed's defect is unchanged (pad_thin_medium_margins=False reproduces the loss above). With z twice as long as x and y (a resampled mask, so not padded by default), cell 1 keeps 0.98 of that volume (0.86 when padded). Of the 54 cells absent from the meshes of the real embryo series, 45 are in the 5 padded frames: none is recovered by the padding (each lies 32 to 102 voxels from the padded face, and is lost by the watershed or has no tetrahedron in its voxels, not by the box), and no other cell becomes absent.
  • On a resampled mask the padding of thin medium margins would make the watershed lose cells more often, so construct_mesh_in_physical_units does not pad such a mask by default. On foambryo's test mask of four cells filling a ball 4 voxels from the image box, with z twice as long as x and y (resampled to cubic voxels, then padded on its four faces in x and y), over dither seeds 42 to 141 of the point placement, a cell kept less than half of its voxel volume inside the box on 20 of 100 seeds with the padding (95 % interval 0.13–0.29) against 3 of 100 without it (0.006–0.085); 17 seeds lost a cell only with the padding and none only without it (McNemar exact p = 1.5e-5). On the same ball with cubic voxels, 13 against 10 (p = 0.51). The cell is lost in the watershed, not at its seed nor in mesh surgery: the cell facing a padded face hands most of its interior to the medium through a face that straddles its outer membrane, before that interior reaches its own seed. The distance field there is not changed by the padding; the tetrahedralisation near the padded faces is (the lost cell holds 5 to 16 fewer tetrahedra). Why this happens more often on resampled masks was not found. The cost of leaving such masks unpadded is the defect itself: on the same ball with x 2.5 times as long, cell 4 comes out at 7.47 times its voxel volume unpadded (0.78 padded), and with z 2.5 times as long cell 2 at 6.14 (padded: 1.29, while cells 3 and 4 fall to 0.48 and 0.46); ThinMediumMarginWarning names such cells. pad_thin_medium_margins=True in construct_mesh_in_physical_units pads anyway. On the two real anisotropic stacks tested, a 110-cell and a 1 866-cell tissue (z/xy = 5/3), the default (no padding on a resampled mask) lost or inflated no cell near an image face. On the 1 866-cell tissue, whose z faces have thin margins (2 and 3 resampled voxels), the 9 cells within 8 voxels of a face kept a mesh volume of 0.88 to 1.05 times their voxel volume over 5 dither seeds, within the range of its interior cells (0.84 to 1.05); ThinMediumMarginWarning named 3 to 6 of them, depending on the seed, although their volumes were normal. Padding (pad_thin_medium_margins=True) lost no further cell on that tissue over the same seeds, and lowered the volume of the four cells nearest a face by 0.01 to 0.09 of their voxel volume; which of the two is closer to the true volume is not known. Two stacks give no rate over stacks, and five seeds bound a per-seed loss rate only to 0.52 or less (95 %).
  • The padding is decided from the first mesh's vertices, which misses a cell that collapses without reaching the image box. On cubes of side 6 to 12 voxels at 1 to 5 voxels from one face or from every face, at min_distance 3 to 5 and 10 dither seeds (1 200 reconstructions), 25 cubes collapsed to 0.00–0.49 of their voxels with no vertex on a face of the image box, so the mask was not padded; padded, the same masks give 0.58–0.80, and the same cubes with the same seeds 16 voxels from every face give 0.51–0.71 (another 50 small cubes collapse whether padded or not). dw2d decides its padding from the mask (its "Fixed" below); dw3d keeps the decision from the mesh's vertices in this release, so the two packages decide differently. Whether a cell collapses this way can depend on the platform: the points lie on the integer lattice, and Qhull chooses the tetrahedralisation of their cospherical sets by floating-point rounding, so the 8-voxel cube 5 voxels from every face (min_distance 3) is padded on macOS arm64 but, on GitHub's Linux runners, collapses before the decision to a 4-vertex mesh (0.06 of its voxels) and is not padded.

Changed (changes results)

  • The padding of thin medium margins (under "Fixed") changes the meshes of 18 of the lab's 684 test masks; every other mask is meshed bitwise as before. Measured with the default configuration, meshed in voxel units (construct_mesh_from_segmentation_mask), on the 47 benchmark masks, the 141 masks of the resolution sweep, the 492 frames of two real embryo series and the four test images: the 47 benchmark masks and the four test images are unchanged, so every number in BENCHMARKS.md stands (none is measured on the resolution sweep). The 18 that change are 13 resolution-sweep masks at the coarsest size (margins of 3 to 5 voxels) and 5 frames of one embryo series, all among the over-segmented frames that real-data work leaves out. On the 11 equilibrium sweep masks, against the Neumann angles of their known tensions, the median absolute error of the line-mean contact angles (foambryo's production reading) gets better on 4, worse on 4 and stays the same on 3, with a median paired change of 0.00° (largest: −1.28° and +1.92°); the gauge-matched YoungDupre tension error gets better on 7 and worse on 3 (median change −0.0003). Every value that gets worse stays within the range the same mask gives over ten other seeds of the point placement's dither (for the +1.92°: 12.31° against a range of 8.47–15.66°). On the 2 non-equilibrium sweep masks the angle error grows by 1.81° and 1.02°, inside or below their seed range. On the 5 embryo frames, 4 to 18 of about 700 line-mean wedges change, all near the padded face. Their 14 triangles on faces their cells do not reach go to 1 (on one frame, named by ThinMediumMarginWarning); vertices pass the image box by 0 to 2 voxels. One cell that came out at 1.45 times its voxels stays there: that value is the dither's draw (0.88–1.06 on nine other seeds), not the margin's doing.
  • reconstruct_mask_from_dict rebuilds the mask exactly from the mesh's own triangles, and no longer depends on trimesh; rebuilt masks change and agree better with the original. Every voxel centre now takes the label of the region of space the mesh's triangles enclose it in: two neighbouring centres are in the same region when the segment between them crosses no triangle, decided in exact arithmetic, and each region takes the index of the seed it holds. A centre lying exactly on a surface, which is common because most mesh vertices sit on the voxel lattice, goes to the region it enters when moved infinitesimally towards increasing index along axis 0, then 1, then 2 (towards decreasing index on the last voxel of an axis, so that a cell cut by the image box keeps its outermost voxels). A region holding several seeds goes to the deepest one (the others belong to cells absent from the mesh, which now get no voxel), and a region holding no seed (a few voxels cut off by a sliver thinner than a voxel) to the region it shares the most neighbouring voxels with. Before, the mesh was subdivided with trimesh, the voxels nearest its vertices were marked as membrane and the rest was flooded by a seeded watershed, and the result depended on the trimesh release (509 to 819 voxels per test image between trimesh 4.12.2 and 5.1.1). Measured on the default meshes (min_distance 3) of the four test images and the 47 benchmark masks: agreement with the mask rises from 98.44–99.32 % to 99.19–99.73 % on every one of the 51 (median gain 0.58 percentage points), the rebuild takes 0.3–1.1 s instead of 5–10 s, and the rebuilt masks of the four test images are bit for bit the same with numpy 2.0 to 2.5 and SciPy 1.13 to 1.18 (a test checks their SHA-256). The compressed segmentation's format, the output labels (seed k fills label k) and the dtype (int64) are unchanged.
  • trimesh is no longer a dependency. It was used only by reconstruct_mask_from_dict.

2D (dw2d)

Runs on current scientific Python

  • dw2d runs on SciPy 1.14 and later and on NumPy 2. scipy.interpolate.interp2d, removed in SciPy 1.14, is replaced by a bilinear interpolant on the pixel grid, written with NumPy ufuncs so that it gives the same last bits on every machine; the edge scores and the exterior-triangle test are vectorised. On every golden case the reconstruction is bitwise the one of dw2d 0.1.5 on SciPy 1.13 with interp2d, given the same Delaunay triangulation.

Fixed (changes results)

  • DCEL_Data.compute_lengths and DCEL_Data.compute_curvatures were wrong on most interfaces; compute_lengths is now the length of each interface, the sum of its edges' lengths. Where the half-edge structure reversed a material's boundary loop to orient it, it reversed the order of the loop's half-edges but not their endpoints, so each half-edge ended where the next did not begin; walking such a face, compute_lengths and compute_curvatures cut every interface one edge off its junctions, and a closed loop without junction (a cell enclosed by the medium) lost its last edge. On the shipped masks the two lengths disagreed on most interfaces (on mask_Cells_2 with expansion_labels=6, 103 of 146 at min_dist=3; on mask_Cells_8 without expansion, every one of its 68 enclosed cells); now they agree to rounding on every golden case and every shipped mask, with and without relocation (tests/two_dimensional/test_dcel_lengths.py), and every half-edge ends where the next begins. Over the shipped masks (five masks, expansion_labels 0 and 6, min_dist 3 and 5, relocation off and on: 2 080 interfaces that change), the former lengths were off by a median 7.4 % and by more than a factor 2 on 50 short interfaces (2 to 17 px, one or two edges); compute_curvatures changes on the cell-cell interfaces, whose ends are now the junctions. The mesh (return_mesh), compute_angles and compute_area_faces are bitwise unchanged on every golden case and shipped mask. foambryo does not read these quantities.
  • DCEL_Data.compute_curvatures reads every vertex of a closed loop without junction. On a closed loop (a cell enclosed by the medium, or a pocket of medium inside a cell) the walk left out the loop's first and last vertices, so the length-weighted Menger curvature of that interface missed two of its vertices. Over the shipped masks and the golden cases (min_dist 3, expansion_labels 0 and 6, relocation off and on: 56 meshes, 2 218 interfaces), 228 of the 228 interfaces with such a loop were off, by a median 3.5 % and at most 20 %; no other interface changes, and the golden cases have no such loop. compute_curvatures now equals, to rounding, the same sum read straight from the mesh's edges on every golden case and every shipped mask (tests/two_dimensional/test_dcel_curvatures.py). foambryo does not read it.
  • Every edge has a stated orientation, the image-border edges included: m1 < m2, and each edge is oriented by one rule (stated in "Changed (changes results)" below, where every edge is also reversed). It held on every interior edge already; the edges along the image border took the triangle of another edge (a stale loop variable) and came in an arbitrary order (on mask_Cells_7, 164 of 165 were reversed). They are now oriented like every other edge, with the medium, outside the image, on the side the rule gives m1, so each material's edges run around it in one sense. Only the vertex order of border edges changes: no vertex moves, no edge or material changes, and the meshes without a cell cut by the image border are bitwise unchanged (every golden case but mask_Cells_2 with expansion_labels=6, where 212 of 634 edges at min_dist=3 and 130 of 380 at min_dist=5 are reversed). The half-edge structure's lengths of the medium interfaces of such meshes change accordingly (for example 21 to 23 px, now the sum of their edges' lengths). The contract is documented in Clean_mesh and tested on every edge of the golden cases and the shipped masks, with and without relocation and projection; foambryo's 2D pressures rely on it.

Fixed

  • A cell a few pixels from the image border no longer takes the medium between them, nor collapses: the same rule as in 3D (dw2d.thin_medium_margins). dw2d's distance field is also 0 on the image border, and its membrane points are also placed only where no lower value lies within min_distance, so the membrane facing a side a few pixels away lost its points. Measured on squares (side 12, 20, 32 pixels), squares near one side, a doublet and disks, at min_distance 3, 4 and 5: at margins of 2 pixels up to about min_distance, the cell's area was 1.04 to 1.73 times its pixels (a 20-pixel square at min_distance 4: 1.25, 1.37, 1.28 at 2, 3, 4 pixels), and a 12-pixel square 3 or 4 pixels from one side collapsed to a triangle of 0.23 times its pixels at min_distance 5; from min_distance + 1 or + 2 pixels on, nothing of it. Now every side of the image that no cell reaches and whose margin is below 2 * min_distance + 2 pixels is padded with label 0 up to that bound before meshing, and the mesh is returned in the mask's frame; a side a cell reaches is a crop and is never padded. dw2d places its points without a random dither, so it decides from the mask, with one run (dw3d decides from a first mesh: in 2D the cell can take the margin without reaching the side, and the collapsed square has no vertex near it). On all those masks every cell at a margin of 1 to 10 pixels now meshes to 0.84–0.99 times its pixels (0.23–1.73 before), as at 16 pixels, where nothing changes. The option, the record and the warning have dw3d's names: pad_thin_medium_margins (default True; False gives the previous meshes), medium_margin_padding, and ThinMediumMarginWarning, exported by dw2d. dw3d's algorithm passes its pad_thin_medium_margins to dw2d for a 2-D mask, and its medium_margin_padding is then dw2d's. None of the workspace's 2-D masks is padded (dw2d's shipped masks and test fixtures, its golden cases, and the 147 frames of the Developmental Cell 2026 datasets: the smallest margin of a side no cell reaches is 12 pixels), so their meshes are unchanged.
  • DCEL_Data.plot_local_curvature ends on a mesh with relocated junctions. It traced each edge by unit steps until it met the far end exactly, so it never ended, and its list of pixels grew without bound (34 GB before it was stopped), when the two ends of an edge differed by a non-integer, as they do on every mesh relocated by default since 0.8.0 (junctions on pixel corners). Its trace_line is now the mask rebuild's, which rounds each end to the nearest pixel centre; a pixel rounded past the image's edge is drawn on the border pixel. On integer ends the traced pixels are those of before.
  • A mask whose 2-D mesh has no edge no longer raises IndexError; the mesh is returned empty and its cells are named. A cell too small for a triangle (a 12-pixel square 1 pixel from every side at min_distance 5) or a mask without a cell made Clean_mesh fail in reorient_edges. The segments and labels are now (0, 2), UnresolvedCellWarning names the cells, and last_constructed_dcel says that the mesh has no edge (ValueError) instead of failing in numpy.

Changed (changes results)

  • Every edge is stored the other way round: the order of the two vertices within each edge is reversed, and nothing else changes. Each edge [v1, v2, m1, m2] is now the positively oriented boundary of m1 in the index frame: m1 lies on the left of v1 -> v2 in (row, column) (it lay on the right before, i.e. on the left in (x, y) = (column, row)), which is dw3d's rule for triangles, so that one rule holds in both dimensions (docs/user-guide/orientation-in-two-and-three-dimensions.md). Every route returns and writes the new order: construct_mesh_from_segmentation_mask, last_constructed_mesh, last_constructed_dcel and DCEL_Data.e, the compressed segmentation, .rec files (text and binary), the deprecated geometry_reconstruction_2d(...).return_mesh() and export_mesh, and dw3d's object given a 2-D mask. No vertex, edge, label or edge order changes: on the 18 golden cases, the regenerated golden master differs from the former one only by the two vertex columns of each of its 2 221 edges, and the vertices, seeds, edge scores, triangles and their labels and the half-edge angles, lengths, curvatures and cell areas are bitwise the same. The mask rebuilt from a compressed segmentation is bitwise the same (each edge is traced from its second vertex, as before). One consequence for code that reads the edges' direction: dw2d.Dcel.compute_areas, the signed area of each material from the oriented edges, now gives each cell its area with a positive sign (negative before). save_to_rec_mesh records the rule in the file's appendix, orientation = boundary_of_first_label (dw2d.io.ORIENTATION_RECORDED); files written before carry no such key, and foambryo 0.8.0 reads either orientation to the same tensions and pressures.
  • The mesh is the same on every machine (deterministic=True, the new default). Where four or more seed points lie on one circle, which is frequent because they are integer pixels, the Delaunay triangulation is not unique, and Qhull picks one triangulation on Linux x86-64 and another on macOS arm64. Every such cell is now triangulated by a fixed rule (a fan from a vertex chosen by a SHA-256 hash of the cell's points), triangles and graph edges are listed in a canonical order, and the seeded watershed uses a stable sort, so the reconstruction no longer depends on the machine, on Qhull's row order or on the NumPy version. Against dw2d 0.1.5, 2 of the 18 golden cases change (two doublets at min_dist=3, where the rule takes the other diagonal of one cocircular cell: one interface length changes by about 0.05 %, no angle changes). deterministic=False keeps the legacy route.
  • Pinch vertices and label fragments are repaired (repair_pinch_vertices=True, the new default). On tissue masks the labelled triangulation can leave a cell in two pieces, or a material in two sectors around one vertex, and return_dcel then failed. The repair relabels a few triangles (it never moves a point), and the half-edge structure accepts several boundary loops per material. Where nothing needs repairing the result is bitwise unchanged: on every golden case, and on every shipped mask whose half-edge structure could be built before (14 of 24 mask and parameter settings). On the other 10, return_dcel used to raise and now builds the mesh. repair_pinch_vertices=False keeps the previous labelling.
  • Z-shaped folds along membranes are removed on the plain reconstruction (relabel_near_tie_slivers, on by default unless relocate_junctions=True). Along a membrane, the Delaunay triangulation has pairs of flat triangles whose three points all lie on the membrane; where the seeded watershed gave the two triangles of such a pair different labels, the interface turned back on itself twice within a few pixels. When the watershed's choice was a near tie (the triangle's best edge score towards its own label exceeds its best edge score towards its neighbour's label by less than 0.1 px) and taking the neighbour's label strictly removes such turn-backs at the triangle's three vertices, the triangle now takes that label. No point moves. Measured on synthetic equilibrium foams with known tensions and pressures (159 images, min_dist=3): with cells of 40 px radius it relabels 453 triangles in 48 of 53 images and removes every such fold, with 20 px cells 4 triangles in 4 images, with 10 px cells none; junction angles read by chords are unchanged on every image, and over the 52 changed images the pressures inferred from the plain mesh are more accurate by a median 0.0026 of the RMS true pressure (95 % interval 0.0013 to 0.0053; better on 38, worse on 14); no angle, tension or pressure error became measurably worse. On every golden case and on the shipped real masks it relabels nothing, so their outputs are unchanged. On the route with relocate_junctions=True it is off by default: there the pressure change was not distinguishable from zero (median -0.00011, interval -0.0030 to +0.0015; better on 27, worse on 25); relabel_near_tie_slivers=True turns it on for that route (on the same 159 images the projection then refuses no move at all, where without it it refuses 291 crossings and 143 contacts with 40 px cells and 4 crossings with 20 px cells), False turns it off everywhere. The report is near_tie_sliver_report.
  • Junctions are moved onto the mask's own junctions (relocate_junctions=True, the new default). Every junction vertex with an unambiguous counterpart moves onto the corner where three labels meet between pixels, connectivity frozen, under guards against edge crossings and contacts. Measured on synthetic equilibrium foams with known tensions (53 held-out tissues, 661 exact, cropped and noisy images, cells of 10 to 40 px radius), with foambryo's circular-arc reading of the angles: the junctions move from 0.65 to 0.42 px of the true ones (medians), the junction-angle error falls by 0.85 degrees (95 % interval 0.75 to 0.95) and the relative tension error by 0.007 (0.004 to 0.010); per tier (cell size, crop, noise level) it is better or not resolved in 13 of 14, including boundary noise of 0.75 px, the level measured on real 2D masks, and worse in one (0.5 px of noise with 40 px cells: +0.007, interval 0.000 to 0.012); on its own, with chord angles, it lowers the angle error by about 1.8 degrees and the tension error by about 0.025. Because the near-tie sliver relabelling is off on the relocated route, it is now off by default too. relocate_junctions=False gives the plain reconstruction.
  • The vertices on the image border are marked, and the junction relocation never moves them. geometry_reconstruction_2d takes them from the triangulation's structure before any vertex moves (the endpoints of its hull edges, which run along the image border because the four image corners are triangulated with the points: image_border_vertices, also dw2d.Dcel.image_border_vertices), passes them to the relocation and the projection as vertices never to move (fixed_vertices), and hands them on as DCEL_Data.image_border_vertices (return_dcel) and in export_segmentation. Where the mask has medium pixels on the image border next to two cells, the relocation used to move the junction there onto the mask's junction, 0.7 to 2.9 px inside the image, where foambryo, which recognised the border by the vertex positions, read it as an interior junction with a wedge in the medium cut by the border. On mask_Cells_2 (expansion_labels 0 and 6, min_dist 3 and 5) and 78 cropped synthetic foams (cells of 10, 20 and 40 px radius), 7 of 972 border junctions moved so; they now stay on the border and foambryo 0.8.0 excludes them by the mark. Nothing else moves differently (no other vertex of the 82 meshes), and the golden cases are bitwise unchanged. The relocation report gains fixed, the planned moves dropped because the vertex is on the border.
  • dw2d 0.1.5 as written is geometry_reconstruction_2d(..., deterministic=False, relocate_junctions=False, repair_pinch_vertices=False, relabel_near_tie_slivers=False).

Changed

  • The .rec reader and writer are named after the format, in dw2d.io: load_rec(filename) returns (points, segments, labels) and save_rec(filename, points, segments, labels, binary_mode=False, metadata=None) writes them, as dw3d.io does (see "One experience in 2D and 3D"). load_rec detects binary or text from the content: points (n, 2) float64 in the mask's (row, column) order, segments and labels (m, 2) int64; save_rec chooses the layout by binary_mode; both require the file name. Both go through iorec (iorec.load_2d_rec, iorec.save_2d_rec), and export_mesh writes with save_rec. The binary layout is unchanged, byte for byte. Text files now hold every coordinate exactly (the shortest text that reads back to the same float64), where the old writer rounded them to 5 decimals: on the shipped masks every coordinate has at most 5 decimals, so only the formatting changes (12.5 for 12.50000) and the arrays read back are bit for bit the same. Files written by earlier versions read to the same arrays and dtypes as with the old readers. The names of dw2d 0.1.5, read_rec_file_bin, read_rec_file_num, open_mesh_multitracker, write_mesh_bin and write_mesh_text (in dw2d.Dcel), still work through 0.8.x: they call the new functions, return what they returned before, and emit a DeprecationWarning that names the replacement; they will be removed in 0.9. open_mesh_multitracker no longer has a default file name (it named a path on one author's machine) and no longer reads its type_file argument: the layout is detected.

New options (off by default)

  • project_interface_vertices=True, together with relocate_junctions=True, then moves every interface vertex onto its label pair's interface in the mask. Measured on the same synthetic foams, the two together lower the angle error by about 2.5 degrees; the projection alone made it worse, so requesting it alone raises an error.
  • Neither option makes two edges touch. Besides crossings, the guards now refuse any move after which an edge touches another edge it did not touch before (an endpoint lying on another edge, two vertices at the same point, collinear edges overlapping, or an edge folding back by exactly 180 degrees onto its neighbour), decided with exact arithmetic; the vertex then stays where it was. On the synthetic foams with cells of 40 px radius, the projection used to flatten a Z-shaped turn of the plain mesh onto the edge before it 141 times in 38 of 53 images; it now refuses those 143 moves and leaves no such contact. With 10 and 20 px cells, and on every golden case, the vertices are unchanged. The reports gain contacts_before and contacts_after, and a refusal is counted under "contact".

Development of this release was supported by Anthropic's AI for Science program; parts of the code were written with Claude and reviewed by the developers.

0.7.1 — 2026-10-26

Changed (changes results)

  • The mesh no longer depends on the order in which Qhull returns the tetrahedra; meshes change slightly. dw3d read the row order of the tesselation's tetrahedra in three places: the watershed's tie-break between faces of exactly equal score (about a third of the faces tie exactly), the lookup of the seed tetrahedra, and the order in which mesh surgery walks the tetrahedra around an edge. That order is not a property of the tetrahedralisation: Qhull changes it when the same points come in another order, and may change it between machines. Every reconstruction now puts the tetrahedra in a canonical order first (vertex indices sorted within each tetrahedron, tetrahedra sorted lexicographically): canonical_tetrahedron_order=True, the new default of MeshReconstructionAlgorithm, of MeshReconstructionAlgorithmFactory (set_canonical_tetrahedron_order) and of every get_*_algorithm. Measured with the default configuration on the 47 benchmark masks: 9 row orders of the same tetrahedra gave 9 different meshes in the median case, moving the median line-mean contact-angle error of one case by up to 0.78 degrees and its median tension error by up to 3.8 percentage points; under the canonical order all 9 give the same mesh, in 47 of 47 cases. Against 0.7.0, the canonical order changes 45 of the 47 benchmark meshes slightly, by a few faces (median 13 of a few thousand), by about as much as one more row order would. With the default configuration (junction relocation on), read by foambryo 0.7.0 on the 40 benchmark cases at equilibrium (median over cases of each case's median): the line-mean contact-angle error goes from 6.228 to 6.253 degrees under the chord reading and from 5.172 to 5.122 degrees under the second-order (quadric) reading, and the median relative tension error after matching the scale (YoungDupre) from 0.0777 to 0.0763. Set canonical_tetrahedron_order = False on an algorithm (or call set_canonical_tetrahedron_order(False)) to keep Qhull's row order and reproduce 0.7.0's meshes on the same machine. Between machines, remaining differences are expected only at exactly cospherical points (five or more lattice points on one sphere, where Qhull's choice of tetrahedralisation itself may differ); this is confirmed on Linux x86-64 CI (GitHub Actions runs 40213651795 of delaunay-watershed-3d at fe02db4 and 40179726210 of foambryo at f61c603: Ubuntu 24.04, Python 3.12 and 3.13, newest and lowest supported dependencies).

Fixed (changes results)

  • An enclosed pocket of medium is now its own region, flagged as a medium, instead of part of one cell; meshes of masks with a lumen change. A piece of label 0 that touches no face of the image (a lumen, a cavity) had no watershed seed: label 0 got one seed, at its deepest voxel, normally in the exterior. The first cell the pocket's tetrahedra reached took all of it. On a public 697-cell embryo with a 389 918-voxel lumen, one lining cell came out at 2.40 times its voxel volume, with a pressure of 0.051 instead of 0.084, and no lining cell kept a membrane against the lumen; on 8 cells around a hollow core, a 7 251-voxel core inflated its cell to 1.40 times with no warning. Now a pocket lined by two or more cells, with an inscribed radius of at least min_distance + 1 voxels (4 at the default 3), gets its own label: max + 1, max + 2, ... in the order of each pocket's lowest raster index. On the embryo every cell's mesh volume is then between 0.903 and 1.024 times its voxels, and the lumen's 1.029; foambryo infer gives the lumen its own pressure (0.037) and cell 579 its own (0.085). Smaller pockets hold no tetrahedron at min_distance 3 and stay as before; a pocket lined by a single cell (a hole in that cell's segmentation, whose surface would have no triple line) stays with its cell. Both are reported (EnclosedMediumWarning, below). label_enclosed_media = False on an algorithm keeps every pocket to the cells, as in 0.7.0.
  • Every piece of medium that touches the image box is exterior and gets its own watershed seed; a cell no longer takes part of the exterior. When cells spanning the image cut the medium in two, one half had no seed and a cell took it; when an enclosed pocket was deeper than the exterior (a tight crop), label 0's one seed fell in the pocket and a cell took the exterior (22 to 29 times its voxel volume on a hollow shell with 6 voxels of margin).
  • A watershed seed now starts inside its own region; a region with no tetrahedron of its own is absent from the mesh and named, instead of growing inside a neighbour. Each seed is the tetrahedron whose centroid is nearest to the label's deepest voxel. When that centroid lay in a neighbouring region (a region too thin or too small for the tesselation), the region grew inside its neighbour as a phantom. Such a seed now moves to the nearest tetrahedron inside its label. When no tetrahedron centroid lies in the label's voxels, the seed is dropped: the region is absent from the mesh, UnresolvedCellWarning names it with its voxel count and the min_distance (a smaller one may mesh it), the reconstruction's report lists it, and the .rec file records it (unresolved_regions). On the benchmark this is cell 2 of case 031 (62 voxels, lined by the exterior and cell 3) and cell 7 of case 038 (26 voxels, lined by the exterior and cell 4), at every min_distance from 1 to 7, in every configuration and for every dither seed. In 0.7.0, cell 7 of 038 was a 6-triangle phantom at 8.2 times its voxel volume, with tensions 1.54 and -0.095 on its two interfaces (foambryo did not refuse it: both border two regions); cell 2 of 031 was already absent from the final mesh, surgery having removed its phantom, and that mesh changes by 2 triangles.
  • What these three changes change, measured. A mask with no enclosed pocket at or above the bound, one piece of exterior, and every seed already inside its own label is reconstructed bit for bit as before. Default meshes (min_distance 3): 533 of 543 are bitwise unchanged (the 47 benchmark masks, 492 frames of two real embryo series, the four test images); the 10 that change are benchmark cases 031 and 038 and 8 frames that real-data work leaves out as over-segmented (one of which, a 3 877-voxel pocket, gains a lumen). Over the reconstructions behind the documented numbers (benchmark at min_distance 1 to 7, the link-checked, junction-protected and deterministic configurations, dither seeds 1 to 7), only cases 031 and 038 change (31 of 752 reconstructions); of the 433 plane crops of the benchmark, 36 change: 16 whose crop splits the exterior in two or more pieces, and 21 that hold one of the two unresolved cells (or a cell of case 011 that a crop leaves too thin). The documented numbers that read those two cases move a little, and the force-balance ones move most: on 038's default mesh ForceBalanceKKT's median relative tension error falls from 0.801 to 0.109, on 031's from 0.208 to 0.122, so the tension table's ForceBalanceKKT median goes from 0.1150 to 0.1138 (dithered now better on 41 of the 42 cases) and BayesianMAP's from 0.1222 to 0.1186; the median rho_free goes from 0.5461 to 0.5414; and the benchmark now counts the two cells' membranes and triple lines as missed (one more missed triple line per variant). YoungDupre's medians do not move. The cropped-tissue numbers do not move at the precision they are printed (the largest change: with crop faces kept out and 40 % of the tissue cropped away, the crop-touching tension error goes from 12.7 % to 13.1 %).
  • The junction-protected configurations no longer depend on how SciPy breaks exact ties; on macOS some of their meshes change by a point or a few. Each quadruple-point component of the mask is sampled at the skeleton voxel nearest its centroid. Where several voxels are exactly as near, which is common on the voxel lattice, cKDTree chose one by its tree traversal, and that choice differs between SciPy builds: on one test image, Linux placed one more point than macOS. The tie now goes to the lowest raster index among the exact minima, compared in integer arithmetic. The same rule (lowest index among exact ties) now applies to the lookup of the watershed's seed tetrahedra and to the pixel reconstruct_mask_from_dict marks for a mesh vertex halfway between two pixels. Measured on macOS, this change alone: the default, dithered, deterministic and boundary-layer meshes of the four test images are bitwise unchanged, and so are the default meshes of the 47 benchmark masks (one seed among them has an exact tie, and its mesh does not change); the junction-protected point placements (get_junction_protected_algorithm and get_link_checked_algorithm) gain one 0-junction sample on two test images and move one on a third, at min_distance 3 and 5, so at most one more placed point per image than 0.7.0 (compared with 0.7.0 itself, with SciPy 1.18.0 and 1.18.1 alike); 35 of the 47 benchmark link_checked meshes change, by -2 to +6 mesh points (total 56 517 to 56 534); the masks rebuilt from the four test images' default meshes change on a few voxels of two of them (13 and 2, or 7 and 2, depending on the installed SciPy and trimesh).
  • Mesh surgery no longer leaves abnormal non-manifold edges by undoing its own repairs; a few meshes change, none of the default route's benchmark meshes. An abnormal edge is an edge with four or more incident triangles that do not belong to as many different cells (a cell's surface touching itself, or two cells meeting twice). Surgery repairs one by relabelling a tetrahedron of the ring around it, and gave that tetrahedron the label of its previous neighbour in the ring, whose direction followed the order of the tetrahedra. On some rings that repair created an abnormal edge next to it whose own repair gave the tetrahedron its label back, and the loop stopped after 3 iterations with one edge left. Surgery now counts, exactly, the abnormal edges a relabelling adds or removes, keeps the rule's own choice when it lowers the count (or keeps it without undoing an earlier step), otherwise takes the alternative that lowers the count most, never applies a relabelling that raises it, and runs until no abnormal edge is left (at most 20 iterations instead of 3). Measured with the default algorithm (min_distance 3, seed 42) on the 47 benchmark masks, meshed on the default route and on six anisotropic routes (z resampled or native at z/xy ratios of 5/3, 2 and 3), each with 9 row orders of the tetrahedra and the canonical order: before, 1 to 2 abnormal edges were left on 4 masks of the anisotropic routes, depending on the order (under the canonical order, one on case 037 at 5/3 resampled and one on case 039 at 3 native); now none in any of the 3 290 meshes. On 12 simulated tissues of 90 and 165 cells at a real cell size, the same 7 routes, Qhull's and the canonical order: 33 and 37 abnormal edges before, mostly on the native grid, none now in 168 meshes. The default route's 47 benchmark meshes are unchanged; under the canonical order 4 of the 282 anisotropic benchmark meshes change, by a few triangles, and 31 of the 84 tissue meshes. The reconstruction time does not change measurably. Every walk of surgery is also strictly descending: the steps after the last one that lowered the count are reverted when surgery stops, so it returns either a mesh with fewer abnormal edges, every unchanged-count step of which led to a lower count, or the mesh it was given. On the benchmark (3 290 meshes), the 12 simulated tissues (168 meshes) and two real embryo series of 246 timepoints each (default configuration), no mesh has an abnormal edge before or after this; 10 benchmark meshes (case 004 at a z/xy ratio of 3, resampled, every row order) and 2 real timepoints change by one or two triangles, where surgery had taken one more unchanged-count step after the last edge was gone. Of the golden-master configurations, one boundary-layer mesh changes (image 3, min_distance 3: 2 115 points and 4 511 triangles instead of 2 119 and 4 520), where surgery kept 6 unchanged-count steps that never reached a repair; it keeps its one abnormal edge.

Fixed

  • The Polyscope viewer draws the tissue, not its mirror image. dw3d.viewing.plot_cells_polyscope handed the mesh's points to Polyscope with their columns as stored, (z, y, x), which Polyscope reads as its (x, y, z): z was drawn as x and x as z, an exchange of two axes, which is a reflection. Every view, and every screenshot taken from it, was the mirror image of the tissue (a left-right asymmetry appeared reversed). The viewer now draws Polyscope's x, y, z as the mask's column, row and slice (the points' columns 2, 1, 0) and hands each triangle with two corners exchanged, so that it still faces the same side. Only what is drawn changes: the mesh, its winding, the .rec and .vtk files and every number are unchanged.

Added

  • Enclosed media and unresolved regions are reported. MeshReconstructionAlgorithm.medium_labels (0, then the enclosed media) and enclosed_medium_report (dw3d.EnclosedMediumReport: each medium's label, voxels, inscribed radius and lining cells; each pocket left to the cells with the region that took it and why; the exterior pieces seeded; the regions with no tetrahedron of their own, unresolved, as dw3d.UnresolvedRegion; whether any of the three changes above acted, changes_the_mesh). dw3d.find_enclosed_media(mask, min_inscribed_radius) does the relabelling alone.
  • EnclosedMediumWarning, once per reconstruction that leaves enclosed pockets of medium to the cells (below the size bound, or lined by one cell): their number and the five largest, each with the cell that took it. Expect it on masks with small holes in the segmentation: 9 of the 47 benchmark masks have pockets of 1–26 voxels.
  • UnresolvedCellWarning, once per reconstruction that drops a seed, naming each region absent from the mesh, its voxel count and the min_distance.
  • The .rec file records the media and the unresolved regions when there are any: media = 0 L ... in the metadata appendix, with enclosed_media_voxels and enclosed_media_inscribed_radius aligned with the enclosed labels; unresolved_regions and unresolved_regions_voxels. dw3d.io.load_rec_appendix reads them as tuples; an older dw3d keeps them as strings. A file with neither is byte for byte as before. foambryo 0.7.1 reads both.
  • compare_cell_volumes_with_mask(..., media=...) skips the media like label 0; the reconstruction's cell_volume_report does.
  • MeshReconstructionAlgorithm(..., label_enclosed_media=True), also an attribute: the switch of the first fix above.
  • A finished mesh with abnormal non-manifold edges is no longer silent. When the reconstruction ends with edges carried by four or more triangles that do not separate as many regions, it emits dw3d.AbnormalEdgeWarning once, with their number and the configuration (point placement and its parameters, mesh surgery, tetrahedron order, offset exclusion). They come from surgery being off, from an edge surgery cannot remove without adding another, or from the offset exclusion, which rewrites triangles after surgery. Measured on the golden-master configurations (4 images, min_distance 3 and 5): it fires on the boundary-layer configuration's image 3 at min_distance 3 (1 edge) and on 3 meshes of the offset-excluded configuration (1, 1 and 2 edges), and on no mesh of the default configuration, of the benchmark, of the simulated tissues or of the real embryo series. A UserWarning, so it can be silenced or made an error on its own.

Documentation

  • BENCHMARKS.md is measured on 0.7.1's meshes. Every section that reads meshes was measured again with the same scripts on the default and link-checked reconstructions of 0.7.1, and 0.7.0's value stands beside each number that moved. The conclusions hold; the numbers move little: the tension table's YoungDupre row goes from 0.0777 to 0.0763 (dithered) and from 0.0986 to 0.1003 (link_checked, now a median over all 42 cases, case 038 scored on its interfaces with a determined tension), the median junction-angle error of the mesh-quality table from 6.51 to 6.61 degrees, rho_free from 0.5511 to 0.5461. Two statements change: min_distance=1 no longer leaves abnormal edges (28 on 0.7.0), and the force-balance residual now orders the three junction arms as the contact-angle slope does (it did not on 0.7.0), which leaves its 4 % spread against the slope's 19 % as the reason it is not a proxy for angle quality. Not measured again, and said so where printed: the timings, the numbers measured on the 1 866-cell tissue (its cell-volume count included; one run needs about 31 GiB), the anisotropy costs on the simulated tissues at a real cell size and the quadric reading's result there (some of those runs need 8 to 40 GiB of memory), and the junction-curve numbers with relocation off.
  • BENCHMARKS.md measured again after the strictly descending surgery walks. The same scripts on the final 0.7.1 code change 5 benchmark meshes (of the default, link_checked, min_distance 2, anisotropy and crop populations) and one printed number: the 51-case link_checked mesh-point total, 61 277 to 61 279. The 1 866-cell tissue's 0.5.1 and 0.7.0 meshes, said to be the same, have the same points and labels but differ in 2 vertex positions and 166 triangle windings, from fixes of 0.6.0; its 20 cells with a disagreeing volume are the same on 0.7.0's and 0.7.1's meshes.
  • BENCHMARKS.md measured again after the exact tie-breaks. The same scripts on the final 0.7.1 code change only link_checked and junction-protected records; every default-route mesh is unchanged. In the tension table, link_checked's medians become 0.1003 (YoungDupre, which now wins on 11 of the 42 cases, not 13), 0.1266 (YoungDupreLocal), 0.3262 (ForceBalanceKKT) and 0.3149 (BayesianMAP); in the mesh-quality table, its interface-area error becomes +0.71 %, its valence-≥4 edges 112, its junction-angle error 8.68 degrees, its junction length 1.002× (1.009× without relocation), its missed triple lines 18, and its 51-case point totals 191 428 (tesselation) and 61 298 (mesh). The conclusions hold.
  • BENCHMARKS.md measured again after the enclosed-media fix. The same scripts on the final 0.7.1 code change the reconstructions of cases 031 and 038, the crops that split the exterior or hold one of their two cells, and nothing else. In the tension table, ForceBalanceKKT becomes 0.1138 on dithered meshes (link_checked wins on 1 case, not 2) and BayesianMAP 0.1186; the sentence on case 038's undetermined link_checked interface now says that this interface was the membrane of its unresolved cell, gone since this fix. In the mesh-quality table, link_checked's junction-angle error becomes 8.64 degrees (9.97 without relocation), its junction length 1.003× (1.012× without relocation), the missed triple lines 21 and 19, and the 51-case mesh-point totals 71 272 and 61 295. In the force-balance residual, the three arms' rho_free become 0.5414, 0.5501 and 0.5659 (46.8x, 47.6x and 48.9x the reference mesh) and their slopes −0.2118, −0.2262 and −0.2518 (spread of rho_free 5 %, of the slope 19 %); in the spacing table the slopes become −0.4972, −0.2402, −0.2118 and −0.2455 at min_distance 1, 2, 3 and 5, the excesses −0.4648, −0.1553, −0.0730 and +0.0198, the spread over 2–5 0.034, the min_distance=1 contrast 0.595, and the share of the flattening that coarseness explains at 3 is 66 %. In the junction-curve section the mesh's own lines sit at 0.6735 and 0.7449 voxels (advantage 1.16x and 1.21x; the first implementation's 1.20x at min_distance 4), their curvature and tangent error against the floor at 1.024 and 3.35x, 621 of the mesh's 690 trijunctions are matched with 27 invented, the matched curves' p90 and p99 distances are 1.470 and 4.426 voxels with 0.834 within one voxel, and the label-permutation null matches 0.513 and misses 289. The conclusions hold.
  • What reproduces between machines is stated as measured. The docstrings of canonical_tetrahedron_order and of the deterministic point placements no longer say "on every platform": on one machine a reconstruction is reproducible; between machines, remaining differences are expected only at exactly cospherical points, which is confirmed on Linux x86-64 CI (the two runs cited above).
  • Docstrings that quoted numbers measured before junction relocation became the default now quote the current ones: extract_junction_curves and JunctionCurves (position error 0.5796 against the mesh's 0.6735 at min_distance 3; matched curves a median 0.523 voxels from their three interfaces, invented ones 29.7), get_default_algorithm (the tension table), dw3d.mask_preprocessing (the benchmark's anisotropy costs), and the junction-curve example notebook.

Tests

  • The default configuration's golden master no longer depends on Qhull. The test suite stores the default configuration's tetrahedralisation of the four golden images (tests/golden/default_tetrahedralisations.npz) and reconstructs from it; exact integer checks verify, on every machine, that it is a Delaunay tetrahedralisation of the points and that Qhull's own differs from it only by another Delaunay choice. 0.7.0's default fixtures moved to tests/golden/qhull_tetrahedron_order/ and are checked with canonical_tetrahedron_order=False. The golden tests of the opt-in configurations (deterministic, dithered, boundary layer, junction protected, link checked, cubic score, offset excluded) and the reference counts on 3.tif reconstruct the same way, from tests/golden/opt_in_configuration_tetrahedralisations.npz (the weighted configurations with an exact check of the regular tetrahedralisation): on Linux, Qhull splits the golden images' cospherical point sets otherwise than on macOS, and 82 of these tests failed there although every difference was such a split.

Known issues

  • The crop report can miss a cut cell, because the watershed lost it (corrected on 4 November 2026: the first wording blamed the crop report and said cell 1 gets a pressure). On a test mask of four cells filling a ball that the 36³ image box cuts, the cells with voxels on the box are 1, 3 and 4 (262, 133 and 105 voxels on it). At unit and 0.5 cubic voxels, the default min_distance 3, the seeded watershed leaves cell 1 (1 648 voxels) only its seed tetrahedron, mesh surgery relabels it, and cell 1 is absent from the mesh: only CellVolumeDisagreementWarning names it, unresolved is empty, and foambryo gives it no pressure. cut_cells reports 2, 3 and 4: cell 2, which took most of cell 1's tetrahedra, holds its crop faces. 0.7.0 loses cell 1 too on macOS arm64 (no triangle); one Linux x86-64 run of 0.7.0 kept 8 of its triangles, 0.7.0's mesh depending on Qhull's row order. See the next release for the measured extent.
  • reconstruct_mask_from_dict depends on the installed trimesh. The mesh is subdivided with trimesh's subdivide_to_size, whose output changed between releases: the same mesh gives 1 901 565 vertices with trimesh 4.12.2 and 1 319 748 with 5.1.1, and the masks rebuilt from the four test images differ by 509 to 819 voxels between the two. The mesh itself does not depend on trimesh.
  • A .rec file with media or unresolved regions keeps them in its metadata appendix; dw3d 0.7.0 reads those keys as strings. A file with neither is byte for byte as before.
  • Mesh files keep the mask's column order, (z, y, x): ParaView, MeshLab and napari's default 3-D orientation show the mirror image of the tissue (see Fixed, above).

0.7.0 — 2026-10-17

0.6.0 was prepared (4 October 2026) but not published on PyPI: its changes are part of 0.7.0, listed at the end of this section under "Prepared for 0.6.0". 0.7.0 is the first release on PyPI since 0.5.1.

Recent work on dw3d and foambryo is part of a collaboration with Alejandro Aguilera Castrejon (Janelia Research Campus, Howard Hughes Medical Institute). We thank him and his Janelia colleagues Adam L. Taylor, Wenhong Li and Francesco Roncato. Adam L. Taylor found the border-triangle winding defect fixed in 0.6.0 and pointed us to the seed-extraction and dense tension-solve bottlenecks on large tissues.

Documentation

  • The README is shorter and points to a user guide in docs/ (reconstruction variants, junction relocation, cropped tissues, anisotropic voxels, the .rec metadata appendix), from which a documentation website is built with MkDocs (mkdocs.yml), with an API reference generated from the docstrings. A new notebook, example_6_anisotropic_voxels_and_crop_faces.ipynb, runs on a mask it generates. The notebooks no longer contain install cells (they say what to install), and the first notebook says that data/Images/1.tif records no voxel size, so the sizes it uses are illustrative. The docstrings of the public functions were checked against the code. No mesh changes.
  • Two return annotations corrected: both_construct_mesh_and_compressed_segmentation returns four items (the mesh's three arrays and the compressed-segmentation dictionary), and reconstruct_mask_from_dict and reconstruct_mask_from_saved_file_dict return 64-bit integer labels, not uint8. What they return is unchanged.

Fixed (changes results)

  • set_pixel_size now scales the right axes; results change when the xy and z sizes differ. dw3d's mesh points are in the mask's index order, (z, y, x) for a microscope stack, so column 0 is z. dw3d.mesh_utilities.set_pixel_size(points, xy_pixel_size, z_pixel_size), the method algorithm.set_pixel_size(xy_pixel_size, z_pixel_size) and dw3d.set_points_pixel_size now scale column 0 by the z size and columns 1 and 2 by the xy size. Before, they scaled columns 0 and 1 by the xy size and column 2 by the z size: z was multiplied by the xy size and x by the z size. Results change only when the two sizes differ; re-run any analysis that called one of them with different sizes. (A mask stored as (x, y, z) was scaled correctly before and is not now: transpose it to (z, y, x) before meshing.) For a mask whose voxels are longer along z, prefer algorithm.construct_mesh_in_physical_units(mask, spacing), which resamples the mask to cubic voxels before meshing: measured on 12 simulated tissues of 90 and 165 cells voxelised at a real cell size and down-sampled along z, against the same tissues meshed at full resolution, it costs +0.83, +0.71 and +1.17 degrees of contact-angle error at z/xy ratios of 5/3, 2 and 3, against +1.38, +1.97 and +4.10 for meshing the native grid and scaling the mesh.

Faster

  • The distance transform needs less memory and the tesselation graph is built faster; the meshes are bit for bit the same. The distance transform builds its masks in uint8 and its field in float32 (still returned as float64), and the tesselation graph pairs the faces of the tetrahedra and builds its networkx graph without Python loops. Measured on one machine, on a 1 866-cell tissue: the distance transform's peak memory goes from 21.0 to 14.9 GiB (38.1 to 28.1 GiB when the mask is first resampled to cubic voxels), the face table and pairing from 7.8 to 1.8 s, the graph from 5.5 to 3.0 s; on a 2 000-cell synthetic foam the whole reconstruction goes from 200 to 186 s. The meshes, crop faces and cut cells of 481 masks (benchmark, resolution sweep, simulated tissues at real cell size, cut and anisotropic masks) and of two large tissues are bitwise identical before and after. Contributed by Wenhong Li and Adam L. Taylor.

Fixed

  • dw3d.io.load_rec_appendix reads resampled_spacing as a number. It returned the text ('0.3'); it now returns a float (0.3), as it already did for spacing. resampling stays text.
  • dw3d.viewing.plot_cells_polyscope(..., anisotropy_factor=...) no longer rescales the reconstruction's mesh. With a factor other than 1 it multiplied column 0 of the algorithm's own points in place, so every call compounded the factor and a later save_to_rec_mesh or save_to_vtk_mesh wrote the scaled points. It now shows a scaled copy and leaves the mesh as it was. If you saved a mesh after viewing it with a factor, reconstruct and save it again. To mesh a mask whose voxels are longer along z in physical units, use algorithm.construct_mesh_in_physical_units(mask, spacing).
  • A reconstruction no longer prints a SciPy DeprecationWarning. The seed lookup imported the k-d tree from scipy.spatial.ckdtree, a namespace SciPy will remove in 2.0; it now uses scipy.spatial.cKDTree, the same class, so the meshes are unchanged.
  • dw3d.io.load_meshio_mesh refuses a file without labels with a ValueError. A file with no label1 or label2 triangle cell array raised meshio's KeyError; it now raises the ValueError the function already raised for empty label arrays, naming the file and the missing array. load_meshio_mesh_with_crop_faces likewise. If you caught KeyError there, catch ValueError.
  • A binary .rec file always reads back. save_rec(..., binary_mode=True) wrote the points in their own dtype, while load_rec reads float64, so float32 points did not read back; they are now always written as float64. For float64 points, which is what dw3d produces, the files are byte for byte what they were. The text layout is unchanged. Both layouts are now described in save_rec's docstring and in the user guide's page on the .rec format.
  • The compressed segmentation after construct_mesh_in_physical_units says which frame each entry is in. algorithm.last_compressed_segmentation returns the mesh's points, which that method has scaled to physical units, with the seeds and the shape of the resampled cubic grid that was meshed. Passed as they are to dw3d.reconstruct_mask_from_dict, the mesh is rasterised at the wrong scale; divide the points by the resampled spacing (the shortest spacing) first, and the resampled mask is rebuilt. The docstrings now say so; nothing returned has changed.

New

  • New: masks with voxels longer along z. algorithm.construct_mesh_in_physical_units(mask, spacing=(0.5, 0.3, 0.3)) resamples the mask to cubic voxels of the shortest spacing by shape-based interpolation, meshes it, and returns the mesh in the unit of spacing; save_to_rec_mesh then records coordinate_frame = physical, the mask's own spacing, source_shape, resampling and resampled_spacing in the file's metadata appendix. The resampling alone is dw3d.resample_to_isotropic(mask, spacing, method="shape"). Meshing the native grid and scaling the mesh, as before, samples the surfaces coarsely along z: measured on 12 simulated tissues of 90 and 165 cells voxelised at a real cell size and down-sampled along z (one seed), as the median over tissues of each mesh's median line-mean contact-angle error minus that of the same tissue meshed at full resolution, it costs +1.38, +1.97 and +4.10 degrees at z/xy ratios of 5/3, 2 and 3, against +0.83, +0.71 and +1.17 when the mask is resampled first. Nothing was measured above a ratio of 3: there the method warns (dw3d.UnmeasuredAnisotropyWarning) and still meshes. The cost is that of a mask acquired at the finer spacing (time and memory grow with the ratio). Nothing changes for construct_mesh_from_segmentation_mask, its meshes or its files, and a mask with cubic voxels goes through resample_to_isotropic untouched.
  • New: the reconstruction records where the image cut the tissue. When a cell of the mask reaches a face of the image box, the triangles that close it on that face are not contact with the medium: the tissue goes on beyond the image. The algorithm now marks them as crop faces (algorithm.crop_faces, a boolean per triangle) and the cells they touch as cut cells (algorithm.cut_cells); algorithm.crop_face_report gives the counts per image face. The mesh itself is unchanged, bit for bit: same points, same triangles in the same order, same labels. foambryo reads these marks and keeps crop faces out of its equations.
  • New: an image face can be declared physical, for a tissue that really ends there, such as on a coverslip: algorithm.physical_image_faces = ("axis0_low",) before reconstructing, or MeshReconstructionAlgorithmFactory().set_physical_image_faces("axis0_low"). The triangles on a physical face stay contact with the medium, as before. By default every image face is a crop.
  • .rec and .vtk files keep the crop. save_to_rec_mesh (and save_rec(..., crop_faces=...)) writes the crop faces as the last block of triangles and records the block in the file's metadata appendix as crop_faces = <first row> <count>, with physical_image_faces; dw3d.io.load_rec_with_crop_faces reads them back. save_to_vtk_mesh adds a crop_face cell array, read by load_meshio_mesh_with_crop_faces. Only meshes of masks whose cells reach the image box are affected: for every other mesh the files are byte for byte what they were. A program that does not know the new key still reads a valid mesh, in which the crop faces look like medium contact.
  • Measured on the 47 benchmark masks cut by planes at 10 %, 25 % and 40 % of their extent: read as contact with the medium, crop faces put 13 % to 40 % error on the tensions foambryo infers for the interfaces that touch the crop, against 9 % to 12 % when they are kept out.
  • A reconstruction can also close a cell on an image face that the mask's cell does not reach, when the mask leaves only a voxel or two of medium between the cell and the image border. Those triangles are not crop faces: the cell was seen to end inside the image, so they stay contact with the medium, as before. A mask none of whose cells reaches the image box therefore has no crop face and no cut cell. algorithm.crop_face_report counts them, and lists which cells reach each image face.

Removed

  • The three reconstruction getters deprecated since 0.5.0 are removed, with their top-level aliases. Each was an exact synonym of a keyword call on get_junction_protected_algorithm (top level: get_junction_protected_mesh_reconstruction_algorithm), which gives the same mesh, bit for bit; call that instead:
  • get_offset_included_algorithm(...) → get_junction_protected_algorithm(...);
  • get_offset_excluded_algorithm(...) → get_junction_protected_algorithm(..., exclude_offsets_from_surface=True);
  • get_cubic_score_algorithm(...) → get_junction_protected_algorithm(..., spline_order=3).

Dependencies

  • Higher minimum versions, the oldest with which the test suite passes (Python 3.11): numpy 2.0.0, scipy 1.13.0, scikit-image 0.23.1, edt 2.4.1 and meshio 5.3.5 (trimesh 4.0.0 and networkx 2.8.0 unchanged); for the viewing extra polyscope 2.2.0 and matplotlib 3.8.4. The previous minimums had never been tested: with them (numpy 1.24) the reconstruction gives slightly different meshes and the rebuilt mask 32-bit labels, and edt 2.4.0, meshio 5.3.4 and older scipy and scikit-image releases do not work with numpy 2.

Prepared for 0.6.0 (4 October 2026, not published)

  • Faster, and lighter in memory, on large tissues; the meshes are bit-for-bit the same. Three steps of the reconstruction were rewritten without changing any result:
  • the seeds are found in two passes over the volume instead of one pass per label;
  • junction relocation's self-intersection guard finds its candidate vertex pairs with one batched neighbour search per range of reach, and checks only the triangles those pairs involve;
  • the trijunction curves are detected in slabs of the volume instead of on the whole volume at once.

Measured on one machine on a 1 866-cell tissue meshed on its native grid, together with foambryo's sparse tension solve: from mask to tensions, 9.5 min instead of 47.5 min with 0.5.1, and a peak memory of 30.9 GiB instead of 54.7 GiB (measured again for 0.7.0, nothing else running). Seed extraction went from 28 min to 6 s, the relocation guard from 6.6 min to 45 s, and curve detection from 82 s to 49 s and from 37.6 to 9.7 GiB. The meshes of the 47 benchmark masks, 492 embryo timepoints, 10 cut masks and the 4 example images are bitwise identical before and after, as are those of two large tissues. The memory peak is now junction relocation's whole-mesh self-intersection check.

  • New: the cells whose mesh volume disagrees with their mask are listed, with one warning. A reconstruction can lose a small cell, or give part of a cell to a neighbour, while the mesh stays closed and manifold, so no surface check sees it. After every reconstruction the algorithm now compares each cell's mesh volume with its voxel count and lists, in cell_volume_report, the cells outside 0.5–1.5 times it, with a non-positive volume, or with no surface at all; CellVolumeDisagreementWarning is emitted once when the list is not empty. The same check is available as dw3d.compare_cell_volumes_with_mask. The mesh itself is unchanged, bit for bit. Measured with the default settings: 2 of 240 cells on the 47 benchmark masks, 169 of 5 038 on two 246-timepoint embryo series (almost all in the last frames of one series, where the mask suddenly holds many very small labels), 20 cells and 45 cavities on a 1 866-cell tissue. Interfaces of the listed cells are missing or misplaced, and a pressure inferred for them is not a measurement.

  • The repository no longer ships lock files. uv.lock recorded version 0.4.1 and a package index that only the lab can reach, and locked-requirements.txt pinned version 0.3.5. The supported dependency ranges are those in pyproject.toml.

  • The package metadata names the Turlier lab as author; Matthieu Perez remains the maintainer.

  • Fixed: triangles on the image border were wound the wrong way. When a cell touches the edge of the image, the triangles that close it along the image border had their normal pointing out of the cell instead of into it, against the convention every other triangle follows (the normal points from the first label into the second). Every such triangle was affected, not a random share. A cell closed by the image border then reads too small a volume, often a negative one, and any tension or pressure computed from the mesh is wrong.

Who is affected. Anyone whose cells touch the image border, above all tissue cropped through its cells. Measured with the default reconstruction on ten benchmark masks cut through their middle: before the fix, 38 of the 54 cells on the cut had a negative volume; after it, none. The tensions foambryo infers from those meshes changed by up to 199 %, and every cell pressure by 37–139 %. On masks whose cells stay clear of the border nothing changes: of 543 uncut masks (47 benchmark cases, 492 embryo timepoints and the 4 example images), 542 have no border triangle and come out bit-for-bit identical. The one exception has two border triangles on a single cell, whose volume goes from 0.73 to 1.01 of its voxel count.

Only the vertex order of border triangles changes: vertex positions, the set of triangles and their labels are identical. A cut surface is still treated as contact with the medium, as before.

  • Fixed: a few triangles lying on a flat tetrahedron were wound the wrong way. The tetrahedral mesh the surface is cut from contains flat tetrahedra (four coplanar points of the voxel grid). A triangle whose orientation was read from such a tetrahedron got its winding from a rounding error, and about half of them came out reversed; each reversed triangle makes its two cells read a volume slightly different from the volume they actually enclose. These triangles are now oriented from the tetrahedron on their other side. Measured with the default settings: 10 triangles in 8 cells on the 47 benchmark masks (volume error 0.4 % median, 0.7 % at most), 20 triangles in 19 cells on two 246-timepoint embryo series (2 % median, 14 % at most), 9 triangles in 10 cells on a 1 866-cell tissue; after the fix, every cell's volume equals that of the tetrahedra it is made of. Only the vertex order of those triangles changes: vertex positions, the set of triangles and their labels are bit-for-bit identical on every mask measured.

  • Fixed: junction relocation could turn a very small cell inside out. Relocation's guard checked that every triangle around a moved vertex kept its orientation, but a cell made of a single tetrahedron could still be inverted by a vertex moved across its opposite face, with every triangle around it passing that check; the cell then had a negative volume and passed every surface check. The guard now also refuses a move that would leave any cell it touches with a volume of zero or less, and nothing else: a cell may still shrink. A refused move leaves its vertex where it was; relocation_report counts these refusals and names the cells. Measured with the default settings: the clause changes no mesh of the 47 benchmark masks, the 141 masks of the resolution sweep, 10 masks cut through their cells, a 110-cell tissue, or 484 timepoints of two embryo series (all bit-for-bit identical). It fires on two over-segmented frames of an embryo series, where it keeps one cell from inverting on one frame, and on a 1 866-cell tissue, where it keeps one cavity from inverting.

0.5.1

0.5.1 republishes the final 0.5.0 (as on GitHub's master since 27 September). The 0.5.0 wheel and source archive on PyPI were built from an earlier snapshot of the release: their licence metadata says CC BY-NC-SA 4.0 instead of GPL-3.0-or-later, the viewing extra still installs napari, and dw3d.viewing still has the napari viewer that 0.5.0 removed. GitHub's v0.5.0 tag points at that same earlier snapshot, and is left as it is. Install 0.5.1; 0.5.0 is withdrawn from PyPI (yanked).

Nothing else changes: the code is the final 0.5.0's. The package metadata names the Turlier lab as author (Matthieu Perez remains the maintainer), the README's links point to the 0.5.1 tag, and the two stale lock files 0.5.0 carried (uv.lock and locked-requirements.txt) are gone.

0.5.0

New licence: from 0.5.0, delaunay-watershed-3d is licensed under the GNU General Public License, version 3 or (at your option) any later version (SPDX GPL-3.0-or-later; the text of version 3 is in License), replacing CC BY-NC-SA 4.0. Commercial use is allowed, under the GPL's conditions (a distributed derivative work must be released under the same licence, with its source). Earlier releases keep the licence they were published under.

The default changed: junction relocation is on in every reconstruction configuration. Meshes come out with the same triangles and labels as in 0.4, and different vertex positions on the trijunction lines. To get the 0.4 meshes back exactly, switch it off: pass relocate_junctions=False to MeshReconstructionAlgorithm, call MeshReconstructionAlgorithmFactory().set_junction_relocation(False), or set algorithm.relocate_junctions = False on an algorithm a get_*_mesh_reconstruction_algorithm function returned. See RELEASE_NOTES.md for the limitations that matter on real data.

  • Junction relocation, now the default. dw3d.relocate_junction_vertices is a post-process on a finished mesh that moves its trijunction vertices onto the trijunction curves the mask itself gives. It changes vertex positions only — triangles and material labels come back untouched — so a treated mesh can be compared vertex-for-vertex with its own untreated original. Read what it did from the algorithm's relocation_report, and whether it ran, with which guard and whether it warned from the new relocation_provenance.

What it costs, in seconds, because the reconstruction it follows varies by an order of magnitude between volumes: about +0.75 s on the benchmark meshes, whose reconstruction takes about 5 s (+15 %); 0.1–1.5 s per timepoint on real embryo volumes, whose reconstruction takes about 0.6 s (median 0.34 s and 0.48 s on two developmental time series; about 65 s per 154-timepoint series). Within one real series it grows faster than linearly with the number of triangles — a fitted exponent of 2.68 over a 2.2-fold range of mesh sizes, which describes that series and is not a tissue-scale law. A faster neighbour search is planned for 0.5.1; it will leave every relocated mesh bit-for-bit unchanged.

  • New warning: dw3d.CoarseSpacingRelocationWarning (a UserWarning), emitted once per reconstruction when relocation is on and the point placement's min_distance is 5 or more. Its text: "At min_distance ≥ 5, the check on surface-tangent contact angles showed a small drift that lies within the check's own noise, and larger spacings have not been measured; facet-based contact angles improve. If tangent-based angles matter for your analysis, compare with relocate_junctions=False (or set_junction_relocation(False))." A custom point-placement function that carries no min_distance never triggers it. Filter it like any warning: warnings.filterwarnings("ignore", category=dw3d.CoarseSpacingRelocationWarning).

  • Removed, as their deprecation warnings announced since 0.4.0: get_v0_3_algorithm (use get_dithered_algorithm), get_a1b_algorithm (use get_deterministic_algorithm), get_a3_a5_algorithm (use get_junction_protected_algorithm), and the matching top-level get_v0_3_…, get_a1b_… and get_a3_a5_mesh_reconstruction_algorithm.

  • Removed, without a deprecation period: dw3d.viewing.plot_in_napari. It already failed with the napari that pip installs today: with napari 0.9.1 (measured on 27 Sep 2026) it raised AttributeError, because napari.view_image no longer exists, and its add_points calls pass an n_dimensional argument that napari 0.9.1 no longer accepts. napari is no longer part of the viewing extra, which now installs Polyscope and matplotlib only; the Polyscope viewer dw3d.viewing.plot_cells_polyscope is unchanged.

  • Deprecated, removed in 0.6.0 — three exact synonyms, which now emit a DeprecationWarning naming the equivalent call and still return the identical mesh: get_offset_included_algorithm() → get_junction_protected_algorithm(); get_offset_excluded_algorithm(...) → get_junction_protected_algorithm(..., exclude_offsets_from_surface=True); get_cubic_score_algorithm() → get_junction_protected_algorithm(spline_order=3); and their top-level get_*_mesh_reconstruction_algorithm aliases. Six configurations remain recommended: default, dithered, deterministic, link-checked, junction-protected and boundary-layer.

  • Golden masters. tests/golden/ now holds the relocated meshes; the 0.4 fixtures moved, byte for byte, to tests/golden_without_relocation/, and every golden-master test runs against both — the second with relocate_junctions=False.

  • Documentation. BENCHMARKS.md is self-contained: each number states its population and how it was measured. Those numbers were measured without junction relocation (the 0.4 default). Docstrings no longer cite files that are not distributed. The README cites the published article (Ichbiah et al., Nature Methods 2023, doi:10.1038/s41592-023-02084-7) instead of its preprint, and a new CITATION.cff says the same. The mask-compression notebook (Examples/example_2_mask_compression_reconstruction.ipynb) opens its napari viewer with napari.Viewer() and add_image, since napari.view_image no longer exists in current napari, and says that napari must be installed separately; the advanced-use notebook (example_3_advanced_use.ipynb) no longer has its napari section.

The rest of this section describes what 0.5.0 adds besides the default:

What it costs and what it buys, measured over 40 benchmark cases at four reconstruction spacings and on four point samplers — 16 independent adjudications, all passing. Line position error, local tangent error and discrete curvature all improve with their confidence intervals clear of zero at every spacing on every sampler; no pre-existing mesh-validity number changes on any case. On the seed-free samplers it also improves contact angles by 2.3–3.5 degrees and gauge-matched tension error by 20–40 %; on the shipped default's seeded sampler the line improves and the contact angle does not move significantly either way. Its cost is stated in seconds above.

It is guarded twice. The local guard refuses any move that would invert or collapse a triangle touching the vertex. The second guard is the one that matters: a move can drive one sheet of the mesh through a distant sheet while every triangle around the moved vertex stays perfectly oriented, and no local check can see that. Measured on the benchmark cohort, all twelve existing validity numbers stayed bit-identical on 40 of 40 cases while 23 such crossings existed on 5 of them. The second guard makes the crossing count non-increasing by construction, and it costs between 0.04 % and 0.21 % of the moves to do it.

  • dw3d.find_self_intersections and dw3d.count_self_intersections. The exact triangle–triangle intersection test the relocation certifies itself with, now part of the library. Two triangles sharing a vertex are adjacent and are never tested — three triangles meet along every trijunction edge by design — so what it counts is a genuine defect, never the intended non-manifold structure. It is a count, never a score, and no threshold is proposed.

0.4.2

No change to reconstruction behaviour: every default is bitwise identical to 0.4.1 (verified by hash on the mesh output of the dithered and deterministic configurations).

  • The three deprecation warnings' text no longer implies 0.5.0 already exists. get_v0_3_algorithm, get_a1b_algorithm and get_a3_a5_algorithm (and the matching dw3d/__init__.py aliases) now say "removed in a future 0.5.0 release" instead of "removed in 0.5.0"; the replacement function and the removal commitment are unchanged.
  • New dw3d_benchmarks/mesh_quality_comparison/ package: compares mesh quality (M1-M7: contact angles, interface areas, cell volumes, curvature, junction-line geometry, mesh validity, cost) across the four core reconstruction configurations and across dw3d versions. A benchmarks extra (pip install ".[benchmarks]") covers the figure scripts' matplotlib requirement without pulling in viewing's napari dependency.
  • One-line fix: dw3d_benchmarks/run_case.py's VARIANT_GETTERS comment stated the default is offset_excluded_linkcheck; it is not — the default is dithered.

0.4.1

Release hygiene only. No change to reconstruction behaviour: every default is bitwise identical to 0.4.0 on all 47 benchmark meshes.

  • MeshReconstructionAlgorithmFactory's three development-named factory methods are renamed to describe their mechanism: get_v0_3_algorithm → get_dithered_algorithm, get_a1b_algorithm → get_deterministic_algorithm, get_a3_a5_algorithm → get_offset_included_algorithm, and the matching top-level exports in dw3d/__init__.py (e.g. get_v0_3_mesh_reconstruction_algorithm → get_dithered_mesh_reconstruction_algorithm). The old names still work — they now emit a DeprecationWarning naming the replacement — and will be removed in 0.5.0.
  • dw3d_benchmarks/run_fingerprints.py's --variant strings are renamed to match (v0_3 → dithered, a1b → deterministic, a3_a5 → offset_included); the old strings are still accepted, with a printed note pointing at the replacement.
  • Development files no longer ship or return. Development notes and scratch scripts are removed from the repository tip and gitignored so they cannot be re-added by accident. The project's development record is kept in the development repository and has never been part of the packaged distribution; confirmed by building the wheel and listing its contents.
  • Internal benchmark filenames and test names that were named after a development phase (e.g. analyze_a5.py, d2_defect_patches.py, baseline JSONs prefixed a6_/a7_/a8_/a8b_) are renamed to describe what they measure. This does not change any benchmark's recorded numbers.

0.4.0

New: trijunction curves read from the mask, keyed to the mesh's own junctions

extract_junction_curves(mask, points, triangles, labels) returns one polyline per material triple, computed from the segmentation mask and matched against the reconstructed mesh's own trijunctions. Purely additive: nothing in the reconstruction pipeline calls it, no default changed, no dependency was added, and the contact-angle and mesh-validity numbers are bitwise unchanged (verified on 1974 measured values across 47 cases at two point spacings).

from dw3d import extract_junction_curves
from dw3d.io import load_rec

points, triangles, labels = load_rec("000_mesh.rec")  # or your own reconstruction
curves = extract_junction_curves(mask, points, triangles, labels)
curves.matched      # the usable set: one-to-one with a mesh trijunction
curves.invented     # triples the mask says exist and the mesh does not have
curves.match_rate   # 0.900 on the 47-case benchmark at min_distance=3

Why you might want it. These curves are measurably closer to ground truth than the junction lines the mesh produces on its own — median position error 0.5846 voxels against 0.8642 at min_distance=3, a factor of 1.48, and more as the mesh coarsens (1.90x at min_distance=7). Every head-to-head comparison measured favours them on 1.000 of 10,000 bootstrap draws.

What it costs you. They are less complete: 90 % of the mesh's trijunctions get exactly one curve, and the rest arrive fragmented. matched and invented are deliberately separate fields and are never merged, because they are structurally different populations — matched curves lie a median 0.68 voxels from all three of their own interfaces, invented ones 29.7, with none within a voxel.

What it is not. The curves sit about 4.8x above the mask's own identifiability floor (0.107 voxels). This is better geometry, not correct geometry.

The default estimator is "plain" — detection only, about 0.8 s per benchmark case against the ~1.5 s dw3d spends reconstructing it. estimator="anchor" solves one small linear program per vertex, costs about six times as much, and buys 11 % of position error; its argument is that it carries a smaller systematic bias against narrow junction wedges, not that 11 %. estimator="centroid" exists to reproduce the research result and is not a recommendation.

See BENCHMARKS.md (section "Junction curves") for the full numbers and the controls, and Examples/example_4_junction_curves.ipynb for a worked example that runs in a few seconds on data already in this repository.

The default reconstruction is the published dithered algorithm again

Between one earlier internal release and this one, the default reconstruction algorithm was a revised meshing pipeline (deterministic point placement, explicit junction detection and protection, and a topology-preserving cleanup of the extracted surface). That pipeline produces measurably better mesh geometry — lower interface-area bias against ground truth, far fewer degenerate ("all-surface") tetrahedra, better junction placement — but end-to-end tension-inference accuracy through foambryo, on a benchmark of 42 mechanically-equilibrated cases, is worse with it than with the published algorithm, on every inference method tested. Since that downstream accuracy is what most users of this package ultimately care about, the default reconstruction algorithm has reverted to the published (dithered) configuration.

The revised meshing pipeline is not removed: it remains fully available, opt-in, as get_link_checked_mesh_reconstruction_algorithm. Reach for it when mesh geometry and topology matter more to you than today's downstream inference accuracy. See BENCHMARKS.md for the numbers behind this decision and the accuracy finding stated plainly, without spin: the revised pipeline is currently the worse choice for tension inference, despite being the better mesh in isolation.

This reconstructs bit-for-bit what dw3d 0.3.6 produced on the current numpy/scipy/ scikit-image stack (see get_default_mesh_reconstruction_algorithm's docstring for the one caveat: the pre-0.4.0 watershed tie-break ordering, which had no single well-defined answer, is not restored, since it depended on which sorting kernel happened to run it).

New capability, unaffected by the default change

  • set_tiled_edt_method(..., dtype=np.float64): an opt-in Euclidean-distance-transform variant that uses roughly a third of the peak memory of the default EDT computation at large volumes, while reproducing it bit-for-bit — unlike the existing float32 tiled variant, which saves the same memory but changes the output when combined with the revised meshing pipeline's normal/score computations. Not the default EDT for either reconstruction variant; a deliberate choice for memory-constrained large volumes.

.rec / .arec files can now carry a metadata appendix

save_rec(..., metadata={...}) appends a trailing block of ASCII # key = value lines recording coordinate_frame (voxel_index, physical, or unknown — the field this exists for: it is what lets a reader tell whether coordinates are raw voxel indices or already-scaled physical units), axis_order, spacing, spacing_unit, source_shape and crop_offset. Read it back with the new load_rec_appendix(filename), which returns None for a file with no appendix — never a default of isotropic spacing. See README.md for the field list and the format.

The block is written at the end of the file, never the start, so this is purely additive: save_rec without metadata (the default) writes byte-for-byte the same file as before this existed, and every reader already in the wild — including dw3d 0.3.6 and released foambryo — loads a file with an appendix exactly as it always has. load_rec's return type is unchanged; the appendix is read separately, on purpose.

Nothing else changed

Every other named reconstruction getter (get_deterministic_algorithm, get_offset_included_algorithm, get_boundary_layer_algorithm, get_offset_excluded_algorithm, get_cubic_score_algorithm) is unchanged and produces exactly the output it always has.