Add batch-wide histogram aggregation, Multi-Otsu thresholding, and QC sweep report#157
Draft
Add batch-wide histogram aggregation, Multi-Otsu thresholding, and QC sweep report#157
Conversation
…rules Agent-Logs-Url: https://github.com/khanlab/SPIMquant/sessions/1911c21b-2dbc-4019-96d4-4c15c24c890a Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add rules for histogram calculation and threshold optimization
Add batch-wide histogram aggregation, Multi-Otsu thresholding, and QC sweep report
Apr 11, 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.
Enables batchwide threshold optimization for SPIM segmentation: since acquisition parameters are constant within a batch, a single threshold should be computed from all subjects together rather than per-subject. Adds a pipeline from per-subject histogram → batch aggregation → Multi-Otsu → visual QC sweep across all subjects.
New rules (
segmentation.smk)compute_spim_histogram— computes intensity histogram from raw SPIM channel at an arbitrary pyramid level via Dask; savescounts+bin_edgesas.npzaggregate_histograms— sums per-subject.npzhistograms into a single batch histogram (group datatype output)multiotsu_from_batch_histogram— applies percentile-range filtering on the aggregated histogram, then runs Multi-Otsu; outputsthresholds.tsv+thresholds.pngNew rule (
qc.smk)qc_batch_otsu_threshold_sweep— group-level HTML report: sweeps threshold values, showing one mid-volume 2D crop per subject as columns, so the user can immediately see whether a threshold generalises across the batch. Batch histogram PNG is embedded at the top.New target rule (
Snakefile)all_batch_otsu_hist_qc— triggers allbatchotsuthreshqc.htmlreports for everystains_for_seg × otsu_seg_methodscombinationFile layout
compute_spim_histogramsub-*/seg/stain-*/level-*/histogram.npzaggregate_histogramsgroup/stain-*/level-*/histogram.npzmultiotsu_from_batch_histogramgroup/stain-*/level-*/desc-otsu+k{k}i{i}_thresholds.{png,tsv}qc_batch_otsu_threshold_sweepgroup/stain-*/desc-otsu+k{k}i{i}_batchotsuthreshqc.htmlThe per-subject
qc_otsu_threshold_sweepandmultiotsurules are unchanged; the new batch pipeline is additive.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
zenodo.org/usr/bin/python3 python3 ./spimquant/run.py /home/REDACTED/work/SPIMquant/SPIMquant/tests/bids_ds /tmp/test_out participant -np(dns block)If you need me to access, download, or install something from one of these locations, you can either: