Skip to content

Speed up granularity ~2x by only upsampling labeled voxels - #51

Merged
d33bs merged 2 commits into
WayScience:mainfrom
d33bs:gran-32
Aug 12, 2026
Merged

Speed up granularity ~2x by only upsampling labeled voxels#51
d33bs merged 2 commits into
WayScience:mainfrom
d33bs:gran-32

Conversation

@d33bs

@d33bs d33bs commented Aug 12, 2026

Copy link
Copy Markdown
Member

Description

compute_granularity was upsampling the entire subsampled image back to full resolution every scale, just to compute means over a handful of labeled objects. Now it only interpolates/scans the voxels that actually belong to a labeled object — mathematically identical result (verified byte-identical against the old implementation, plus unchanged accuracy-lock fingerprints), ~2.8x faster on real data (5.15s → 1.85s).

Also fixes a pre-existing bug in the benchmark scorecard's real-world colocalization loader (missing image_id) so the full scorecard runs end-to-end.

What kind of change(s) are included?

  • Documentation (changes docs or other related content)
  • Bug fix (fixes an issue).
  • Enhancement (adds functionality).
  • Breaking change (these changes would cause existing functionality to not work as expected).

Checklist

Please ensure that all boxes are checked before indicating that this pull request is ready for review.

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have searched for existing content to ensure this is not a duplicate.
  • I have performed a self-review of these additions (including spelling, grammar, and related).
  • These changes pass all pre-commit checks.
  • I have added comments to my code to help provide understanding
  • I have added a test which covers the code changes found within this PR
  • I have deleted all non-relevant text in this pull request template.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@075abe0). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #51   +/-   ##
=======================================
  Coverage        ?   94.75%           
=======================================
  Files           ?       17           
  Lines           ?     1658           
  Branches        ?        0           
=======================================
  Hits            ?     1571           
  Misses          ?       87           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@d33bs
d33bs marked this pull request as ready for review August 12, 2026 12:06
@d33bs
d33bs requested a review from MikeLippincott August 12, 2026 12:06

@gwaybio gwaybio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great to see the speedup! A few comments, mostly on tests.

Comment thread src/zedprofiler/featurization/granularity.py
Comment thread tests/featurization/test_granularity.py Outdated
Comment thread tests/featurization/test_granularity.py

@MikeLippincott MikeLippincott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! This will speed up "~empty" images but the images with high information content and object counts will still take a lot of time to compute.

This change will increase efficiency and increase resource requirement heterogeneity as a by product, which IMO is worth the speed up!

Co-Authored-By: Gregory Way <gregory.way@gmail.com>
@d33bs

d33bs commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

Thank you @gwaybio and @MikeLippincott !

@d33bs
d33bs merged commit 62af460 into WayScience:main Aug 12, 2026
13 checks passed
@d33bs
d33bs deleted the gran-32 branch August 12, 2026 17:49
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.

3 participants