Add animated GIF QC for per-instance and coloc crops#145
Merged
Conversation
Agent-Logs-Url: https://github.com/khanlab/SPIMquant/sessions/6deb859a-f977-4b11-ba96-53112670e4ab Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Agent-Logs-Url: https://github.com/khanlab/SPIMquant/sessions/6deb859a-f977-4b11-ba96-53112670e4ab Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
…evel offsets Agent-Logs-Url: https://github.com/khanlab/SPIMquant/sessions/6deb859a-f977-4b11-ba96-53112670e4ab Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add QC rules and script for generating animated GIFs
Add animated GIF QC for per-instance and coloc crops
Apr 4, 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.
Adds two new QC rules that produce animated GIFs of 2D SPIM crops centred on each detected instance, showing all stain channels side-by-side with a hollow circle marker for the equivalent spherical diameter and per-frame annotation.
New rules (
qc.smk)qc_stain_instance_gif—{stain}wildcard selects the instance type; reads aggregated regionprops parquet; produces one GIF per atlas seg × stain × seg methodqc_coloc_instance_gif— same layout for colocalized pairs; reads coloc parquet; gated ondo_colocBoth rules emit two outputs:
*instancerandom.gif/*colocinstancerandom.gif— frames in reproducible randomised order*instancesorted.gif/*colocinstancesorted.gif— frames sorted ascending by equivalent spherical radiusBoth are wired into
rule all_qc.New script (
qc_instance_gif.py)Shared by both rules via
snakemake.params.instance_type = "stain" | "coloc".Key behaviours:
patch_size×patch_size2D axial slice at each instance's subject-space position viaZarrNii.crop_centeredradius = (3·nvoxels / 4π)^⅓voxels (avg radius for coloc pairs)idx | pos(x,y,z) | atlas ROI | radiusZarrNiiAtlas.label_region_properties; failure is logged and non-fatalmax_instanceswhen the table is largepatch_sizeandmax_instancesare configurable viainstance_gif_patch_size/instance_gif_max_instancesin the workflow config (defaults 100 / 200).compute_colocalization.pyAdded
pos_coloc_x/y/z— subject-space midpoint of the two objects — to the coloc parquet. Required forcrop_centeredcalls in the GIF script (the existingtemplate_coloc_x/y/zare in template space only).