Skip to content

radiens_qc.persist

Write a report to a folder and read it back.

The folder is output, not an interchange contract: nothing in this package reads a folder written by a different run. What it buys is a downstream reader re-plotting a recording without a server or a KPI recompute.

Layout of <out_dir>/<base_name>/:

===================== ========================================================= meta.json Provenance, thresholds, the cache key of the run that produced it, channel counts per integrity tier and event state, and per-metric summary stats. channels.csv One row per channel: geometry, per-metric whole-recording values, integrity tier, event state. matrices.npz The full (n_windows, n_channels) per-metric arrays, which is what lets a reloaded report draw its temporal figures without a server. ===================== =========================================================

Classes

Functions:

cached_key

cached_key(report_dir)

The cache key save_report recorded here, or None if there is none.

None for a directory that does not exist, holds no meta.json, or was written without a key -- all of which read as "cannot be reused".

load_report

load_report(report_dir, *, thresholds=None)

Load a report previously written by :func:save_report.

Parameters:

Name Type Description Default
report_dir Path

A report directory as written by :func:save_report.

required
thresholds QualityThresholds | None

Regrade the channel table against these instead of the ones the report was saved with. Classification is pure over the stored metrics, so this costs no server work -- which is why thresholds are not part of the cache key.

None

Returns:

Type Description
QualityReport

The reconstructed report.

save_report

save_report(report, out_dir, *, cache_key=None)

Persist report to <out_dir>/<report.base_name>/.

Data only. Figures are drawn from a report, not stored beside one, so nothing here renders.

Parameters:

Name Type Description Default
report QualityReport

Report to persist.

required
out_dir Path

Parent directory; one subdirectory per recording is created.

required
cache_key str | None

Digest of the pipeline run that produced report, recorded so a later call can tell whether it may reuse this directory instead of recomputing. None writes no key, which reads as a miss.

None

Returns:

Type Description
Path

The report's own directory.