Rewrite nuclei localization with mesh-transform approach and parallel processing #45
Open
Rewrite nuclei localization with mesh-transform approach and parallel processing #45
Conversation
… processing - Transform mesh to nuclei coordinates (Camera 2) instead of transforming nuclei to mesh coordinates, using inverse of dual camera alignment matrix - Replace point-cloud-utils (pcu.make_mesh_watertight) with custom flat-cap hole filling using scipy Delaunay triangulation (MIT-licensed) - Add parallel processing via joblib with per-movie tmp directories - Batch contains_points ray casting for all nuclei per timepoint - Add CLI options: --n_jobs, --sequential, --no-align, --local, --local-csv - Update io.py to support load_from_aws and local_path parameters - Add joblib dependency to pyproject.toml
…s-BM workflow dataset'
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.
Summary
Mesh-transform approach: Instead of transforming nuclei segmentation coordinates to match the CollagenIV mesh (Camera 1), this version transforms the mesh vertices to match nuclei coordinates (Camera 2) using the inverse of the dual camera alignment matrix. This keeps nuclei positions fixed and avoids interpolation artifacts in the segmentation data.
Replace point-cloud-utils with flat-cap hole filling: The GPL-licensed pcu.make_mesh_watertight() is replaced by a custom MIT-licensed approach that fills mesh holes using a flat cap at the maximum boundary Z level, triangulated via scipy.spatial.Delaunay. This eliminates double-wall artifacts that pcu introduced.
Parallel processing: Movies are processed in parallel using joblib (default 4 workers), with per-movie temporary directories to avoid file conflicts. Memory is explicitly freed after each movie.
Batch ray casting: All nuclei centroids per timepoint are checked against the mesh in a single contains_points call instead of one-by-one, improving throughput.
Robust mesh loading: Handles both data-ID-prefixed and generic VTM file naming conventions via glob instead of constructing a fixed filename.
CLI options: --n_jobs, --sequential, --no-align, --local, --local-csv for flexible execution.
Run python EMT_data_analysis/analysis_scripts/Nuclei_localization.py --sequential on a subset to
verify correctness
Run with default parallel mode (--n_jobs 4) and confirm all movies complete
Compare output CSVs against the previous version's results
Verify --local and --local-csv options work with a local manifest
Confirm no point-cloud-utils import errors (dependency removed from script)