diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d50033..dd97845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ Release notes and migration notes of `morphobricks-normalization`. Numbers are p issues of [CellMigrationLab/morphobricks-normalization](https://github.com/CellMigrationLab/morphobricks-normalization). The decisions are in [docs/plan.md](docs/plan.md) §12. +## Unreleased + +- Tests: the vendored Spec test material (`tests/spec_fixtures`) is re-pinned from `cc9820f` to + MorphoBricks-Spec main `1167108`, regenerated with the Spec's `tools/vendor.py`. New fixtures + i136–i141, t14–t15, v39–v40; i111 is now the valid fixture v38 (`parent_labels`, owner + decision PL1); `docs/experiment-v1.md` (amendments PL1, RH1 `rgb_header_override`, BM11) and + `tools/audit/refval.py` changed. The copy equals the Spec at `bf68d30`, the pin of + morphobricks-preprocessing v0.7.0. Test material only: no library code, output, API, message or + `schema_version` changes (the library reads no experiment description; `tools/dump_outputs.py` + digests are unchanged). + ## v0.7.1 (2026-11-17) Patch release (#104, #105, #108): the per-bin work of integer planes is 1.3–1.5× faster, signed diff --git a/tests/spec_fixtures/PIN.toml b/tests/spec_fixtures/PIN.toml index dcc4a91..430e90f 100644 --- a/tests/spec_fixtures/PIN.toml +++ b/tests/spec_fixtures/PIN.toml @@ -1,14 +1,14 @@ # The MorphoBricks-Spec commit these files are copied from (conformance plan section 1). # Updating the pin is a reviewed change: see README.md in this folder. repository = "https://github.com/CellMigrationLab/MorphoBricks-Spec" -commit = "cc9820f5b84f01bbbb5c8e3f54e70ee13cb5e9eb" +commit = "1167108ffb5b71f5d8f4fb9ef685988e328a78ba" # `git rev-parse :fixtures`, the git tree-object ID of the fixtures/ folder. The # vendored folder must hash to it, so one changed, added or missing byte fails a test. -fixtures_tree = "40fe48c6d735266ca7608fab0c3a564affc68171" +fixtures_tree = "c9e27f763789ad30d3b5d04bead2a82d84125250" # `git rev-parse :`, the git blob ID of each other vendored file. [files] -"docs/experiment-v1.md" = "d21388ad9e48608ce42adb0f7b0a4c600cb2c9a7" -"tools/audit/refval.py" = "0ea83094cfa8c1bcb6ea596e17b3f0c948ad5dfb" +"docs/experiment-v1.md" = "caf74376265b8abbed7357baacd26f5516485a94" +"tools/audit/refval.py" = "8fcb429ae95dd0d2c1819685b3eeec720b1c712c" "tools/audit/refrecords.py" = "ef06a1ea59a93c695dbba21d2ee792667ad8e8eb" diff --git a/tests/spec_fixtures/docs/experiment-v1.md b/tests/spec_fixtures/docs/experiment-v1.md index d21388a..caf7437 100644 --- a/tests/spec_fixtures/docs/experiment-v1.md +++ b/tests/spec_fixtures/docs/experiment-v1.md @@ -9,6 +9,15 @@ round: folder labels are never restricted) gives conditions and technical repeats a canonical ID separate from their source folder label (§4.6a). A statement about a consumer is as audited as that audit; it is not a conformance claim for any brick. +- **Amended** on 11 November 2026 (owner decision PL1, ADR 0001): `representation` gains the value + `parent_labels` (§4.5b, §7, §8). +- **Amended** on 13 November 2026 (owner decision RH1, ADR 0001): an RGB unit may declare + `rgb_header_override = true` for files whose header contradicts `rgb` but that hold exactly three + interleaved samples per pixel (§4.4b, §6, §7, §8). +- **Amended** on 15 November 2026 (owner decision BM11, + [ADR 0005](adr/0005-binary-masks.md)): a `binary` mask file holds values in {0, v} for one + positive v over all its planes, stored as integers or booleans; all-zero and all-foreground files + are accepted, two or more distinct positive values and float files are refused (§4.5, §4.5b, §8). It replaces "more than two distinct values". - **Decisions:** [ADR 0001](adr/0001-experiment-description-v1.md). - **Fixtures:** [fixtures/README.md](../fixtures/README.md). **Conformance:** [conformance-plan.md](conformance-plan.md). @@ -264,6 +273,7 @@ condition; at most one per condition per repeat, guaranteed by TOML key uniquene | `display_name` | non-empty text | no | Display only (§4.8); MAY be the folder label | | `channels` | array of channel IDs | yes | ≥ 1 entry; ordered: entry *i* is source channel C*i*; every entry declared (`E_UNKNOWN_CHANNEL`); no repeats (`E_DUPLICATE_CHANNEL_IN_UNIT`) | | `image_type` | text | no | Only the value `rgb` (`E_ENUM`: exact, lower case); absent = an ordinary channel image. User-declared, never inferred (§4.4b) | +| `rgb_header_override` | boolean | no (default `false`) | Only on a unit with `image_type = "rgb"` (`E_RGB_OVERRIDE_WITHOUT_RGB`); `true` accepts a header whose colour interpretation contradicts `rgb` when every image of the unit has exactly three interleaved samples per pixel (§4.4b, amendment RH1) | **§4.4b RGB imaging units (AQ6; supersedes the D8 refusal).** RGB (interleaved colour) is an accepted, **declared** image type, per imaging unit: @@ -283,6 +293,30 @@ accepted, **declared** image type, per imaging unit: `R_IMAGE_TYPE_CONTRADICTS_HEADER`. A format whose header states no colour interpretation cannot contradict the declaration, which then stands on user confirmation and is recorded in the manifest as not header-verified. +- **Header override (owner decision RH1, 13 November 2026).** Some scanners write interleaved RGB + with a colour interpretation that is not RGB (for example TIFF photometric `MINISBLACK` with + three samples per pixel). A unit declared `rgb` MAY also declare `rgb_header_override = true`: + preprocessing then accepts a header that says the unit is not RGB **only** when every image of + the unit has exactly three samples per pixel on an interleaved samples axis (TIFF + `SamplesPerPixel = 3`, contiguous planar configuration; the samples become `R`, `G`, `B` in + stored order) and records the unit in the manifest as **declared RGB, header overridden**, with + the header's colour interpretation. Any other contradiction stays + `R_IMAGE_TYPE_CONTRADICTS_HEADER`; an image of an overridden unit without three interleaved samples + is `R_RGB_OVERRIDE_NOT_THREE_SAMPLES`. The key is never inferred, never written by a reader on its + own, and changes no channel ID; without it the contradiction is refused and the message names the + key. Owner answers of 14 November 2026: + - **Declared and effective are recorded separately.** The manifest records, per unit, the declared + key (`rgb_header_override`, `true` or `false`) and, per image, whether the override was **used** + (it lifted a contradicting header, with that header's colour interpretation) or **unused** (the + header already says RGB: accepted as header-verified; or the format states no colour + interpretation, for example OME-Zarr: accepted as not header-verified, as without the key). + The three-sample requirement applies to every image whose header the override lifts. + - **Homogeneity uses the effective type.** After a valid override every image of the unit is + effectively `rgb`; images whose headers differ only in colour interpretation (for example some + `MINISBLACK` with three interleaved samples, some photometric RGB) are homogeneous, and each + image's own header interpretation is kept as evidence. + - **The key is part of the confirmed layout.** Adding, removing or changing it reopens the N35 + confirmation of the repeat, like a change of `image_type` or of the channel list (§10). - The spec gives RGB **no scientific meaning**: no grey conversion, luminance, stain separation or joint-channel rule. Each brick owns the meaning and MUST declare whether it supports RGB; undeclared means unsupported. An analysis request that includes an RGB unit's channels for a @@ -332,7 +366,7 @@ Repeat rules: | Key | Type | Req | Rule | |---|---|---|---| | `source_type` | text | yes | Exact discovered mask type (Label rules); one mask per source type (`E_MASK_SOURCE_TYPE_REUSED`) | -| `representation` | text | yes | `instances` or `binary` (`E_ENUM`); user-confirmed, never inferred from dtype, values or names. A mask declared `binary` with more than two distinct values is refused by preprocessing's mask step (`R_MASK_CONTRADICTS_REPRESENTATION`, §4.5a); the user must declare `instances` | +| `representation` | text | yes | `instances`, `binary` or `parent_labels` (`E_ENUM`; exact, lower case); user-confirmed, never inferred from dtype, values or names. Every file of a mask declared `binary` MUST be stored as integers (signed or unsigned) or booleans, never floats (a float file is refused even when every value is whole), and MUST hold, over all its planes together, values in {0, v} for one positive integer v (a boolean file: {0, 1}); v may differ between files. An all-zero file is accepted (zero objects; an empty region where used as a region), and so is an all-foreground file {v}. A float file, or a file holding two or more distinct positive values (also when each plane alone holds one) or any negative value, is refused by preprocessing's mask step (`R_MASK_CONTRADICTS_REPRESENTATION`, §4.5a); the user must declare `instances` or `parent_labels`, or fix the file. `parent_labels`: §4.5b | | `source_channels` | array of channel IDs | no | Provenance only (what the mask was derived from); not a restriction on measured channels; each declared (`E_UNKNOWN_CHANNEL`); no duplicates (`E_DUPLICATE_VALUE`); order not semantic | | `display_name` | non-empty text | no | Display only (§4.8) | @@ -347,14 +381,52 @@ set in the run manifest, the status `checked` (with the checked files and their `not yet checked`. A run that uses a mask file whose status is `not yet checked` MUST refuse (`A_MASK_UNCHECKED`, §8); it never checks implicitly and never assumes. A new batch of files is `not yet checked` until the mask step has read it. Pixels cannot prove `instances` (an integer -mask holding only 0 and 1 is accepted as declared). - -**§4.5b Grouped (`parent_labels`) masks are out of scope in v1 (AQ8).** MorphoRelate's third -representation `parent_labels` (preprocessing kind `grouped`) has no v1 value: -`representation = "parent_labels"` is `E_ENUM`. A grouped mask cannot be declared `instances` -(wrong objects) or `binary` (more than two values: `R_MASK_CONTRADICTS_REPRESENTATION`), so it -is not described, and not analysed through a description, in v1. A design for it follows with a -later `schema_version` (v1.1); nothing here predicts its form. +mask holding only 0 and 1 is accepted as declared) or `parent_labels`: a file of either is +`checked` once the mask step has read it. + +**§4.5b Parent-label (grouped) masks (owner decision PL1, 11 November 2026; supersedes AQ8).** +`representation = "parent_labels"` declares a mask whose non-zero values each name **one group**, +for example the mitochondria of one cell, and whose pixels of one value can be in any number of +separate pieces. 0 is background. It is MorphoRelate's `parent_labels` representation and what +preprocessing's mask step suggests as the kind `grouped` (evidence only, never a pre-filled +answer: the representation is user-confirmed, §4.5). + +- **Identity.** A group is identified by the FOV key (§3.4), the mask ID and the value. A value is + never an identity on its own: the same number in another mask or another FOV is not the same + group, and no consumer joins groups or objects by number alone. +- **Not instances.** A group is not an object of this mask: its pieces are not one object, and its + value is not an object label of this mask. A `parent_labels` mask is never an object set + (`A_MASK_NOT_INSTANCES`, §8), with or without the capability below. No reader, resolver or + labeller splits it into connected components, relabels it or converts it to `instances`, and + the per-request conversion of §4.5c applies to `binary` masks only. What a brick measures + inside a group (for example its connected pieces) is that brick's own numerical rule. +- **Declared wrongly.** A grouped mask declared `binary` is refused by the mask step when a file + holds two or more distinct positive values (`R_MASK_CONTRADICTS_REPRESENTATION`, §4.5a); with one + group (0 and one value) it cannot be told from a `binary` mask. Declared `instances` it cannot be refused, + because pixels cannot prove `instances`. In both cases the user's declaration is the guard, and + the mask step's `grouped` kind is the evidence for it. +- **The parent.** The file names no mask that the values refer to. A consumer reads a value as + the label of an object only when its own request names that parent: an object set of the **same + FOV** (an `instances` mask, or a set the brick derives from one, such as MorphoRelate's + `cytoplasm`). It then reports the pixels whose value disagrees with that parent and never + reassigns them. +- **Capability (`parent_labels_support`).** A brick declares whether it reads the groups. A brick + that publishes a provider manifest declares it there as the optional top-level key + `parent_labels_support`, a boolean, with the rules of `rgb_support` (§4.4b): `true` declares + support; `false` and an absent key mean unsupported; a value that is not a boolean is a + manifest error, never read as `true`; a brick without a provider manifest states it in its + documented capabilities. Which features of a brick accept the representation is the brick's + own list; the Spec gives none. +- **Use as a region (owner decision of 11 November 2026).** A request can use a `parent_labels` + mask in the role `region` (an area, not objects) for every consumer: + - a consumer that declares `parent_labels_support` receives the values as groups (`conversion` + none); + - a consumer that does not declare it reads the mask as an **area**: every non-zero pixel is + inside, 0 is outside, and the groups are not kept. This is never silent: the resolver returns + the selection with the recorded marker `conversion = "parent_labels_as_area"`, and the + consumer records it in its run provenance or output and shows it to the user (for example + "`Mito`: parent_labels used as an area; grouping not kept"). The selection keeps + `representation = "parent_labels"`; the file is not changed. **§4.5c A binary mask is never an object set by default (AQ9).** A request that uses a `binary` mask as an object set is `A_MASK_NOT_INSTANCES`. The only way around it is an **explicit, @@ -363,7 +435,7 @@ per-request, recorded conversion** to instances chosen in the request, for examp the method and its parameters, applies to that request only, and is never automatic, never a default and never stored in `morphobricks.toml`, where `representation` stays `binary` (`binary_mask_policy` and `mask_conversion` are `E_FORBIDDEN_FIELD`, §4.7). The numerical method -stays in the brick that owns it. +stays in the brick that owns it. There is no such conversion for a `parent_labels` mask (§4.5b). ### 4.6 Immutable IDs @@ -660,6 +732,7 @@ for NFC only (phase 4) before it is resolved (phase 5). | 5 | `E_RGB_UNIT_CHANNELS` | A unit with `image_type = "rgb"` whose `channels` is not exactly `["R", "G", "B"]` (§4.4b) | | 5 | `E_RGB_TOKEN_MISUSE` | A unit without `image_type = "rgb"` lists a channel whose case-folded ID is `r`, `g` or `b` (§4.4b) | | 5 | `E_RGB_ALIAS` | A channel whose case-folded ID is `r`, `g` or `b` has non-empty `header_names` (§4.4b) | +| 5 | `E_RGB_OVERRIDE_WITHOUT_RGB` | A unit declares `rgb_header_override` without `image_type = "rgb"` (§4.4b, RH1) | | 5 | `E_DISPLAY_NAME_COLLISION` | Two display names of one kind equal after NFC and case folding (§4.8) | | 5 | `E_USED_ID_MISSING` | A declared condition, channel, repeat or technical repeat ID is not in `used_ids` (§4.9) | | 5 | `E_SOURCE_FOLDER_REUSED` | One `source_folder` on two condition IDs, or on two technical repeat IDs (§4.6a) | @@ -686,6 +759,15 @@ validation: a reader MUST NOT try to interpret fields of a version it does not s The supported set is a constant of the reader (in v1: `{1}`). It is checked without network access, against nothing fetched. A missing version is `E_SCHEMA_VERSION_MISSING` and is never mapped to a default version. +- **Amendment of v1 (owner decision PL1, 11 November 2026).** Adding the value `parent_labels` + to `representation` (§4.5b) is an amendment of version 1, not a new version: every file valid + before it stays valid with the same meaning, and a reader pinned to an earlier Spec commit + refuses the new value as `E_ENUM`, never misreads it. A reader states which rules it implements + by the Spec commit it pins (conformance plan §1). +- **Amendment of v1 (owner decision RH1, 13 November 2026).** Adding the optional unit key + `rgb_header_override` (§4.4b) is an amendment of version 1, not a new version: every file valid + before it stays valid with the same meaning (the key is absent there, which means `false`), and a + reader pinned to an earlier Spec commit refuses the key as unknown, never misreads it. - A migration between versions MUST be an explicit, recorded operation that writes a new file and never changes canonical identities silently. - **Repeat, condition, technical repeat and channel IDs are immutable** (§4.6) and never reused @@ -729,17 +811,20 @@ Required preprocessing refusals (`R_*`): | `R_UNIT_NOT_FOUND` | A declared imaging unit has no included image | | `R_UNIT_NOT_DECLARED` | A discovered imaging unit is not in the file (reconciliation draft required) | | `R_CHANNEL_COUNT_MISMATCH` | An image's channel count differs from its unit's list length | -| `R_UNIT_NOT_HOMOGENEOUS` | FOVs of one unit differ in channel count, image type, interpreted axes or header names at one C index; the message names FOV, path and C index | +| `R_UNIT_NOT_HOMOGENEOUS` | FOVs of one unit differ in channel count, image type (the effective type after a valid header override, §4.4b), interpreted axes or header names at one C index; the message names FOV, path and C index | | `R_HEADER_CONTRADICTION` | A header name at C*i* is not, after NFC of both sides and with no trimming (§4.3), in the confirmed `header_names` of the unit's channel at *i* | -| `R_IMAGE_TYPE_CONTRADICTS_HEADER` | A unit's declared image type (`rgb` or absent, §4.4b) contradicts the image header metadata, in either direction; pixels are never examined | +| `R_IMAGE_TYPE_CONTRADICTS_HEADER` | A unit's declared image type (`rgb` or absent, §4.4b) contradicts the image header metadata, in either direction, and is not an accepted `rgb_header_override` (RH1); pixels are never examined; for a unit declared `rgb` the message names `rgb_header_override` when its images have three interleaved samples | +| `R_RGB_OVERRIDE_NOT_THREE_SAMPLES` | A unit declares `rgb_header_override = true` and one of its images does not have exactly three interleaved samples per pixel (§4.4b, RH1); pixels are never examined | | `R_HETEROGENEOUS_LAYOUT_NOT_ENABLED` | Stage 1–2 only: the units do not all have the same ordered list; names the units; lifted at Stage 3 | | `R_MASK_TYPE_NOT_DECLARED` | A discovered mask type has no `masks` entry | | `R_MASK_TYPE_NAME_INVALID` | A discovered mask type name breaks the Label rules (for example `NA`, ` cells`), so it cannot be a `source_type`; refused at discovery (AQ11) | -| `R_MASK_CONTRADICTS_REPRESENTATION` | A mask declared `binary` holds more than two distinct values; raised by the mask step on each new batch, not at publication (§4.5a) | +| `R_MASK_CONTRADICTS_REPRESENTATION` | A file of a mask declared `binary` is stored as floats, or holds, over all its planes, two or more distinct positive values or a negative value (a `binary` file is integer or boolean and holds values in {0, v} for one v > 0; all-zero and all-foreground files are accepted, §4.5); raised by the mask step on each new batch, not at publication (§4.5a) | Within one unit, `R_UNIT_NOT_HOMOGENEOUS` is reported first and replaces `R_CHANNEL_COUNT_MISMATCH` and `R_HEADER_CONTRADICTION` for that unit: intra-unit discrepancies -are detected before channel identity is checked. +are detected before channel identity is checked. In a unit that declares `rgb_header_override = true`, +`R_RGB_OVERRIDE_NOT_THREE_SAMPLES` is reported before `R_UNIT_NOT_HOMOGENEOUS`: it names the image +that breaks the override's condition (owner answer of 14 November 2026). Undetectable by any layer: identical-shape, unnamed images with physically swapped fluorophores. Representative previews and explicit confirmation are the guard; image-based checks are advisory. @@ -750,7 +835,7 @@ separate code for "no image has it" (owner decision SI1); the refusal names the the images that lack it, as "present in k of n acquisitions" (`k` may be 0); refuse unless the user selects and records an eligible subset; never drop FOVs, impute, re-weight technical repeats or change biological N); -`A_MASK_NOT_INSTANCES` (a `binary` mask requested as an object set without the explicit recorded per-request conversion of §4.5c); `A_MASK_UNCHECKED` (a run uses a mask file whose representation check is `not yet checked`, §4.5a); `A_RGB_NOT_SUPPORTED` (a request on a described run includes the channels of an RGB unit, §4.4b, for a brick whose manifest does not declare `rgb_support = true`, or that does not declare it at all); `A_DRAFT_REFUSED` (§10: `RunInputs` given a draft or an unconfirmed file). Each biological repeat is +`A_MASK_NOT_INSTANCES` (a `binary` mask requested as an object set without the explicit recorded per-request conversion of §4.5c, or a `parent_labels` mask requested as an object set, with or without `parent_labels_support`, §4.5b); `A_MASK_UNCHECKED` (a run uses a mask file whose representation check is `not yet checked`, §4.5a); `A_RGB_NOT_SUPPORTED` (a request on a described run includes the channels of an RGB unit, §4.4b, for a brick whose manifest does not declare `rgb_support = true`, or that does not declare it at all); `A_DRAFT_REFUSED` (§10: `RunInputs` given a draft or an unconfirmed file). Each biological repeat is classified **fully represented**, **partially represented** or **unavailable** per request and recorded in the run manifest. Consumers resolve channels by canonical ID per unit, never by C index alone, and group by canonical repeat ID (`repeat_group`, §3.4) while keeping the source label @@ -817,7 +902,8 @@ silently; edits go to a separate draft and are published atomically after valida - **N35 reopening.** The confirmation of a repeat is reopened (draft `confirmed = false`) only when channels, layout or grouping change: a new or removed unit or member, a unit's ordered channel - list, or the pairing of folders into repeats. New FOVs (or removed ones) inside an existing unit + list, its `image_type` or its `rgb_header_override` (added, removed or changed; §4.4b), or the + pairing of folders into repeats. New FOVs (or removed ones) inside an existing unit whose confirmed layout still holds do **not** reopen it; they are reported and recorded. A changed `image_count` of a confirmed member is recorded as an `image_count_changed` record (§4.6) whether or not anything else changes in the same diff --git a/tests/spec_fixtures/fixtures/README.md b/tests/spec_fixtures/fixtures/README.md index 58f37f8..5c9fd3e 100644 --- a/tests/spec_fixtures/fixtures/README.md +++ b/tests/spec_fixtures/fixtures/README.md @@ -29,7 +29,7 @@ their section. fixtures that do not exercise the rule it equals the ID (the key), `single` for `single`; `v33`, `v34` and `t10`-`t12` separate the two. The eight undecodable or unparsable phase-1 fixtures (`i01`-`i08`) are unchanged and fail before it matters. -- `transitions/` holds thirteen files that are valid alone and are checked against a named published +- `transitions/` holds fifteen files that are valid alone and are checked against a named published predecessor: refused with an exact set of publication codes (`R_CONFIRMED_ID_CHANGED`, `R_USED_ID_REUSED`, `R_USED_ID_DROPPED`, `R_CONFIRMED_ON_CHANGED`; experiment-v1 §4.4a, §4.6, §4.9; a changed or reassigned `source_folder` counts, §4.6a) or, for `t06`, **accepted** (adding members is not a changed entity, §4.6). They need the @@ -46,6 +46,14 @@ their section. consumer audit (roadmap S0.1) is done (PR #5); its questions are answered by the third round of owner decisions (ADR 0001) and the fixtures `v28`-`v32`, `t06`-`t09`, `i100`-`i119` follow from them; the fourth round (FR1, FR2) adds `v33`, `v34`, `t10`-`t12` and `i120`-`i127`. +- **Parent-label masks (11 November 2026, owner decision PL1, supersedes AQ8).** `i111` was + invalid (`E_ENUM`) and is now valid: following the renumbering of `rv07`/`rv08` to `ri25`/`ri26` + when their verdict flipped, it moved to `valid/` as `v38` (with a `Cells` mask added), and the + number `i111` is not reused. PL1 adds `v39` and `i136`-`i139`. +- **RGB header override (13 November 2026, owner decision RH1).** Adds `v40`, `i140` and `i141`; the + image checks (three interleaved samples, the manifest record) are scenario P36 of the conformance plan. + The owner's answers of 14 November 2026 (the key is part of the confirmed layout) add the transitions + `t14` and `t15`. ## Syntax check (6 November 2026) @@ -66,10 +74,10 @@ The matrix audit ([`docs/audits/matrix-audit-2026-11-07.md`](../docs/audits/matr adds `v35`, `v36` and `i128`-`i130` for structures the catalogue lacked (a flat experiment, a biological-repeat folder named like a forbidden key, `single` rules for condition folders and members). The owner decisions of 7 November 2026 (ADR 0001, SQ6) add `i131`-`i133` (the -`single` rules for conditions) and `i134` (a duplicate key inside an inline table); the owner decision of 7 November 2026 on reserved names in `used_ids` (UR1) adds `v37` and `i135`. Its audit-only validator, [`tools/audit/refval.py`](../tools/audit/refval.py) -(`python -I tools/audit/refval.py fixtures .`), accepts 37 of 37 valid files with exactly the -listed warnings, refuses 135 of 135 invalid files with exactly the listed code set from the listed -phase, gives the listed `R_*` set for 12 of 12 transitions, and round-trips every valid and +`single` rules for conditions) and `i134` (a duplicate key inside an inline table); the owner decision of 7 November 2026 on reserved names in `used_ids` (UR1) adds `v37` and `i135`; the owner decision PL1 of 11 November 2026 moves `i111` to `v38` and adds `v39` and `i136`-`i139`. Its audit-only validator, [`tools/audit/refval.py`](../tools/audit/refval.py) +(`python -I tools/audit/refval.py fixtures .`), accepts 40 of 40 valid files with exactly the +listed warnings, refuses 140 of 140 invalid files with exactly the listed code set from the listed +phase, gives the listed `R_*` set for 15 of 15 transitions, and round-trips every valid and transition file through the canonical writer. It is an audit tool, not a reader: the conformance plan's single reference reader stays preprocessing. @@ -152,12 +160,14 @@ This is a check of the fixtures against the text, not a conformance claim for an | Swapped channel order | `v04`, `v06` | | Extra / missing channel | `v05`, `v17` (both Stage 3 / G3, GS2: P04 refuses their layouts at Stages 1-2), `v22`, `i69` | | Within-unit divergence | `i20`; P01, P02 | -| Instance vs binary masks | `v07`, `v08`, `i42`, `i43`, `i111`, `i112`; P05, P27, P28 | +| Instance vs binary masks | `v07`, `v08`, `i42`, `i43`, `i112`; P05, P27, P28 | +| Parent-label (grouped) masks | `v38`, `v39`, `i136`-`i139`; conformance §4 "Parent labels" | | Partial masks | `v09` | | Immutable IDs (no renames) | `v16`, `i75`, `i82`, `t01`, `t02`; P08, P16 | | Adding is not a change; removing or reassigning is | `t03`, `t06`, `t07`, `t08`; P07, P15 | | Case-only correction needs a new ID; set of publication codes | `t02`, `t09`, `i95`; P16 | | RGB images (declared type, fixed tokens, no aliases) | `v28`, `v29`, `i100`-`i106`, `i119`; P13, P23, P24 | +| RGB header override (RH1) | `v40`, `i140`, `i141`, `t14`, `t15`; P36 | | Reserved names (one list for channel and mask IDs; also for `used_ids.channels`) | `i59`, `i61`, `i107`-`i109`, `i135`, `v32`, `v37` | | Forbidden names apply to ID keys | `i113`-`i115` | | Folder labels never restricted: condition and technical-repeat IDs separate from `source_folder` | `v33`, `v34`, `i113`, `i115`, `i120`-`i127`, `t10`-`t12`; P32, P33 | @@ -207,8 +217,9 @@ This is a check of the fixtures against the text, not a conformance claim for an | UR1 | The reserved list also applies to `used_ids.channels` entries (they reserve those IDs) | `i135`, `v37` | | AQ5 | Canonical repeat ID added as `repeat_group`; the FOV key keeps the source label | `v03`, `v30`; P25 | | AQ6 | RGB accepted as a declared type (`image_type = "rgb"`, tokens `R`, `G`, `B`); supersedes D8 | `v28`, `v29`, `i100`-`i106`, `i119`; P13, P23, P24 | +| RH1 | A unit declared `rgb` may set `rgb_header_override = true`: a contradicting header is accepted for exactly three interleaved samples, recorded | `v40`, `i140`, `i141`, `t14`, `t15`; P36 | | AQ7 | No trimming: header names exact after NFC of both sides | `v31`, `i110`; P26 | -| AQ8 | `parent_labels` masks out of scope in v1 | `i111` | +| AQ8 | `parent_labels` masks out of scope in v1. **Superseded 11 November 2026** by PL1 | none (`i111` retired: it is now `v38`) | | AQ9 | Binary-as-instances only by an explicit, per-request, recorded conversion | `v08`, `i112`; P27 | | AQ10 | Mask representation checked in the mask step; publication records "not yet checked"; unchecked masks refuse | `v09`; P05, P28 | | AQ11 | A discovered mask type breaking the Label rules: `R_MASK_TYPE_NAME_INVALID` | P29 | @@ -225,8 +236,9 @@ This is a check of the fixtures against the text, not a conformance claim for an | RF4 | Empty records file accepted; BOM and CR before LF refused; lower-case SHA hex | `rv06`, `ri13`, `ri24`, `ri26`, `ri31` | | RF5 | `technical_repeats` not empty; `old_image_count` differs from `new_image_count` | `ri28`, `ri29` | | RF6 | Line order within one publication stated; checked by writer tests, not by the file | P34, P35 | +| PL1 | `representation = "parent_labels"` is a v1 value (amendment, not a new version): one group per non-zero value, pieces may be disconnected, never instances, never split; a brick reads the groups only by declaring `parent_labels_support`, any other brick uses it as a recorded area in the role `region`; no parent-mask field | `v38` (was `i111`), `v39`, `i136`-`i139`; conformance §4 "Parent labels" | -## Valid fixtures (37) +## Valid fixtures (40) | Fixture | Source | Expected | Homogeneous | Case | |---|---|---|---|---| @@ -267,6 +279,9 @@ This is a check of the fixtures against the text, not a conformance claim for an | [`v35_flat_experiment`](valid/v35_flat_experiment.toml) | Matrix audit 2026-11-07, case F01 | pass | yes | The experiment folder is itself the leaf: condition, repeat and technical repeat are all `single`. The condition `single` has `source_folder = "single"` ("no condition folder level", 4.2, 3.2) and is the only condition (owner decision SQ6, matrix audit MS-1). | | [`v36_repeat_folder_forbidden_name`](valid/v36_repeat_folder_forbidden_name.toml) | Matrix audit 2026-11-07, case F16 | pass | yes | Biological-repeat folders `z` paired into repeat `R1`; `source_repeat` is never restricted. The folder label `z` is not an allowed repeat ID (`i130`), so no ID is proposed and the user names `R1` (4.6a; owner decision SQ6, matrix audit MS-2). | | [`v37_used_ids_reserved_near_misses`](valid/v37_used_ids_reserved_near_misses.toml) | Owner decision UR1 (Spec issue 11) | pass | yes | `v32` with the retired channel IDs `Ringer` and `label2` listed in `used_ids.channels`: names next to the reserved list are valid there too (experiment-v1 4.9). | +| [`v38_parent_labels_mask`](valid/v38_parent_labels_mask.toml) | Owner decision PL1 (supersedes AQ8; was `i111`) | pass | yes | A `parent_labels` mask `Mito` beside an `instances` mask `Cells`: each non-zero value of `Mito` is one group (the mitochondria of one cell) in any number of pieces; 0 is background. Not an object set (`A_MASK_NOT_INSTANCES`), never split or relabelled; as a region, a brick without `parent_labels_support` reads it as an area with the recorded marker `parent_labels_as_area` (conformance §4 "Parent labels"). No field names the grouping mask (experiment-v1 4.5b). | +| [`v39_parent_labels_only`](valid/v39_parent_labels_only.toml) | Owner decision PL1 | pass | yes | A `parent_labels` mask with no other mask in the file: the description never names the mask whose objects the values refer to; a consumer that reads a value as a parent's label names that parent in its own request (experiment-v1 4.5b). | +| [`v40_rgb_header_override`](valid/v40_rgb_header_override.toml) | Owner decision RH1 | pass | yes | The CTRL units declare `rgb_header_override = true` beside `image_type = "rgb"` (scanner files whose TIFF header says MINISBLACK with three interleaved samples); the DrugA units do not. The key changes no channel ID; whether a header is overridden is checked against the images (P36), never by this file. | ## Expected outputs (3) @@ -279,7 +294,7 @@ named valid file by the stated rules; `tools/audit/refval.py` compares them. | [`v33_condition_folder_on_forbidden_list.experiment_design.csv`](expected/v33_condition_folder_on_forbidden_list.experiment_design.csv) | `valid/v33` | `condition` holds the folder label `control`, never the ID `ctrl`; `DrugA` sorts before `control` (code point order). | | [`v34_technical_repeat_folder_on_forbidden_list.experiment_design.csv`](expected/v34_technical_repeat_folder_on_forbidden_list.experiment_design.csv) | `valid/v34` | Two technical repeats (folders `files`, `overrides`) give `technical_repeat_count` 2; `rep2` has only `single`, so 0. | -## Transition fixtures (13) +## Transition fixtures (15) Valid alone; checked against the named published predecessor (refused with the listed set, or accepted). @@ -298,8 +313,10 @@ Valid alone; checked against the named published predecessor (refused with the l | [`t11_technical_repeat_id_changed_same_folder`](transitions/t11_technical_repeat_id_changed_same_folder.toml) | `valid/v34` | R_CONFIRMED_ID_CHANGED (against predecessor valid/v34, without a recorded re-confirmation) | The folder `files` was confirmed as technical repeat `acq1` in v34 and now carries the ID `acqA` in both members. A confirmed technical repeat ID never changes in place (experiment-v1 4.6, 4.6a). `acq1` stays listed in used_ids. Valid alone. | | [`t12_condition_folder_reassigned`](transitions/t12_condition_folder_reassigned.toml) | `valid/v33` | R_CONFIRMED_ID_CHANGED (against predecessor valid/v33, without a recorded confirmation) | The ID `ctrl` held the folder `control` in v33 and now holds the folder `ctl` (a folder renamed on disk and attached to the same ID without a recorded confirmation). A folder change for an existing ID is a reassignment, so a changed entity (experiment-v1 4.6, 7). Valid alone. | | [`t13_confirmed_on_with_image_count_only`](transitions/t13_confirmed_on_with_image_count_only.toml) | `valid/v01` | `R_CONFIRMED_ON_CHANGED` (N35 not reopened) | Against v01 only CTRL/rep1 `image_count` (12 to 17, new FOVs) and rep1 `confirmed_on` (2026-11-07) change: new FOVs do not reopen the confirmation (experiment-v1 10), so the new date is refused. | +| [`t14_rgb_header_override_added`](transitions/t14_rgb_header_override_added.toml) | `valid/v28` | no R_* code: accepted (against predecessor valid/v28, N35 reopened) | Against v28 the CTRL units of rep1 and rep2 gain `rgb_header_override = true`. The key is part of the confirmed layout (experiment-v1 10, RH1 answer of 14 November 2026), so both repeats are reopened and re-confirmed on 2026-11-07: the changed `confirmed_on` is not R_CONFIRMED_ON_CHANGED. | +| [`t15_rgb_header_override_other_repeat_dated`](transitions/t15_rgb_header_override_other_repeat_dated.toml) | `valid/v28` | `R_CONFIRMED_ON_CHANGED` (rep2 not reopened) | Against v28 only rep1's CTRL unit gains `rgb_header_override = true` (rep1 reopened, re-confirmed on 2026-11-07); rep2's layout is unchanged, so its new `confirmed_on` (2026-11-07) is refused. | -## Invalid fixtures (135) +## Invalid fixtures (140) | Fixture | Source | Expected code(s) | Phase | Case | |---|---|---|---|---| @@ -413,7 +430,6 @@ Valid alone; checked against the named published predecessor (refused with the l | [`i108_channel_id_reserved_casefold`](invalid/i108_channel_id_reserved_casefold.toml) | Owner decision AQ4 | `E_ID_RESERVED` | 4 | Channel ID `T`: reserved names are compared case-folded, so `T` is the reserved `t`. | | [`i109_mask_id_reserved_column`](invalid/i109_mask_id_reserved_column.toml) | Owner decision AQ4 | `E_ID_RESERVED` | 4 | Mask ID `patch_id`, a MorphoRelate reserved column name: one reserved list for channel and mask IDs. | | [`i110_header_names_duplicate_after_nfc`](invalid/i110_header_names_duplicate_after_nfc.toml) | Owner decision AQ7 | `E_DUPLICATE_VALUE` | 5 | `header_names` = ["Caf\u00e9", "Cafe\u0301"]: header names are compared after NFC, so these are the same alias twice. | -| [`i111_mask_representation_parent_labels`](invalid/i111_mask_representation_parent_labels.toml) | Owner decision AQ8 | `E_ENUM` | 3 | `representation = "parent_labels"` (MorphoRelate's grouped masks): out of scope in v1. | | [`i112_mask_conversion_field_forbidden`](invalid/i112_mask_conversion_field_forbidden.toml) | Owner decision AQ9 | `E_FORBIDDEN_FIELD` | 3 | `binary_mask_policy = "connected_components"` in a mask table: a binary-to-instances conversion is a per-request, recorded choice of the analysis request, never part of the file. | | [`i113_forbidden_name_condition_key`](invalid/i113_forbidden_name_condition_key.toml) | Owner decision AQ13a | `E_FORBIDDEN_FIELD` | 3 | A condition ID `control`: forbidden names apply to ID keys as well as fields (reported at the condition and at its member keys). The folder `control` itself is describable under another ID (`v33`); only the key is refused. | | [`i114_forbidden_name_channel_key`](invalid/i114_forbidden_name_channel_key.toml) | Owner decision AQ13a | `E_FORBIDDEN_FIELD` | 3 | A channel ID `files`: a forbidden name used as a channel key. | @@ -438,6 +454,12 @@ Valid alone; checked against the named published predecessor (refused with the l | [`i133_condition_single_not_alone`](invalid/i133_condition_single_not_alone.toml) | Owner decision SQ6, matrix audit MS-1 | `E_SINGLE_MISUSE` | 4 | The condition `single` (no condition folder level) next to the condition DrugA: it must be the only condition (experiment-v1 3.2). | | [`i134_duplicate_key_inline_table`](invalid/i134_duplicate_key_inline_table.toml) | Stage 1 design PR 0, experiment-v1 2.2 | `E_DUPLICATE_KEY` | 1 | `display_name` written twice inside the inline table of the channel DNA: a key declared twice in any spelling, inline tables included, is `E_DUPLICATE_KEY`, not `E_TOML_SYNTAX` (experiment-v1 2.2). | | [`i135_used_id_channel_reserved`](invalid/i135_used_id_channel_reserved.toml) | Owner decision UR1 (Spec issue 11) | `E_ID_RESERVED` | 4 | The retired channel ID `Nucleus` in `used_ids.channels`: a listed ID reserves the ID, so it follows the reserved list of 3.2 (case-folded) like a declared channel ID (experiment-v1 4.9). | +| [`i136_representation_grouped`](invalid/i136_representation_grouped.toml) | Owner decision PL1 | `E_ENUM` | 3 | `representation = "grouped"`: `grouped` is the mask step's suggested kind (evidence), not a representation; the value is `parent_labels`. | +| [`i137_representation_parent_labels_case`](invalid/i137_representation_parent_labels_case.toml) | Owner decision PL1 | `E_ENUM` | 3 | `representation = "Parent_Labels"`: the enumeration is exact and lower case, never case-folded. | +| [`i138_mask_grouped_by_field`](invalid/i138_mask_grouped_by_field.toml) | Owner decision PL1 | `E_UNKNOWN_FIELD` | 3 | A `parent_labels` mask naming its grouping mask (`grouped_by = "Nuclei"`): v1 has no relationship field; the parent is named by the consumer's request (experiment-v1 4.5b). | +| [`i139_parent_labels_support_in_file`](invalid/i139_parent_labels_support_in_file.toml) | Owner decision PL1 | `E_UNKNOWN_FIELD` | 3 | `parent_labels_support = true` at the top level: support is a capability the receiving brick declares (experiment-v1 4.5b), never a statement of the description. | +| [`i140_rgb_override_without_rgb`](invalid/i140_rgb_override_without_rgb.toml) | Owner decision RH1 | `E_RGB_OVERRIDE_WITHOUT_RGB` | 5 | A unit without `image_type` declares `rgb_header_override = true`: the override exists only for units declared `rgb` (experiment-v1 4.4b). | +| [`i141_rgb_override_not_boolean`](invalid/i141_rgb_override_not_boolean.toml) | Owner decision RH1 | `E_TYPE` | 3 | `rgb_header_override = "true"`: a string is never read as a boolean. | ## Records fixtures (37) diff --git a/tests/spec_fixtures/fixtures/invalid/i136_representation_grouped.toml b/tests/spec_fixtures/fixtures/invalid/i136_representation_grouped.toml new file mode 100644 index 0000000..e9c9d77 --- /dev/null +++ b/tests/spec_fixtures/fixtures/invalid/i136_representation_grouped.toml @@ -0,0 +1,38 @@ +# Fixture i136_representation_grouped +# Expected: E_ENUM +# Source: Owner decision PL1 +# `representation = "grouped"`: `grouped` is the mask step's suggested kind (evidence), not a representation; the value is `parent_labels`. +schema = "morphobricks-experiment" +schema_version = 1 + +[conditions.CTRL] +source_folder = "CTRL" + +[channels.DNA] +display_name = "DAPI" + +[channels.RNA] +display_name = "SYTO 14" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-11" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 9 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["DNA", "RNA"] + +[masks.Nucleoli] +source_type = "nucleoli" +representation = "grouped" +source_channels = ["RNA"] + +[used_ids] +conditions = ["CTRL"] +channels = ["DNA", "RNA"] +repeats = ["rep1"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/invalid/i137_representation_parent_labels_case.toml b/tests/spec_fixtures/fixtures/invalid/i137_representation_parent_labels_case.toml new file mode 100644 index 0000000..31aeceb --- /dev/null +++ b/tests/spec_fixtures/fixtures/invalid/i137_representation_parent_labels_case.toml @@ -0,0 +1,37 @@ +# Fixture i137_representation_parent_labels_case +# Expected: E_ENUM +# Source: Owner decision PL1 +# `representation = "Parent_Labels"`: the enumeration is exact and lower case, never case-folded. +schema = "morphobricks-experiment" +schema_version = 1 + +[conditions.CTRL] +source_folder = "CTRL" + +[channels.DNA] +display_name = "DAPI" + +[channels.RNA] +display_name = "SYTO 14" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-11" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 9 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["DNA", "RNA"] + +[masks.Nucleoli] +source_type = "nucleoli" +representation = "Parent_Labels" + +[used_ids] +conditions = ["CTRL"] +channels = ["DNA", "RNA"] +repeats = ["rep1"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/invalid/i138_mask_grouped_by_field.toml b/tests/spec_fixtures/fixtures/invalid/i138_mask_grouped_by_field.toml new file mode 100644 index 0000000..584f675 --- /dev/null +++ b/tests/spec_fixtures/fixtures/invalid/i138_mask_grouped_by_field.toml @@ -0,0 +1,43 @@ +# Fixture i138_mask_grouped_by_field +# Expected: E_UNKNOWN_FIELD +# Source: Owner decision PL1 +# A `parent_labels` mask naming its grouping mask (`grouped_by = "Nuclei"`): v1 has no relationship field; the parent is named by the consumer's request (experiment-v1 4.5b). +schema = "morphobricks-experiment" +schema_version = 1 + +[conditions.CTRL] +source_folder = "CTRL" + +[channels.DNA] +display_name = "DAPI" + +[channels.RNA] +display_name = "SYTO 14" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-11" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 9 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["DNA", "RNA"] + +[masks.Nuclei] +source_type = "nuclei" +representation = "instances" +source_channels = ["DNA"] + +[masks.Nucleoli] +source_type = "nucleoli" +representation = "parent_labels" +grouped_by = "Nuclei" + +[used_ids] +conditions = ["CTRL"] +channels = ["DNA", "RNA"] +repeats = ["rep1"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/invalid/i139_parent_labels_support_in_file.toml b/tests/spec_fixtures/fixtures/invalid/i139_parent_labels_support_in_file.toml new file mode 100644 index 0000000..43e7f0b --- /dev/null +++ b/tests/spec_fixtures/fixtures/invalid/i139_parent_labels_support_in_file.toml @@ -0,0 +1,38 @@ +# Fixture i139_parent_labels_support_in_file +# Expected: E_UNKNOWN_FIELD +# Source: Owner decision PL1 +# `parent_labels_support = true` at the top level: support is a capability the receiving brick declares (experiment-v1 4.5b), never a statement of the description. +schema = "morphobricks-experiment" +schema_version = 1 +parent_labels_support = true + +[conditions.CTRL] +source_folder = "CTRL" + +[channels.DNA] +display_name = "DAPI" + +[channels.RNA] +display_name = "SYTO 14" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-11" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 9 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["DNA", "RNA"] + +[masks.Nucleoli] +source_type = "nucleoli" +representation = "parent_labels" + +[used_ids] +conditions = ["CTRL"] +channels = ["DNA", "RNA"] +repeats = ["rep1"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/invalid/i140_rgb_override_without_rgb.toml b/tests/spec_fixtures/fixtures/invalid/i140_rgb_override_without_rgb.toml new file mode 100644 index 0000000..6fcc841 --- /dev/null +++ b/tests/spec_fixtures/fixtures/invalid/i140_rgb_override_without_rgb.toml @@ -0,0 +1,69 @@ +# Fixture i140_rgb_override_without_rgb +# Expected: E_RGB_OVERRIDE_WITHOUT_RGB +# Source: Owner decision RH1 +# A unit of an ordinary channel image (no `image_type`) declares `rgb_header_override = true`: the override exists only for units declared `rgb`. +schema = "morphobricks-experiment" +schema_version = 1 + +[conditions.CTRL] +source_folder = "CTRL" +display_name = "Control" + +[conditions.DrugA] +source_folder = "DrugA" +display_name = "Drug A" +reference = "CTRL" + +[channels.DAPI] +display_name = "DAPI" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-06" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["DAPI"] +rgb_header_override = true + +[repeats.rep1.members.DrugA] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["DAPI"] + +[repeats.rep2] +confirmed = true +confirmed_on = "2026-11-06" + +[repeats.rep2.members.CTRL] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["DAPI"] + +[repeats.rep2.members.DrugA] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["DAPI"] + +[masks.Nuclei] +source_type = "nuclei" +representation = "instances" + +[used_ids] +conditions = ["CTRL", "DrugA"] +channels = ["DAPI"] +repeats = ["rep1", "rep2"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/invalid/i141_rgb_override_not_boolean.toml b/tests/spec_fixtures/fixtures/invalid/i141_rgb_override_not_boolean.toml new file mode 100644 index 0000000..b2a1721 --- /dev/null +++ b/tests/spec_fixtures/fixtures/invalid/i141_rgb_override_not_boolean.toml @@ -0,0 +1,79 @@ +# Fixture i141_rgb_override_not_boolean +# Expected: E_TYPE +# Source: Owner decision RH1 +# `rgb_header_override = "true"`: a string is never read as a boolean (no conversion). +schema = "morphobricks-experiment" +schema_version = 1 + +[conditions.CTRL] +source_folder = "CTRL" +display_name = "Control" + +[conditions.DrugA] +source_folder = "DrugA" +display_name = "Drug A" +reference = "CTRL" + +[channels.R] +display_name = "Red" + +[channels.G] +display_name = "Green" + +[channels.B] +display_name = "Blue" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-06" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" +rgb_header_override = "true" + +[repeats.rep1.members.DrugA] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[repeats.rep2] +confirmed = true +confirmed_on = "2026-11-06" + +[repeats.rep2.members.CTRL] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[repeats.rep2.members.DrugA] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[masks.Nuclei] +source_type = "nuclei" +representation = "instances" + +[used_ids] +conditions = ["CTRL", "DrugA"] +channels = ["B", "G", "R"] +repeats = ["rep1", "rep2"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/transitions/t14_rgb_header_override_added.toml b/tests/spec_fixtures/fixtures/transitions/t14_rgb_header_override_added.toml new file mode 100644 index 0000000..751e540 --- /dev/null +++ b/tests/spec_fixtures/fixtures/transitions/t14_rgb_header_override_added.toml @@ -0,0 +1,80 @@ +# Fixture t14_rgb_header_override_added +# Expected: no R_* code: accepted (against predecessor valid/v28, N35 reopened) +# Source: Owner decision RH1, answer of 14 November 2026 (an override change is a layout change) +# Against v28 the CTRL units of rep1 and rep2 gain rgb_header_override = true. The key is part of the unit's confirmed layout (experiment-v1 10), so the confirmation of both repeats is reopened and re-confirmed on 2026-11-07: the changed confirmed_on is not R_CONFIRMED_ON_CHANGED. +schema = "morphobricks-experiment" +schema_version = 1 + +[conditions.CTRL] +source_folder = "CTRL" +display_name = "Control" + +[conditions.DrugA] +source_folder = "DrugA" +display_name = "Drug A" +reference = "CTRL" + +[channels.R] +display_name = "Red" + +[channels.G] +display_name = "Green" + +[channels.B] +display_name = "Blue" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-07" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" +rgb_header_override = true + +[repeats.rep1.members.DrugA] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[repeats.rep2] +confirmed = true +confirmed_on = "2026-11-07" + +[repeats.rep2.members.CTRL] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" +rgb_header_override = true + +[repeats.rep2.members.DrugA] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[masks.Nuclei] +source_type = "nuclei" +representation = "instances" + +[used_ids] +conditions = ["CTRL", "DrugA"] +channels = ["B", "G", "R"] +repeats = ["rep1", "rep2"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/transitions/t15_rgb_header_override_other_repeat_dated.toml b/tests/spec_fixtures/fixtures/transitions/t15_rgb_header_override_other_repeat_dated.toml new file mode 100644 index 0000000..6760ade --- /dev/null +++ b/tests/spec_fixtures/fixtures/transitions/t15_rgb_header_override_other_repeat_dated.toml @@ -0,0 +1,79 @@ +# Fixture t15_rgb_header_override_other_repeat_dated +# Expected: R_CONFIRMED_ON_CHANGED (against predecessor valid/v28, rep2 not reopened) +# Source: Owner decision RH1, answer of 14 November 2026 +# Against v28 only the CTRL unit of rep1 gains rgb_header_override = true, which reopens rep1 (re-confirmed on 2026-11-07). rep2's layout is unchanged, so its new confirmed_on (2026-11-07) is refused. +schema = "morphobricks-experiment" +schema_version = 1 + +[conditions.CTRL] +source_folder = "CTRL" +display_name = "Control" + +[conditions.DrugA] +source_folder = "DrugA" +display_name = "Drug A" +reference = "CTRL" + +[channels.R] +display_name = "Red" + +[channels.G] +display_name = "Green" + +[channels.B] +display_name = "Blue" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-07" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" +rgb_header_override = true + +[repeats.rep1.members.DrugA] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[repeats.rep2] +confirmed = true +confirmed_on = "2026-11-07" + +[repeats.rep2.members.CTRL] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[repeats.rep2.members.DrugA] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[masks.Nuclei] +source_type = "nuclei" +representation = "instances" + +[used_ids] +conditions = ["CTRL", "DrugA"] +channels = ["B", "G", "R"] +repeats = ["rep1", "rep2"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/invalid/i111_mask_representation_parent_labels.toml b/tests/spec_fixtures/fixtures/valid/v38_parent_labels_mask.toml similarity index 56% rename from tests/spec_fixtures/fixtures/invalid/i111_mask_representation_parent_labels.toml rename to tests/spec_fixtures/fixtures/valid/v38_parent_labels_mask.toml index 9dab554..f9dd666 100644 --- a/tests/spec_fixtures/fixtures/invalid/i111_mask_representation_parent_labels.toml +++ b/tests/spec_fixtures/fixtures/valid/v38_parent_labels_mask.toml @@ -1,7 +1,7 @@ -# Fixture i111_mask_representation_parent_labels -# Expected: E_ENUM -# Source: Owner decision AQ8 -# `representation = "parent_labels"` (MorphoRelate's grouped masks): out of scope in v1. +# Fixture v38_parent_labels_mask +# Expected: PASS +# Source: Owner decision PL1 (supersedes AQ8; was invalid/i111) +# A `parent_labels` mask beside an `instances` mask: each non-zero value of `Mito` is one group (the mitochondria of one cell), in any number of pieces. No field names the grouping mask (experiment-v1 4.5b). schema = "morphobricks-experiment" schema_version = 1 @@ -21,6 +21,9 @@ header_names = ["DAPI"] [channels.ACTIN] display_name = "F-actin" +[channels.MITO] +display_name = "MitoTracker" + [repeats.rep1] confirmed = true confirmed_on = "2026-11-06" @@ -31,7 +34,7 @@ image_count = 12 [repeats.rep1.members.CTRL.technical_repeats.single] source_folder = "single" -channels = ["DNA", "ACTIN"] +channels = ["DNA", "ACTIN", "MITO"] [repeats.rep1.members.DrugA] source_repeat = "rep1" @@ -39,15 +42,20 @@ image_count = 10 [repeats.rep1.members.DrugA.technical_repeats.single] source_folder = "single" -channels = ["DNA", "ACTIN"] +channels = ["DNA", "ACTIN", "MITO"] + +[masks.Cells] +source_type = "cells" +representation = "instances" +source_channels = ["ACTIN"] -[masks.Nuclei] -source_type = "nuclei" +[masks.Mito] +source_type = "mito" representation = "parent_labels" -source_channels = ["DNA"] +source_channels = ["MITO"] [used_ids] conditions = ["CTRL", "DrugA"] -channels = ["ACTIN", "DNA"] +channels = ["ACTIN", "DNA", "MITO"] repeats = ["rep1"] technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/valid/v39_parent_labels_only.toml b/tests/spec_fixtures/fixtures/valid/v39_parent_labels_only.toml new file mode 100644 index 0000000..2ccb1c1 --- /dev/null +++ b/tests/spec_fixtures/fixtures/valid/v39_parent_labels_only.toml @@ -0,0 +1,39 @@ +# Fixture v39_parent_labels_only +# Expected: PASS +# Source: Owner decision PL1 +# A `parent_labels` mask with no other mask in the file: the description never names the mask whose objects the values refer to; a consumer that reads a value as a parent's label names that parent in its own request (experiment-v1 4.5b). +schema = "morphobricks-experiment" +schema_version = 1 + +[conditions.CTRL] +source_folder = "CTRL" + +[channels.DNA] +display_name = "DAPI" + +[channels.RNA] +display_name = "SYTO 14" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-11" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 9 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["DNA", "RNA"] + +[masks.Nucleoli] +source_type = "nucleoli" +representation = "parent_labels" +source_channels = ["RNA"] +display_name = "Nucleoli by nucleus" + +[used_ids] +conditions = ["CTRL"] +channels = ["DNA", "RNA"] +repeats = ["rep1"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/fixtures/valid/v40_rgb_header_override.toml b/tests/spec_fixtures/fixtures/valid/v40_rgb_header_override.toml new file mode 100644 index 0000000..f7bdc5d --- /dev/null +++ b/tests/spec_fixtures/fixtures/valid/v40_rgb_header_override.toml @@ -0,0 +1,80 @@ +# Fixture v40_rgb_header_override +# Expected: PASS +# Source: Owner decision RH1 +# The CTRL units declare `rgb_header_override = true` beside `image_type = "rgb"` (scanner files whose TIFF header says MINISBLACK with three interleaved samples); the DrugA units do not. Valid and homogeneous: the key changes no channel ID. Whether a header is overridden is checked against the images (P36), never by this file. +schema = "morphobricks-experiment" +schema_version = 1 + +[conditions.CTRL] +source_folder = "CTRL" +display_name = "Control" + +[conditions.DrugA] +source_folder = "DrugA" +display_name = "Drug A" +reference = "CTRL" + +[channels.R] +display_name = "Red" + +[channels.G] +display_name = "Green" + +[channels.B] +display_name = "Blue" + +[repeats.rep1] +confirmed = true +confirmed_on = "2026-11-06" + +[repeats.rep1.members.CTRL] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" +rgb_header_override = true + +[repeats.rep1.members.DrugA] +source_repeat = "rep1" +image_count = 8 + +[repeats.rep1.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[repeats.rep2] +confirmed = true +confirmed_on = "2026-11-06" + +[repeats.rep2.members.CTRL] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.CTRL.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" +rgb_header_override = true + +[repeats.rep2.members.DrugA] +source_repeat = "rep2" +image_count = 8 + +[repeats.rep2.members.DrugA.technical_repeats.single] +source_folder = "single" +channels = ["R", "G", "B"] +image_type = "rgb" + +[masks.Nuclei] +source_type = "nuclei" +representation = "instances" + +[used_ids] +conditions = ["CTRL", "DrugA"] +channels = ["B", "G", "R"] +repeats = ["rep1", "rep2"] +technical_repeats = ["single"] diff --git a/tests/spec_fixtures/tools/audit/refval.py b/tests/spec_fixtures/tools/audit/refval.py index 0ea8309..8fcb429 100644 --- a/tests/spec_fixtures/tools/audit/refval.py +++ b/tests/spec_fixtures/tools/audit/refval.py @@ -50,10 +50,10 @@ CHAN = ("display_name", "header_names") REP = ("display_name", "confirmed", "confirmed_on", "members") MEM = ("source_repeat", "image_count", "technical_repeats") -UNIT = ("source_folder", "display_name", "channels", "image_type") +UNIT = ("source_folder", "display_name", "channels", "image_type", "rgb_header_override") MASK = ("source_type", "representation", "source_channels", "display_name") USED = ("conditions", "channels", "repeats", "technical_repeats") -REPRESENTATIONS = ("instances", "binary") +REPRESENTATIONS = ("instances", "binary", "parent_labels") # parent_labels: owner decision PL1 class Report: @@ -270,6 +270,8 @@ def phase3(doc: dict, r: Report) -> None: r.e("E_TYPE", up + ".image_type", v) elif v != "rgb": r.e("E_ENUM", up + ".image_type", v) + if "rgb_header_override" in u and not isinstance(u["rgb_header_override"], bool): + r.e("E_TYPE", up + ".rgb_header_override", u["rgb_header_override"]) # RH1 for mid, mk in _id_table(doc, "masks", "", r, required=False, min1=False): p = kpath("masks", mid) _fields(mk, MASK, p, r) @@ -442,6 +444,8 @@ def phase5(doc: dict, r: Report) -> None: if ch in seen: r.e("E_DUPLICATE_CHANNEL_IN_UNIT", f"{up}.channels[{i}]", ch) seen.add(ch) + if "rgb_header_override" in u and u.get("image_type") != "rgb": + r.e("E_RGB_OVERRIDE_WITHOUT_RGB", up + ".rgb_header_override", u["rgb_header_override"]) # RH1 if u.get("image_type") == "rgb": if u["channels"] != ["R", "G", "B"]: r.e("E_RGB_UNIT_CHANNELS", up + ".channels", u["channels"])