Skip to content

Added channels_metadata to plate root zarr.json#197

Merged
exxpyy merged 3 commits intozarr3-transitionfrom
ege/zarr3-work
Feb 24, 2026
Merged

Added channels_metadata to plate root zarr.json#197
exxpyy merged 3 commits intozarr3-transitionfrom
ege/zarr3-work

Conversation

@exxpyy
Copy link
Copy Markdown
Collaborator

@exxpyy exxpyy commented Feb 16, 2026

Added support for writing channels_metadata into the plate root zarr.json for zarr outputs by passing metadata specific to the module (SBS/phenotype) through Snakemake into the HCS metadata writer. This makes the generated Zarr hierarchy’s root metadata align better with the expected CZI-style root metadata.

@mat10d
Copy link
Copy Markdown
Collaborator

mat10d commented Feb 17, 2026

Make sure to ruff check and format this before finalizing.

Copy link
Copy Markdown
Collaborator

@mat10d mat10d left a comment

Choose a reason for hiding this comment

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

Small changes!

Comment thread workflow/lib/shared/hcs.py Outdated
entry["name"] = name

entry.setdefault("description", "")
entry["channel_type"] = "fluorescent" # since we only have fluorescent channels
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This overwrites whatever the user put in config. Should be entry.setdefault("channel_type", "fluorescent") instead. The BioHub spec uses labelfree, virtual_stain, etc. — we'll need those eventually and this line would silently eat them.

Comment thread workflow/lib/shared/hcs.py Outdated
Comment on lines +136 to +142
# Ensure biological_annotation exists
bio = entry.get("biological_annotation") or {}
if not isinstance(bio, dict):
bio = {}
for k in ("organelle", "marker", "marker_type", "full_label"):
bio.setdefault(k, "")
entry["biological_annotation"] = bio
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The normalize function fills {"organelle": "", "marker": "", "marker_type": "", "full_label": ""} when biological_annotation is empty or {}. Better to omit the key entirely if all values are empty —cleaner JSON. The BioHub spec only includes biological_annotation on channels that actually have annotations (e.g. their Phase2D and Focus3D channels don't have one at all).

Comment thread workflow/lib/shared/hcs.py Outdated
Comment on lines +45 to +46
print("hcs.write_hcs_metadata received channels_metadata:")
print(json.dumps(channels_metadata, indent=2))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove these before merging, or add a verbose flag.

phenotype_samples_fp: config/phenotype_samples.tsv
phenotype_channels_metadata:
- name: DAPI
index: 0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need the index now that it is set explicitly through the code?

Comment thread workflow/rules/preprocess.smk Outdated
params:
plate_zarr_dirs=[str(PREPROCESS_FP / "sbs" / f"{p}.zarr")
for p in sorted(sbs_wildcard_combos["plate"].unique())],
channels_metadata=lambda wildcards: config["preprocess"].get("sbs_channels_metadata", None),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can be simplified as

channels_metadata=config["preprocess"].get("sbs_channels_metadata", None),

Comment thread workflow/rules/preprocess.smk Outdated
),
plate_zarr_dirs=[str(PREPROCESS_FP / "phenotype" / f"{p}.zarr") # creates list like 1.zarr, 2.zarr, etc
for p in sorted(phenotype_wildcard_combos["plate"].unique())], # finding which plates exist
channels_metadata=lambda wildcards: config["preprocess"].get("phenotype_channels_metadata", None),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above. Simplify read in.

@mat10d
Copy link
Copy Markdown
Collaborator

mat10d commented Feb 24, 2026

You can go ahead and merge this to zarr3-transition.

@exxpyy exxpyy merged commit 6d8f5dc into zarr3-transition Feb 24, 2026
1 check passed
@exxpyy exxpyy deleted the ege/zarr3-work branch February 24, 2026 20:37
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