spacr.qc_quarantine¶
Reversible, auditable exclusion of merged fields from measurement.
Measurement discovers work by enumerating merged/*.npy. Quarantine
therefore needs no exclusion database: moving one array to the sibling
merged_quarantined/ folder removes it from the next run, while leaving
every mask stack untouched. A JSON ledger beside the moved array records
who made that decision, when, and which segmentation-QC flags prompted it.
The functions in this module deliberately have no Qt dependency. They are usable from the field browser, a notebook, or a headless audit script and can be tested without constructing an application.
Exceptions¶
A field could not be quarantined or restored without losing data. |
Functions¶
|
Return whether the sibling quarantine currently holds |
|
Return sorted field stems currently excluded from |
|
Return |
|
Move one merged array out of measurement and write its audit record. |
|
Return the audit sidecar path for one quarantined field. |
|
Locate a field in |
|
Move one quarantined array back to its sibling |
Module Contents¶
- exception spacr.qc_quarantine.QuarantineError[source]¶
Bases:
RuntimeErrorA field could not be quarantined or restored without losing data.
Initialize self. See help(type(self)) for accurate signature.
- spacr.qc_quarantine.is_quarantined(merged_dir: _PathValue, field: _PathValue) bool[source]¶
Return whether the sibling quarantine currently holds
field.- Parameters:
merged_dir – plate
mergeddirectory whose quarantine is checked.field – field stem, with an optional
.npysuffix, to locate.
- spacr.qc_quarantine.list_quarantined(merged_dir: _PathValue) List[str][source]¶
Return sorted field stems currently excluded from
merged/*.npy.- Parameters:
merged_dir – plate
mergeddirectory whose quarantine is listed.
- spacr.qc_quarantine.quarantine_dir_for(merged_dir: _PathValue) pathlib.Path[source]¶
Return
<plate>/merged_quarantinedfor<plate>/merged.- Parameters:
merged_dir – validated plate
mergeddirectory.
- spacr.qc_quarantine.quarantine_field(merged_dir: _PathValue, field: _PathValue, *, flags: Iterable[str] = (), who: str | None = None) pathlib.Path[source]¶
Move one merged array out of measurement and write its audit record.
- Parameters:
merged_dir – the plate’s
mergeddirectory.field – a
spacr.seg_qc.FieldQCfield stem (.npyis accepted too).flags – the QC flags that motivated this decision.
who – actor recorded in the ledger; defaults to the OS account.
- Returns:
the new
merged_quarantined/<field>.npypath.- Raises:
FileNotFoundError – when the merged array is already gone.
FileExistsError – rather than overwriting an existing quarantine.
If the sidecar cannot be written, the array is moved back before the exception is raised. An unaudited quarantine is never reported as a successful operation.
- spacr.qc_quarantine.quarantine_record_path(quarantine_dir: _PathValue, field: _PathValue) pathlib.Path[source]¶
Return the audit sidecar path for one quarantined field.
- Parameters:
quarantine_dir – plate
merged_quarantineddirectory.field – merged-field stem, with an optional
.npysuffix.
- spacr.qc_quarantine.resolve_field_path(merged_dir: _PathValue, field: _PathValue) pathlib.Path | None[source]¶
Locate a field in
mergedor its quarantine, active copy first.- Parameters:
merged_dir – plate
mergeddirectory to search first.field – field stem, with an optional
.npysuffix, to locate.
- spacr.qc_quarantine.restore_field(quarantine_dir: _PathValue, field: _PathValue, *, who: str | None = None) pathlib.Path[source]¶
Move one quarantined array back to its sibling
mergedfolder.- Parameters:
quarantine_dir – plate
merged_quarantineddirectory.field – field stem, with an optional
.npysuffix, to restore.
The sidecar remains in
merged_quarantinedas the plate’s audit trail and gains a restoration event. As with quarantine, a ledger-write failure rolls the file move back.