Skip to content

Flatten the 'merged' annotation label to the output root#155

Merged
clemsgrs merged 1 commit into
mainfrom
flatten-merged-annotation
Jun 23, 2026
Merged

Flatten the 'merged' annotation label to the output root#155
clemsgrs merged 1 commit into
mainfrom
flatten-merged-annotation

Conversation

@clemsgrs

Copy link
Copy Markdown
Owner

What

Make is_flattened_annotation treat "merged" as flat (alongside None and "tissue"), so the union-of-classes output mode lands at the flat output root rather than a stray merged/ subdirectory.

return annotation is None or annotation in ("tissue", "merged")

Why

is_flattened_annotation is the single source of truth for the annotation→path rule. Merged artifacts are already written to the flat root internally — a merged TilingResult carries annotation=None — but the process_list row is labelled "merged" (by _build_success_process_row) so it isn't mistaken for plain tissue.

That left consumers in a bind: to honor the flat layout they had to blank "merged"None before feeding it to the path rule, which also erased the tissue-vs-merged distinction in the label they surface to users. Flattening "merged" here lets the informative label flow through unchanged while still resolving to the flat root.

Safety

The change is inert within hs2p: no call site ever passes the literal "merged" into the rule — merged results carry annotation=None, and is_flattened_annotation is only ever called with a TilingResult.annotation (None / "tissue" / a real class). So no hs2p artifact path moves. It only unblocks downstream consumers (e.g. slide2vec) that read the "merged" process_list label.

Tests

  • test_annotation_path_flattening now asserts "merged" flattens, and that look-alikes ("Merged", "merged_x") still get their own subdir.
  • Full suite green (the only failures are the pre-existing test_standalone_mask_pyramid.py ones, which import a scripts/generate_tissue_mask_pyramid.py that is absent from the tree — unrelated to this change).

is_flattened_annotation is the single source of truth for the annotation->path
rule. It already collapses None and the 'tissue' sentinel to the flat root, but
not 'merged' — the union-of-classes output mode that carries no single class.

merged artifacts are already written flat internally (their TilingResult.annotation
is None), but the process_list row is labelled 'merged' so it is not mistaken for
tissue. Consumers that read that label back and feed it to the path rule were
therefore forced to blank 'merged' to None to keep the artifact flat, which also
erased the tissue-vs-merged distinction. Treating 'merged' as flattened here lets
the informative label flow through unchanged while still landing at the flat root.

The change is inert within hs2p itself (no call site ever passes the literal
'merged' — merged results carry annotation=None), so it only unblocks downstream
consumers. Extends the flattening test to cover 'merged' (and that 'Merged' /
'merged_x' still get their own subdir).
@clemsgrs
clemsgrs merged commit 0c20df7 into main Jun 23, 2026
1 check passed
@clemsgrs
clemsgrs deleted the flatten-merged-annotation branch June 23, 2026 23:08
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.

1 participant