Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions spimquant/workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,59 @@ active ``seg_method`` contains at least one ``otsu+k{}i{}`` entry.
else [],


rule all_batch_otsu_hist_qc:
"""Target rule to generate batch-wide Otsu threshold sweep QC reports.

Produces one HTML report per stain/method combination (across all subjects)
for every ``otsu+k{}i{}`` segmentation method. Each report shows the
aggregated histogram with Multi-Otsu threshold positions and one mid-volume
crop per subject at each threshold, enabling visual selection of a threshold
that generalises across the entire acquisition batch. Only meaningful when
the active ``seg_method`` contains at least one ``otsu+k{}i{}`` entry.
"""
input:
expand(
bids(
root=root,
datatype="group",
stain="{stain}",
desc="{desc}",
suffix="batchotsuthreshqc.html",
),
stain=stains_for_seg,
desc=otsu_seg_methods,
)
if (do_seg and len(otsu_seg_methods) > 0)
else [],


rule all_batch_otsu_hist_qc_raw:
"""Target rule to generate batch-wide Otsu threshold sweep QC reports.

Produces one HTML report per stain/method combination (across all subjects)
for every ``otsu+k{}i{}`` segmentation method. Each report shows the
aggregated histogram with Multi-Otsu threshold positions and one mid-volume
crop per subject at each threshold, enabling visual selection of a threshold
that generalises across the entire acquisition batch. Only meaningful when
the active ``seg_method`` contains at least one ``otsu+k{}i{}`` entry.
"""
input:
expand(
bids(
root=root,
datatype="group",
stain="{stain}",
desc="{desc}",
suffix="batchotsuthreshqcraw.html",
),
stain=stains_for_seg,
desc=otsu_seg_methods,
)
if (do_seg and len(otsu_seg_methods) > 0)
else [],



rule all_register:
input:
inputs["spim"].expand(
Expand Down
101 changes: 101 additions & 0 deletions spimquant/workflow/rules/qc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,107 @@ Only applicable when ``seg_method`` uses the ``otsu+k{}i{}`` pattern.
script:
"../scripts/qc_otsu_threshold_sweep.py"

rule qc_batch_otsu_threshold_sweep_raw:
"""Batch threshold sweep QC HTML report for multiotsu segmentation, on raw uncorrected images.

Uses the batch-wide Multi-Otsu thresholds (computed from the aggregated
histogram across all subjects in the dataset) to sweep over a range of
threshold values and display one mid-volume 2D crop per subject at each
threshold. Subjects are shown as columns so that the user can immediately
see whether a given threshold generalises across the entire acquisition batch.

The aggregated histogram PNG is embedded at the top of the report.

Only applicable when ``seg_method`` uses the ``otsu+k{}i{}`` pattern.
"""
input:
zarrs=inputs["spim"].expand(),
thresholds_png=bids(
root=root,
datatype="group",
stain="{stain}",
level=str(config["segmentation_level"]),
desc="{desc}",
suffix="thresholds.png",
),
output:
html=bids(
root=root,
datatype="group",
stain="{stain}",
desc="{desc}",
suffix="batchotsuthreshqcraw.html",
),
threads: 4
resources:
mem_mb=32000,
runtime=60,
params:
n_thresholds=10,
patch_size=300,
level=config["segmentation_level"],
hist_percentile_range=[float(x) for x in config["seg_hist_percentile_range"]],
zarrnii_kwargs=lambda wildcards: {"orientation": config["orientation"],"channel_labels":[wildcards.stain]},
script:
"../scripts/qc_batch_otsu_threshold_sweep.py"



rule qc_batch_otsu_threshold_sweep:
"""Batch threshold sweep QC HTML report for multiotsu segmentation.

Uses the batch-wide Multi-Otsu thresholds (computed from the aggregated
histogram across all subjects in the dataset) to sweep over a range of
threshold values and display one mid-volume 2D crop per subject at each
threshold. Subjects are shown as columns so that the user can immediately
see whether a given threshold generalises across the entire acquisition batch.

The aggregated histogram PNG is embedded at the top of the report.

Only applicable when ``seg_method`` uses the ``otsu+k{}i{}`` pattern.
"""
input:
zarrs=inputs["spim"].expand(
bids(
root=work,
datatype="seg",
stain="{stain}",
level=str(config["segmentation_level"]),
desc="corrected{method}".format(method=config["correction_method"]),
suffix="SPIM.ome.zarr",
**inputs["spim"].wildcards,
),
allow_missing=True,
),
thresholds_png=bids(
root=root,
datatype="group",
stain="{stain}",
level=str(config["segmentation_level"]),
desc="{desc}",
suffix="thresholds.png",
),
output:
html=bids(
root=root,
datatype="group",
stain="{stain}",
desc="{desc}",
suffix="batchotsuthreshqc.html",
),
threads: 4
resources:
mem_mb=32000,
runtime=60,
params:
n_thresholds=10,
patch_size=300,
level=config["segmentation_level"],
hist_percentile_range=[float(x) for x in config["seg_hist_percentile_range"]],
zarrnii_kwargs={"orientation": config["orientation"]},
script:
"../scripts/qc_batch_otsu_threshold_sweep.py"


rule qc_roi_summary:
"""Per-ROI summary QC: top-region bar plots for a single subject.
Expand Down
Loading
Loading