Skip to content

Fix stain-for-reg fallback when spim_templates exists but has no matching stains#115

Open
Copilot wants to merge 2 commits intospim-templatesfrom
copilot/sub-pr-112
Open

Fix stain-for-reg fallback when spim_templates exists but has no matching stains#115
Copilot wants to merge 2 commits intospim-templatesfrom
copilot/sub-pr-112

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

When spim_templates was defined in the template config but none of its keys matched the available dataset stains, stain_for_reg remained None and the workflow raised a ValueError — even though a valid registration stain existed in config["stains_for_reg"]. The fallback to config["stains_for_reg"] was unreachable in this case because it was in an else branch tied to spim_templates is None.

Change

  • Replaced else: with if not use_spim_template: so the config["stains_for_reg"] fallback runs whenever SPIM-template matching fails, regardless of whether spim_templates was absent or simply had no overlap with the available stains.
# Before
if spim_templates is not None:
    for stain in spim_templates.keys():
        if stain in stains:
            stain_for_reg = stain
            use_spim_template = True
            break
else:  # ← only runs when spim_templates is None
    for stain in config["stains_for_reg"]:
        ...

# After
if spim_templates is not None:
    for stain in spim_templates.keys():
        if stain in stains:
            stain_for_reg = stain
            use_spim_template = True
            break

if not use_spim_template:  # ← runs when no SPIM template match found
    for stain in config["stains_for_reg"]:
        ...

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…tching stains

Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on accommodating new templates Fix stain-for-reg fallback when spim_templates exists but has no matching stains Mar 4, 2026
@akhanf akhanf marked this pull request as ready for review March 4, 2026 20: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.

2 participants