Skip to content

Rewrite nuclei localization with mesh-transform approach and parallel processing #45

Open
smishra3 wants to merge 4 commits intoreSub-v1from
feature/nuclei-localization-mesh-transform
Open

Rewrite nuclei localization with mesh-transform approach and parallel processing #45
smishra3 wants to merge 4 commits intoreSub-v1from
feature/nuclei-localization-mesh-transform

Conversation

@smishra3
Copy link
Collaborator

@smishra3 smishra3 commented Feb 5, 2026

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)

… 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
@smishra3 smishra3 requested review from kiryteo and vianamp February 5, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant