Repository navigation
Conversation
…k exactly seg2mesh (volume_to_mesh) ran marching cubes on the (z, y, x) array and stored the vertices in that order, so its meshes were mirrored (x and z swapped, triangles facing inward) relative to the tomogram and to every other copick mesh: seg2slab, validbox, picks2mesh and mesh2seg all use (x, y, z) in Å with voxel index i at i * spacing. It also did not pad the volume, so a segmentation touching the volume's edge gave an open mesh. Vertices are now reversed to (x, y, z), which also turns the triangles outward, and the volume is padded by a voxel of background. Fixes #132. seg2mesh --individual-meshes was documented but never reached the converter (one mesh was stored under a literal "{instance_id}" session). It now stores one mesh per label (label_meshes, each label's mask cropped to its bounding box), with {instance_id} replaced by the label. mesh2seg (watertight) cast its rays through the voxel centres, exactly where marching-cubes meshes have their vertices and edges, so crossings were counted twice or missed: a correct seg2mesh mesh of 10521 run 35962's valid-sample segmentation came back with IoU 0.65. Ray origins are now offset by ~0.015 voxel across the ray. Three more fixes in the same code: - a crossing was assigned to its nearest voxel (np.round), which counts the voxel before the surface in where a ray enters and leaves out the last one inside where it exits; a voxel is now inside when its centre is (the first centre after each crossing); - two crossings in the same voxel were applied once (fancy-index assignment with repeated indices); crossings now toggle by parity; - rays started one voxel before the volume, so a mesh reaching further lost its entry crossing; they now start before the mesh. On 10521 run 35962 (boundary-clean valid-sample), seg2mesh then mesh2seg now gives back the segmentation exactly (IoU 1.0, was 0.11). The published pipeline mesh still round-trips, now with voxels decided by their centres: +242,057 / -739 voxels (0.5%) next to its surface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of the main-line fix to v2.0 (fixes #132 there too). It's the same change; the commit cherry-picks cleanly next to v2.0's
get_level_arraytomogram lookup.See the main PR for the details and the real-data verification:
--individual-meshesimplemented;Test plan
pytest testswith copick 2.0.0-alpha.6 / zarr 3.4.1: 124 passed, including the 15 new tests🤖 Generated with Claude Code