Add assign_z_coordinates function for 3D reconstruction from multiple 2D slices#352
Draft
Xiaojieqiu with Copilot wants to merge 4 commits into
Draft
Add assign_z_coordinates function for 3D reconstruction from multiple 2D slices#352Xiaojieqiu with Copilot wants to merge 4 commits into
Xiaojieqiu with Copilot wants to merge 4 commits into
Conversation
… documentation Co-authored-by: Xiaojieqiu <7456281+Xiaojieqiu@users.noreply.github.com>
Co-authored-by: Xiaojieqiu <7456281+Xiaojieqiu@users.noreply.github.com>
Co-authored-by: Xiaojieqiu <7456281+Xiaojieqiu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix z-axis coordinate calculation in 3D model creation
Add assign_z_coordinates function for 3D reconstruction from multiple 2D slices
Oct 14, 2025
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.
Overview
This PR addresses issue about z-axis coordinate calculation for 3D reconstruction by adding a new utility function
assign_z_coordinates()that systematically assigns z-coordinates to multiple 2D spatial transcriptomics slices.Problem
Users performing 3D reconstruction from sequential 2D tissue sections previously had no clear guidance or automated method for:
Currently, when 2D data is encountered, Spateo automatically adds zeros for z-coordinates, but there was no documented workflow for properly spacing slices in the z-dimension.
Solution
New Function:
assign_z_coordinates()Added a comprehensive function accessible via
st.tl.assign_z_coordinates()orst.align.assign_z_coordinates()that supports three z-spacing strategies:1. Default/Custom Uniform Spacing
2. Tissue Thickness-Based Spacing
3. Variable Spacing for Non-Uniform Sections
Complete Workflow Example
Key Features
Documentation Added
Technical Documentation (
docs/technicals/3d_reconstruction.md):Practical Examples (
docs/examples/3d_reconstruction_example.md):Testing
Added 8 comprehensive unit tests in
tests/alignment/test_utils.pycovering:All tests verified passing ✓
Files Changed
spateo/alignment/utils.py(+146 lines) - Core function implementationspateo/alignment/__init__.py(+1 line) - Export functionspateo/align.py(+1 line) - Module integrationdocs/technicals/3d_reconstruction.md(+339 lines) - Technical documentationdocs/technicals/index.md(+2 lines) - Add to documentation indexdocs/examples/3d_reconstruction_example.md(+203 lines) - Practical examplesdocs/examples/README.md(+18 lines) - Examples directory indextests/alignment/test_utils.py(+164 lines) - Comprehensive test suiteTotal: 8 files changed, 874 insertions (+)
Impact
This PR provides users with a systematic, flexible, and well-documented approach to z-coordinate assignment for 3D reconstruction, directly addressing the questions raised about:
The implementation follows Spateo's existing patterns and conventions, integrating seamlessly with the current alignment and visualization workflows.
Original prompt
Fixes #348
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.