Repository navigation
6.1.0
This release gives hs2p's annotation-mask vocabulary a single typed home: MaskSamplingConfig. Pixel mapping, colors, per-label coverage, output mode and sampling strategy now live in one validated dataclass, so downstream tools (slide2vec, soma) can compose it instead of keeping their own drifting copies. The change breaks the API: read the migration notes below before upgrading. For the same inputs, sampling outputs are byte-identical to 6.0.0.
Added
MaskSamplingConfigandDEFAULT_MASK_SAMPLING, both exported fromhs2p.MaskSamplingConfigis a frozen, keyword-only dataclass with the fieldspixel_mapping,min_coverage,colors,output_mode("merged"|"per_annotation") andstrategy("joint"|"independent"). It checks its own fields when built: label values in[0, 255], each value under one label only, coverages in[0, 1]that name declared labels, andcolorscovering every label.DEFAULT_MASK_SAMPLINGis the default{background, tissue}block, and itsmin_coverage["tissue"](0.01) is now the only place the tissue threshold is set. (#272)resolve_mask_sampling_config(cfg)builds aMaskSamplingConfigfrom a loaded YAML config. (#272)
Changed (breaking)
tile_slide(...)andtile_slides(...)now takemasks=MaskSamplingConfig(...)(defaultDEFAULT_MASK_SAMPLING). Thesampling=,selection_strategy=andoutput_mode=arguments are removed, with no alias. (#272)TilingConfig.min_coverageandTilingConfig.independent_samplingare removed. Set the tissue threshold viamasks.min_coverage["tissue"]and the strategy viamasks.strategy.CompatibilitySpecnow requiresmasks. (#272)resolve_sampling_request(*, masks)replaces the cfg-based resolvers.resolve_sampling_spec,resolve_sampling_strategy,resolve_output_modeandbuild_default_sampling_specare removed. (#272)- YAML:
tiling.independent_sampling: true|falsebecomestiling.masks.strategy: independent|joint. Configs that still use the old key fail with a message that names the replacement. (#272) output_modeis no longer lowercased, soMERGEDis rejected; usemergedorper_annotation. (#272)- Label values are normalized to tuples, so
tissue: [1]now counts as the default vocabulary and does binary tissue tiling. Before, it triggered annotation sampling. Through the Python API, the default{background, tissue}vocabulary always means tissue tiling, as it already did in the CLI. (#272)
Migration
# before (6.0.0)
tile_slide(..., tiling=TilingConfig(..., min_coverage=0.05), sampling=spec, output_mode="merged")
# after (6.1.0)
from hs2p import MaskSamplingConfig
masks = MaskSamplingConfig(
pixel_mapping={"background": (0,), "tissue": (1,)},
min_coverage={"tissue": 0.05},
output_mode="merged",
)
tile_slide(..., tiling=TilingConfig(...), masks=masks)