Skip to content

Support datasets mixing .ims and .ome.zarr image formats - #196

Open
Arshya-Guru wants to merge 1 commit into
plaquesfrom
mixed-spim-extensions
Open

Support datasets mixing .ims and .ome.zarr image formats#196
Arshya-Guru wants to merge 1 commit into
plaquesfrom
mixed-spim-extensions

Conversation

@Arshya-Guru

Copy link
Copy Markdown

snakebids requires every component to reduce to a single path template, and the image extension was baked into the spim template - so a dataset containing both Imaris files and OME-Zarr stores failed at dag-building.
Generate the spim component with extension as a wildcard so one template covers both formats, resolve each scan's concrete image path in rules through a spim_input() lookup function, and re-expose the component with the extension stripped from its wildcards/zip_lists so it cannot leak into derived output templates.

snakebids requires every component to reduce to a single path template,
and the image extension was baked into the spim template - so a dataset
containing both Imaris files and OME-Zarr stores failed at dag-building
with "Multiple path templates for one component". SPIMpack works around
this by symlinking every image under a hardcoded .ims name, which makes
zarr-backed stores invisible to pybids and silently drops those
subjects from the workflow.

Generate the spim component with `extension` as a wildcard so one
template covers both formats, resolve each scan's concrete image path
in rules through a spim_input() lookup function, and re-expose the
component with the extension stripped from its wildcards/zip_lists so
it cannot leak into derived output templates.

Verified on a uniform all-.ims dataset (job table identical to
baseline, 6078 jobs) and on a mixed 24x.ims/7x.ome.zarr dataset
(all 31 subjects planned, per-subject inputs resolve to the correct
format, no extension appears in output paths).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012437t8NSZLaZAwoAWK6bNT
Copilot AI lite review requested due to automatic review settings August 18, 2026 20:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Snakemake/Snakebids input handling so a single spim BIDS component can represent datasets that mix SPIM image formats (e.g., .ims alongside .ome.zarr) without failing DAG construction. It does so by making extension a wildcard for discovery, then resolving each job’s concrete input path via a lookup function while preventing extension from propagating into downstream output templates.

Changes:

  • Adds an extension wildcard to the spim Snakebids input component and introduces spim_input() to resolve the concrete per-scan input path.
  • Re-exposes inputs["spim"] with extension removed from its wildcards/zip lists to avoid leaking extension into derived output templates.
  • Updates rules to use spim_input (and updates metadata prepopulation to iterate over the raw component).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spimquant/workflow/Snakefile Introduces spim_raw, builds a wildcard→path lookup, defines spim_input(), and re-wraps the spim component without extension for downstream expansion.
spimquant/workflow/rules/common.smk Updates stain discovery to iterate over the raw SPIM inputs (spim_raw.expand()).
spimquant/workflow/rules/vessels.smk Switches raw SPIM rule inputs to spim_input.
spimquant/workflow/rules/templatereg.smk Switches raw SPIM references (inputs/params) to spim_input.
spimquant/workflow/rules/segmentation.smk Switches raw SPIM inputs to spim_input.
spimquant/workflow/rules/qc.smk Switches raw SPIM inputs to spim_input.
spimquant/workflow/rules/plaques.smk Switches raw SPIM inputs to spim_input.
spimquant/workflow/rules/patches.smk Switches raw SPIM inputs to spim_input.
spimquant/workflow/rules/import.smk Switches raw SPIM inputs to spim_input.
spimquant/workflow/rules/counts.smk Switches raw SPIM inputs to spim_input.
spimquant/config/snakebids.yml Adds extension to the spim wildcards list so a single template covers multiple formats.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +75 to +85
_spim_key_wildcards = [w for w in spim_raw.zip_lists if w != "extension"]
_spim_path_lookup = {
tuple(spim_raw.zip_lists[w][i] for w in _spim_key_wildcards): path
for i, path in enumerate(spim_raw.expand())
}


def spim_input(wildcards):
"""Concrete raw image path (whatever its extension) for a job's wildcards."""
return _spim_path_lookup[tuple(getattr(wildcards, w) for w in _spim_key_wildcards)]

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