Skip to content

Comments

Added channels_metadata to plate root zarr.json#197

Open
exxpyy wants to merge 3 commits intozarr3-transitionfrom
ege/zarr3-work
Open

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

Conversation

@exxpyy
Copy link
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
Collaborator

mat10d commented Feb 17, 2026

Make sure to ruff check and format this before finalizing.

Copy link
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!

entry["name"] = name

entry.setdefault("description", "")
entry["channel_type"] = "fluorescent" # since we only have fluorescent channels
Copy link
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 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
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 on lines 45 to 46
print("hcs.write_hcs_metadata received channels_metadata:")
print(json.dumps(channels_metadata, indent=2))
Copy link
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
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?

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
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),

),
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
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.

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