Functions to QC histopathology images#1036
Merged
Conversation
3 tasks
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1036 +/- ##
==========================================
- Coverage 74.05% 73.56% -0.50%
==========================================
Files 39 44 +5
Lines 6495 6929 +434
Branches 1122 1174 +52
==========================================
+ Hits 4810 5097 +287
- Misses 1230 1347 +117
- Partials 455 485 +30
🚀 New features to boost your workflow:
|
selmanozleyen
approved these changes
Nov 3, 2025
selmanozleyen
requested changes
Feb 26, 2026
Member
selmanozleyen
left a comment
There was a problem hiding this comment.
Things to do:
- Sync with main (some files are old)
- Vectorize for loops I mentioned
- Use scikit-image when we can
e4890cc to
5952a86
Compare
Replaces the earlier qc_sharpness prototype with a general-purpose qc_image function that computes tile-based QC metrics on spatial images. Compute (sq.experimental.im.qc_image): - Tile-based metrics: sharpness (tenengrad, var_of_laplacian), intensity (brightness, entropy), staining (hematoxylin/eosin via HED deconvolution), and artifact detection (fold fraction, tissue fraction) - QCMetric enum and registry mapping each metric to its input kind and callable - Percentile-rank unfocus scoring within tissue tiles for outlier detection - Preview overlay showing flagged tiles on the image - Shared utilities in _utils.py: vectorized TileGrid (numpy + shapely.box), mask helpers, and shapes persistence (also used by make_tiles) Plot (sq.experimental.pl.qc_image): - Multi-panel summary: spatial view, KDE distribution (tissue vs background), and descriptive statistics per metric Metrics use scikit-image filters (sobel_h/v, laplace) instead of hand-rolled convolutions, and thread-safe HED caching avoids redundant deconvolution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5952a86 to
a5e4dfd
Compare
…ficiency - Rename _ensure_tissue_mask → _resolve_tissue_mask (clearer intent) - Split intensity/staining/artifact metrics into _intensity_metrics.py, keeping _qc_metrics.py as a lean registry + enums module - Remove redundant tissue_similarity/background_similarity columns - Simplify _detect_tissue_from_mask → _classify_tiles_by_tissue (accept TileGrid, return 2 arrays instead of 4, reuse pre-binarized mask) - Cache FFT frequency grid via @lru_cache (avoid recomputing per tile) - Pre-compute grayscale luminance weights as module-level constant - Fix O(n) var_names lookup in plotting with dict - Reduce allocations in _entropy - Fix stats text indentation in plot panel - Revert stale .pre-commit-config.yaml pins to match main - Document _fold_fraction HSV thresholds as H&E-tuned Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- test_plot_calc_qc_image_not_hne: use metrics=None so is_hne=False actually exercises different default metrics (was identical to hne test) - test_qc_image_rgb_metric: add explicit is_hne=True for clarity - Add test_qc_image_outlier_detection_with_tissue: verify outlier and tissue columns are populated correctly - Add test_qc_image_outlier_detection_without_tissue: verify detect_tissue=False path (no tissue columns, no NaN scores) - Add test_qc_image_compute_only: verify minimal compute-only path Note: QCImage_calc_qc_image_not_hne.png reference image needs regeneration since the test now produces a different plot. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
|
@timtreis could you resolve the conflicts please its hard to review like this |
…tion-to-qc-he-images # Conflicts: # .pre-commit-config.yaml # src/squidpy/experimental/im/_make_tiles.py
Functions exported across private modules (e.g. _sharpness_metrics, _intensity_metrics, _utils) no longer use a leading underscore since the module itself is already private. Also removes the unnecessary lru_cache from fft_high_freq_mask — the mask computation is cheap relative to the fft2 call it supports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
…en/squidpy into issue1034-suggestion
selmanozleyen
approved these changes
Apr 8, 2026
Member
selmanozleyen
left a comment
There was a problem hiding this comment.
all looks good except the points I made. We can put them as a TODO and move on if we want to
Co-authored-by: Selman Özleyen <32667648+selmanozleyen@users.noreply.github.com>
…-qc-he-images Resolve conflict in _intensity_metrics.py: keep the batched hed_metrics() function from the PR and remove the old thread-local cache approach. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
selmanozleyen
pushed a commit
to selmanozleyen/squidpy
that referenced
this pull request
Apr 13, 2026
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.
IMPORTANT: Please search among the Pull requests before creating one.
Description
How has this been tested?
Closes