medh5
The MEDH5 format engine. A .medh5 file is one subject at one or more
timepoints, with every image, annotation, transform and curation record about
them, in one self-describing HDF5 container. This crate is the canonical
implementation of formats 1.0 and 1.1 (the specification, and 1.1 for the
optional clinical profile): the data model, HDF5 I/O, validation, chunked
access, compression, geometry and transforms, annotations, provenance,
integrity — and, for 1.1, clinical events on a subject clock, strict
prospective selection, and the task and cache contract training builds on.
It has two siblings, and all three read and write the same bytes:
- the Python package (
pip install medh5), a thin layer over this crate that adds the NumPy, PyTorch, MONAI and converter integrations; - the
medh5command line (medh5-cli), a native binary over this crate.
HDF5 and C-Blosc2 are built from source and linked statically (see
medh5-sys), so a dependent crate needs no HDF5 installation. For an MSVC
target, set CFLAGS_x86_64_pc_windows_msvc=-DNDEBUG (or the variable for your
target): without it HDF5 keeps its assertions, and medh5-sys stops the build.
Write and read a sample
use NdArray;
use ;
Where things are
| Module | Specification |
|---|---|
sample |
§2, §4, §14.4 — reading (Sample) and writing (SampleWriter, create, amend) |
geometry |
§3 — grids, affines, frames, multiscale |
annotations |
§5–§9 — the voxel and geometric encodings, headers, coverage |
transforms |
§10 — affine, displacement, B-spline and composite transforms |
labels |
§5 — label sets, hierarchies and ontology codes |
curation |
§11, §12 — identity, provenance, quality, timelines, splits, scrubbing |
integrity |
§13 — per-object digests and content_id |
storage |
§14 — codec profiles, chunking, the sampling index |
validate |
§15 — the validator and its diagnostic codes (codes) |
collection |
§2.2 — packing samples into a .medh5c shard |
dataset, sampling |
cohort manifests, splits, statistics; patch sampling |
conformance |
the conformance corpus third-party implementations run |
version |
1.1 §2 — which versions are read fully, read as a projection, or refused |
clinical |
1.1 §3–§10 — the clinical profile: records, columns, checks, selection, augmentation |
companion |
task-cache-1 — task manifests, source pins, preflight row views, feature caches |
Errors are one Error type whose diagnostic code, when it has one, is the
code the validator reports for the same defect (§15.2, 1.1 §11.2).