Skip to content

Chunking patch#198

Merged
rhoadesScholar merged 2 commits intomainfrom
chunking_patch
Feb 23, 2026
Merged

Chunking patch#198
rhoadesScholar merged 2 commits intomainfrom
chunking_patch

Conversation

@rhoadesScholar
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 23, 2026 19:07
@rhoadesScholar rhoadesScholar merged commit b9e687e into main Feb 23, 2026
2 checks passed
@rhoadesScholar rhoadesScholar deleted the chunking_patch branch February 23, 2026 19:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the chunked array downsampling logic that caused broadcast errors when dealing with half-integer scaled dimensions. The fix aligns the output shape calculation with scikit-image's rescale function by using np.round instead of np.ceil, and adapts the chunk placement logic to handle the actual downsampled chunk shapes.

Changes:

  • Fixed output shape calculation in _load_array_chunked to use np.round instead of np.ceil, matching skimage's internal behavior
  • Updated chunk placement logic to derive output slice bounds from actual downsampled chunk shapes rather than predicted sizes
  • Added comprehensive regression tests covering single-chunk and multi-chunk scenarios for both instance and semantic data types
  • Added writer.flush() calls after figure logging in train.py for better data persistence
  • Code formatting improvements in train.py for readability

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/cellmap_segmentation_challenge/utils/matched_crop.py Fixed rounding bug in output shape calculation (line 191) and chunk placement logic (lines 244-256) to prevent broadcast errors
tests/test_matched_crop.py Added three comprehensive regression tests covering half-integer rounding scenarios for instance/semantic classes and multi-chunk processing
src/cellmap_segmentation_challenge/train.py Added writer.flush() calls after add_figure for better reliability and improved code formatting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 238 to 242
out_z_end = min(int(np.ceil(z_end * scale_factors[0])), output_shape[0])
out_y_start = int(y_start * scale_factors[1])
out_y_end = min(int(np.ceil(y_end * scale_factors[1])), output_shape[1])
out_x_start = int(x_start * scale_factors[2])
out_x_end = min(int(np.ceil(x_end * scale_factors[2])), output_shape[2])
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variables out_z_end, out_y_end, and out_x_end computed here are never used. The actual end positions are calculated later (lines 248-250) based on the downsampled chunk shape. These lines can be removed to avoid confusion and reduce unnecessary computation.

Copilot uses AI. Check for mistakes.
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.

2 participants