Provenance
Every label image patchworks writes records how it was made: the
segmentation function and its bound settings, tiling, overlap, stitching,
level, channel, codec, the input, the library versions and a UTC timestamp.
It sits in the label group's attrs under "patchworks" (for write_to=
stores, on the labels array), so it travels with the data.
from patchworks import read_provenance
read_provenance("scan.zarr/labels/cilia_labels")["settings"]["custom"]
patchworks.read_provenance(store: Any, component: str | None = None) -> dict | None
The provenance record of a label group (or array), if it has one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
(str, Path, Group or Array)
|
A label group path such as |
required |
component
|
str
|
Array inside store to read instead (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
dict or None
|
The record written by :func: |
Source code in src/patchworks/_provenance.py
patchworks.provenance(**settings: Any) -> dict[str, Any]
A JSON-safe record of a run: versions, time, and its settings.
Anything not JSON-serialisable (a function, a path object) is stored as its string form, so the record can always be written as zarr attrs.
Examples:
>>> rec = provenance(tile_shape=(16, 1024, 1024), stitch="iou")
>>> rec["settings"]["stitch"], "patchworks" in rec["versions"]
('iou', True)