API index¶
Every public name of the Python package, one table per module: what it is, the
first sentence of its docstring, and the section of these pages that documents
it. A name exported by more than one module is listed under each. The full
signatures are in the docstrings (help(name)), and medh5._core is the
compiled extension the modules re-export from, not an API of its own.
medh5¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
__format_version__ |
constant (str) |
||
__version__ |
constant (str) |
medh5 › Versioning | |
Activity |
class | One activity of the provenance graph: what an agent did, with its inputs and outputs (§11.1). | Curation records › Editing a record |
Agent |
class | An agent of the provenance graph: a person, software or organization that acts (§11.1). | |
Agreement |
class | One agreement measurement of a quality record, such as a Dice against another rater (§11.2). | Curation records › Agreement |
amend |
function | Copy-on-write amend: build a new file from the old and replace it. | Python API › Amending |
Annotation |
class | What every annotation answers, whatever its kind. | Python API › Timepoints |
audit_splits |
function | Read every file's claims and cross-check them (spec §12.3). | Curation records › Split claims |
CODES |
constant (dict) |
Every diagnostic code, keyed by code string. | Python API › Validation |
Cohort |
class | The cohort member of the sample document: dataset, site, scanner and split group (§12.2). |
Curation records › Editing a record |
Collection |
class | A read-only mapping of sample_key -> Sample over one shard. |
Python API › Opening |
compare_annotations |
function | Compare two annotations, choosing the comparison their kinds support. | Curation records › Agreement |
create |
function | Create a new sample; use as a context manager, or call commit(). |
Annotation kinds › Closure |
Deidentification |
class | The deidentification member: how identifiers were removed from the sample (§11.4). |
Curation records › Editing a record |
FeatureCache |
class | An open cache. | Python API › Tasks and caches |
FORMAT_VERSION |
constant (str) |
medh5 › Versioning | |
Grid |
class | The lattice of a stored array: its shape, axes and index-to-world geometry (§3.2). | Annotation kinds › Boxes |
grid_patches |
function | Deterministic sliding-window cover of a volume — the inference path. | PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
Identity |
class | The identity member of the sample document: who and what the sample is about (§12.1). |
Python API › Identity and structure |
Image |
class | Lazy access to one image and its geometry. | Python API › Timepoints |
Instance |
class | One physical object: a box, a class, an id and optionally a cropped mask. | |
Issue |
class | A known defect recorded in a quality record: its code, severity, classes and note (§11.2). | Curation records › Quality |
LabelClass |
class | One semantic class (§5.2). | Annotation kinds › Closure |
LabelSet |
class | A controlled vocabulary (§5.1). | Annotation kinds › Label sets |
MEDH5Error |
exception | Base of the package's own exceptions: a file, version, schema, validation or integrity error. | Python API › Exceptions |
MEDH5FileError |
exception | A file cannot be opened, is not HDF5, or is structurally unreadable. | Python API › Amending |
MEDH5FileNotFoundError |
exception | The file does not exist. | Python API › Exceptions |
MEDH5IntegrityError |
exception | A digest or content_id does not match the data it covers. |
|
MEDH5IOError |
exception | A read or write the engine could not complete: HDF5 failing a damaged chunk, say. | Python API › Exceptions |
MEDH5IsADirectoryError |
exception | The path names a directory, not a file. | Python API › Exceptions |
MEDH5PermissionError |
exception | The file exists but may not be read (or written). | Python API › Exceptions |
MEDH5SchemaError |
exception | The sample document is absent, is not JSON, or violates its JSON Schema. | |
MEDH5ValidationError |
exception | Input rejected by a writer, or a validation failure raised as an exception. | Python API › Opening |
MEDH5VersionError |
exception | The file's medh5_version is one this operation cannot work with. |
Python API › Amending |
Observation |
class | One object seen once: a row of one annotation. | Python API › Tracking |
open |
function | Open a .medh5 sample file, read-only. |
Python API › Opening |
open_collection |
function | Open a .medh5c shard, read-only. |
Python API › Opening |
open_sample |
function | Open a .medh5 sample file, read-only. |
Python API › Opening |
pack |
function | Copy sample files into one collection shard (spec §2.2). | Python API › Collections |
Patch |
class | One draw: where to read, and how the location was chosen. | Python API › Sampling patches |
PatchSampler |
class | Choose patch windows in a volume (spec §14.3). | Python API › Sampling patches |
PROFILES |
constant (tuple) |
Profiles and validation levels › Profiles — what to hold the file to | |
Provenance |
class | Who did what (§11.1): agents and the activities they performed. | Curation records › Provenance |
QualityRecord |
class | What is known about an annotation's trustworthiness: status, confidence, agreement, issues (§11.2). | |
Sample |
class | A read-only view of one sample root (a file, or a collection member). | Python API › Sample |
SampleDocument |
class | The whole document, typed. | Python API › Identity and structure |
SampleWriter |
class | Builder for one sample. | Python API › Writing |
SplitAudit |
class | What a cohort's split claims say, and where they disagree. | |
SplitClaim |
class | One entry of splits: a claim that the sample belongs to a partition of a split set (§12.3). |
Build and split a cohort › What the digest covers |
TaskManifest |
class | A medh5.task/1 manifest: build it, check it, save it, preflight it. |
Python API › Tasks and caches |
Timeline |
class | The sample's timepoints, in acquisition order; indexable by position or id. | Python API › Timepoints |
Timepoint |
class | One timepoint of the sample: an observation occasion, in DICOM terms usually one study (§3.7). | Curation records › Editing a record |
TimepointPair |
class | One ordered pair of visits, and the change label spanning it, if any. | |
TimepointPairSampler |
class | Enumerate the visit pairs a longitudinal model trains on (§3.7, §9). | PyTorch and MONAI › PairedPatchDataset — the same place at two visits |
Track |
class | Every observation of one physical object, ordered by timepoint. | Curation records › Tracking |
Tracking |
class | {instance_id: Track} with the coverage needed to tell resolved from unexamined, and the reason for every absence. |
Curation records › Tracking |
unpack |
function | Extract sample roots back into standalone files (spec §2.2). | Python API › Collections |
validate_cache |
function | Validate a cache: its checksums, every source pin, and — given a task — that it was built for this task, fitted on this task's training partition, and (check_rows) that each row's entry was built at its cutoff, from versions it admits, of its own subject's sources. |
Python API › Tasks and caches |
VoxelAnnotation |
class | The uniform read contract of the five voxel encodings (spec §7). |
medh5.annotations¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Annotation |
class | What every annotation answers, whatever its kind. | Python API › Timepoints |
ANNOTATION_KINDS |
constant (tuple) |
||
AnnotationHeader |
class | The fixed attribute header every annotation carries (spec §6.2). | |
AnnotationPayload |
class | Datasets and kind-specific attributes for one encoded annotation. | |
Assertion |
class | One label assertion: a class, its value, and what it is about. | Classification and change labels › Hierarchical labels |
BoxesAnnotation |
class | Axis-aligned boxes, (N, S, 2) [lo, hi] at voxel edges (§8.2). |
|
ClassificationAnnotation |
class | Reader for kind = "classification". |
|
ContoursAnnotation |
class | Planar polygons with an offset table (§8.6) — RTSTRUCT-shaped. | |
encode_boxes |
function | Pack axis-aligned boxes, (N, S, 2) in [lo, hi] at voxel edges, as a boxes payload (§8.2). |
|
encode_classification |
function | Pack label assertions as a classification payload over one scope (§9). |
|
encode_contours |
function | Concatenate planar polygons into a contours payload with an offset table (§8.6). |
|
encode_keypoints |
function | Pack (N, K, S) keypoints of N objects as a keypoints payload (§8.4). |
|
encode_mesh |
function | Pack a triangle surface mesh, (V, 3) vertices and (F, 3) faces, as a mesh payload (§8.7). |
|
encode_obb |
function | Pack oriented boxes as centres, full edge lengths and rotation matrices, an obb payload (§8.3). |
|
encode_points |
function | Pack an (N, S) point set — landmarks or seeds — as a points payload (§8.5). |
|
encode_voxels |
function | Encode class masks, choosing the encoding by measurement when asked to. | |
GEOMETRIC_KINDS |
constant (tuple) |
||
GeometricAnnotation |
class | Base for the §8 kinds: N objects whose coordinates live in one space. | |
Instance |
class | One physical object: a box, a class, an id and optionally a cropped mask. | |
KeypointsAnnotation |
class | (N, K, S) keypoints with per-slot classes and visibility (§8.4). |
|
MeshAnnotation |
class | A triangle surface mesh, optionally several submeshes (§8.7). | |
ObbAnnotation |
class | Oriented boxes: centre, full edge lengths, rotation (§8.3). | |
open_annotation |
function | The reader class for an annotation handle's kind. |
|
PointsAnnotation |
class | A point set: landmarks, seeds, or half a correspondence (§8.5). | |
Polygon |
class | One planar polygon handed to encode_contours. |
Annotation kinds › Contours |
READERS |
constant (dict) |
kind -> reader class, for every kind. |
|
RESERVED_KINDS |
constant (tuple) |
Kinds a 1.0 writer must not write (spec §16). | |
SCOPES |
constant (tuple) |
||
select_encoding |
function | Choose an encoding by measurement: (kind, stats). |
|
SPACES |
constant (tuple) |
||
TASKS |
constant (tuple) |
||
transcode |
function | Convert an open voxel annotation to another encoding (§7.6). | Annotation kinds › Transcoding |
VOXEL_KINDS |
constant (tuple) |
||
VoxelAnnotation |
class | The uniform read contract of the five voxel encodings (spec §7). |
medh5.annotations.base¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Annotation |
class | What every annotation answers, whatever its kind. | Python API › Timepoints |
ANNOTATION_KINDS |
constant (tuple) |
||
AnnotationHeader |
class | The fixed attribute header every annotation carries (spec §6.2). | |
AnnotationPayload |
class | Datasets and kind-specific attributes for one encoded annotation. | |
DEFAULT_TASK_FOR_KIND |
constant (dict) |
||
GEOMETRIC_KINDS |
constant (tuple) |
||
Instance |
class | One physical object: a box, a class, an id and optionally a cropped mask. | |
instance_id_dtype |
function | uint32 unless an id needs the wider form (spec §7.4, §8.2). |
|
RESERVED_KINDS |
constant (tuple) |
Kinds a 1.0 writer must not write (spec §16). | |
SPEC_ANNOTATION_ATTRS |
constant (tuple) |
||
TASKS |
constant (tuple) |
||
VOXEL_KINDS |
constant (tuple) |
||
VoxelAnnotation |
class | The uniform read contract of the five voxel encodings (spec §7). |
medh5.annotations.classification¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Assertion |
class | One label assertion: a class, its value, and what it is about. | Classification and change labels › Hierarchical labels |
assertion_rows |
function | (classes, values, scope_ids, schemes, scheme_values) from a mapping or assertion rows (§9). |
|
check_scope |
function | Return scope if it is a classification scope, else raise E412 (§9). |
|
ClassificationAnnotation |
class | Reader for kind = "classification". |
|
encode_classification |
function | Pack label assertions as a classification payload over one scope (§9). |
|
Labels |
type | What a classification is built from: class -> value, or assertion rows. |
|
SCOPES |
constant (tuple) |
medh5.annotations.geometric¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
BoxesAnnotation |
class | Axis-aligned boxes, (N, S, 2) [lo, hi] at voxel edges (§8.2). |
|
check_slice_index |
function | Return what is wrong with a slice_index column of one plane per box, or None (§8.2). |
|
check_space |
function | Return space if it is index or world, else raise E412 (§8.1). |
|
CONTOUR_ROLES |
constant (tuple) |
||
ContoursAnnotation |
class | Planar polygons with an offset table (§8.6) — RTSTRUCT-shaped. | |
encode_boxes |
function | Pack axis-aligned boxes, (N, S, 2) in [lo, hi] at voxel edges, as a boxes payload (§8.2). |
|
encode_contours |
function | Concatenate planar polygons into a contours payload with an offset table (§8.6). |
|
encode_keypoints |
function | Pack (N, K, S) keypoints of N objects as a keypoints payload (§8.4). |
|
encode_mesh |
function | Pack a triangle surface mesh, (V, 3) vertices and (F, 3) faces, as a mesh payload (§8.7). |
|
encode_obb |
function | Pack oriented boxes as centres, full edge lengths and rotation matrices, an obb payload (§8.3). |
|
encode_points |
function | Pack an (N, S) point set — landmarks or seeds — as a points payload (§8.5). |
|
GEOMETRIC_READERS |
constant (dict) |
||
GeometricAnnotation |
class | Base for the §8 kinds: N objects whose coordinates live in one space. | |
KeypointsAnnotation |
class | (N, K, S) keypoints with per-slot classes and visibility (§8.4). |
|
MeshAnnotation |
class | A triangle surface mesh, optionally several submeshes (§8.7). | |
ObbAnnotation |
class | Oriented boxes: centre, full edge lengths, rotation (§8.3). | |
PointsAnnotation |
class | A point set: landmarks, seeds, or half a correspondence (§8.5). | |
Polygon |
class | One planar polygon handed to encode_contours. |
Annotation kinds › Contours |
ROTATION_TOL |
constant (float) |
||
SPACES |
constant (tuple) |
||
VISIBILITY |
constant (dict) |
medh5.annotations.voxel¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
analyse |
function | Measure a set of class masks: counts, the overlap graph, a colouring and localization (§7.6). | |
annotation_to_masks |
function | Every class of a voxel annotation as a full mask. | |
AnnotationPayload |
class | Datasets and kind-specific attributes for one encoded annotation. | |
BitmaskAnnotation |
class | Classes as bits of uint64 planes; position from bit_class_ids (§7.3). |
|
BITS_PER_PLANE |
constant (int) |
||
check_roundtrip |
function | Whether transcoding a payload to to_kind keeps every class mask and its ignore region (§7.6). |
Annotation kinds › Transcoding |
checked_class_id |
function | A class id in the writable range 1..65534, or a coded refusal: E303 for a reserved id (0 or 65535), E306 for any other outside the range. |
|
contains_at |
function | values >= threshold, decided in the stored precision (§7.5). |
|
cost_model |
function | Return the raw, uncompressed bytes each voxel encoding would take for the analysed masks. | |
CostModel |
class | Raw (pre-compression) bytes per encoding. | |
DEFAULT_THRESHOLD |
constant (float) |
||
encode_bitmask |
function | Pack class masks into uint64 bitplanes, one bit per class, as a bitmask payload (§7.3). |
|
encode_instances |
function | Pack objects into boxes, ids and bit-packed crops (spec §7.4). | |
encode_labelmap |
function | Pack mutually exclusive class masks into one integer volume (§7.1). | |
encode_layers |
function | Colour the overlap graph and pack each colour into one labelmap (§7.2); ignore and ignore_id are checked and painted as encode_labelmap does. |
|
encode_mask |
function | Wrap one boolean volume as a mask payload. |
Annotation kinds › Transcoding |
encode_masks |
function | Encode class masks into the voxel encoding kind and return the payload. |
|
encode_probmap |
function | Pack per-class probability planes (spec §7.5). | |
encode_voxels |
function | Encode class masks, choosing the encoding by measurement when asked to. | |
greedy_colour |
function | Colour an overlap graph greedily, highest degree first: a dict of class id to layer (§7.6). | |
IN_BAND_IGNORE_KINDS |
constant (tuple) |
||
Instance |
class | One physical object: a box, a class, an id and optionally a cropped mask. | |
InstanceInput |
class | One object handed to encode_instances. |
Longitudinal studies › Join the objects |
instances_from_masks |
function | One object per class mask, minting ids from start_id; an id past the largest uint64 is refused (E404). |
|
InstancesAnnotation |
class | Objects: each a class, a sample-scoped id, a box and maybe a mask (§7.4). | |
label_dtype_size |
function | Return the bytes per voxel of a labelmap for these class ids: 1 (uint8) or 2 (uint16). |
|
LabelmapAnnotation |
class | Mutually exclusive classes in one volume; 65535 marks ignore (§7.1). |
|
layers_from_colouring |
function | Group a colouring of class id to layer into one tuple of class ids per layer, ascending. | |
LayersAnnotation |
class | Classes coloured onto layers so no two that overlap share one (§7.2). | |
LOCALIZED_BBOX_FRACTION |
constant (float) |
||
MaskAnnotation |
class | A region, not a class: what a field of view or an ignore mask is (§7.7). | |
Masks |
type | class id -> boolean occupancy over the grid's spatial shape. | |
masks_equal |
function | Whether two mask dicts hold the same classes with identical masks: the losslessness check. | |
normalize_masks |
function | Coerce a mask mapping to bool arrays of one agreed shape. |
|
OverlapStats |
class | Measured properties of a set of class masks, and what they imply (§7.6). | Segmentation › Write the masks |
payload_to_masks |
function | Decode any voxel payload into a dict of class id to boolean mask. | |
ProbmapAnnotation |
class | Soft labels; a voxel contains a class at or above threshold (§7.5). |
|
READERS |
constant (dict) |
kind -> reader class, for the voxel kinds. |
|
select_encoding |
function | Choose an encoding by measurement: (kind, stats). |
|
SLAB_BYTES |
constant (int) |
Read budget for a scan that only needs a yes/no or a count. | |
SPARSE_FILL |
constant (float) |
||
storage_dtype |
function | The narrowest of float16/float32 that keeps every voxel's containment decision (§7.5); E411 when neither does — a value within float32 rounding of the threshold, on its other side. |
|
STORAGE_DTYPES |
constant (tuple) |
||
TRANSCODABLE |
constant (tuple) |
Python API › Annotations | |
transcode |
function | Convert an open voxel annotation to another encoding (§7.6). | Annotation kinds › Transcoding |
transcode_payload |
function | Re-encode a payload; the same payload comes back when it already has to_kind. |
Annotation kinds › Transcoding |
medh5.bench¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
benchmark_file |
function | Every targeted metric on one file but the many-class draw, an image patch read, and the paired read when the file is longitudinal. | |
many_class_measurement |
function | The foreground draw on a many-class sample: O(1) whatever the classes. | |
MANY_CLASSES |
constant (int) |
||
Measurement |
class | One timed metric, and whether it met its target. | |
report |
function | The text table the medh5 bench command prints. |
Python API › Validation |
synthetic_many_class_sample |
function | A sample with classes small classes, for the many-class draw. | |
synthetic_pair |
function | A two-timepoint sample with a registration, for the paired metrics. | |
synthetic_sample |
function | Write a sample shaped like the one the published numbers were measured on: a CT, classes overlapping organs, a sampling index. |
Profiles and validation levels › Levels — how much to check |
TARGETS |
constant (dict) |
Metric -> (upper bound in ms, description): the performance guide's targets. | |
throughput |
function | Sustained patches/s through the real dataloader. | |
timed |
function | Median milliseconds per call. |
medh5.cache¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
build_document_cache |
function | An event-level cache of every document event of the task's sources. | Python API › Tasks and caches |
CacheEntry |
class | One cached feature and everything it depends on. | |
CacheReport |
class | What validating a cache found. | Python API › Tasks and caches |
CacheWriter |
class | Write a cache; it appears at path only on commit. |
Python API › Tasks and caches |
event_entry_id |
function | The entry id of an event-level feature of (content_id, event_id). |
|
FeatureCache |
class | An open cache. | Python API › Tasks and caches |
fitted_on |
function | The fitted_on record for learned preprocessing over partition (default: the task's training partition — the split's first). |
Python API › Tasks and caches |
fitted_on_mismatches |
function | Why preprocessing recorded as fitted was not fitted on task's training partition (T405): another task, split (set_id), membership or partition. |
Python API › Tasks and caches |
HashingTextEncoder |
class | Signed feature hashing of lower-cased words into dim floats. |
Python API › Tasks and caches |
LEVELS |
constant (tuple) |
||
open_cache |
function | Open a cache file, read-only. | |
SCHEMA |
constant (str) |
||
schema_text |
function | The medh5.cache/1 manifest JSON Schema. |
Cache manifest schema |
SUFFIX |
constant (str) |
||
validate_cache |
function | Validate a cache: its checksums, every source pin, and — given a task — that it was built for this task, fitted on this task's training partition, and (check_rows) that each row's entry was built at its cutoff, from versions it admits, of its own subject's sources. |
Python API › Tasks and caches |
medh5.cli¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
command_tree |
function | The grammar as data: {"options", "positionals", "commands"}, recursively — what documentation is checked against. |
|
EXIT_ERROR |
constant (int) |
||
EXIT_OK |
constant (int) |
||
EXIT_USAGE |
constant (int) |
||
main |
function | Run medh5 on argv (sys.argv[1:] by default); the exit code. |
medh5.clinical¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
ASSESSMENT_SYSTEM |
constant (str) |
||
augment |
function | Add clinical records to a sample, in place or into out (1.1 §10). |
Python API › Clinical history (format 1.1) |
baseline_day_clock |
function | The clock imaging_events_from_timepoints measures on. |
Clinical history beside the images › Add a history to a 1.0 file |
Bounds |
type | Inclusive (lo, hi) bounds on one instant, in clock microseconds. |
|
Clinical |
class | One sample's clinical profile, read: Sample.clinical. |
Python API › Clinical history (format 1.1) |
ClinicalRecords |
class | A logical-record bundle: what augment adds and records() reads. |
Python API › Clinical history (format 1.1) |
Clock |
class | The subject clock every clinical time is measured on (1.1 §3). | Python API › Clinical history (format 1.1) |
clock_day |
function | The clock day holding t_us: its midnight to the last microsecond before the next, counted from the clock's zero (the engine's Bounds::day_containing). |
Python API › Clinical history (format 1.1) |
CLOCK_REFERENCES |
constant (tuple) |
||
COMPARATORS |
constant (tuple) |
PyTorch and MONAI › Clinical tasks (format 1.1) | |
DAY |
constant (int) |
Train on clinical tasks › Describe the task | |
day_bounds |
function | Every instant of a calendar day on a utc clock, inclusive. |
Python API › Clinical history (format 1.1) |
days |
function | value days, in clock microseconds, rounded half to even, as the engine rounds a visit's days_from_baseline. |
Clinical history beside the images › Write a history |
Document |
class | Canonical, de-identified source text (1.1 §6). | Python API › Document |
DocumentInfo |
class | A document's metadata; its text is read when asked for. | Python API › Clinical history (format 1.1) |
ENDPOINT_TYPES |
constant (tuple) |
||
Event |
class | One immutable version of information about the subject (1.1 §5). | Python API › Clinical history (format 1.1) |
EVENT_KINDS |
constant (tuple) |
||
HOUR |
constant (int) |
Python API › Clinical history (format 1.1) | |
hours |
function | value hours, in clock microseconds, rounded half to even — as the engine rounds medh5 clinical select --cutoff-hours and every time given in hours, so a cutoff is one instant from every frontend. |
|
imaging_events_from_timepoints |
function | imaging events from days_from_baseline, known to the day. |
Python API › Clinical history (format 1.1) |
LESION_PRESENCE |
constant (str) |
||
LESION_VALUES |
constant (tuple) |
||
Link |
class | A typed relationship between sample-relative objects (1.1 §7). | Python API › Clinical history (format 1.1) |
MICROSECOND |
constant (int) |
||
MINUTE |
constant (int) |
From clinical history to a training batch › Write two subjects | |
PROFILE |
constant (str) |
||
records_from |
function | A bundle from lists. | |
RELATIONS |
constant (tuple) |
||
SCHEMA |
constant (str) |
||
schema_text |
function | The clinical descriptor and logical-record JSON Schema. | Clinical schema |
SECOND |
constant (int) |
||
select |
function | Select at cutoff_us from records not read from a file. |
Python API › Clinical history (format 1.1) |
SelectedEvent |
class | One event version a selection admits, in input order. | |
Selection |
class | What a cutoff admits (1.1 §9). | Python API › Clinical history (format 1.1) |
SELECTION_POLICIES |
constant (tuple) |
||
SelectionPolicy |
class | How inputs are chosen at a cutoff (task-and-cache contract §3.4). | Python API › Clinical history (format 1.1) |
STATUSES |
constant (tuple) |
||
strip |
function | Write the imaging projection of path to out: a different sample, and a reported loss. |
Python API › Clinical history (format 1.1) |
TEMPORAL_TYPES |
constant (tuple) |
||
utc_us |
function | An aware datetime on a utc clock: microseconds since 1970-01-01T00:00:00Z. |
Python API › Clinical history (format 1.1) |
medh5.collection¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Collection |
class | A read-only mapping of sample_key -> Sample over one shard. |
Python API › Opening |
default_key |
function | The sample key a file gets when none is supplied: its name up to its first dot (medh5 3.0 takes the stem, the name less its last suffix). | |
extract |
function | Extract one member of a collection into a standalone sample file. | Pack small samples into collections › Pack and unpack |
is_collection |
function | Whether a root declares itself a collection. | |
open_any |
function | Open a file whatever its kind, resolving key inside a collection. | Python API › Opening |
open_collection |
function | Open a .medh5c shard, read-only. |
Python API › Opening |
pack |
function | Copy sample files into one collection shard (spec §2.2). | Python API › Collections |
SAMPLES_GROUP |
constant (str) |
Where sample roots live inside a collection (spec §2.2). | |
SUFFIX |
constant (str) |
Conventional extension for a collection file (spec §2.1). | |
unpack |
function | Extract sample roots back into standalone files (spec §2.2). | Python API › Collections |
medh5.conformance¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
build_corpus |
function | Write every case (or those names) and an expected.json beside them; returns the manifest's path. |
|
Case |
class | One corpus entry. | Migrate from 0.x › 3. Read the report |
case_by_name |
function | The conformance case called name; a KeyError names an unknown one. |
|
CaseResult |
class | What running one case produced. | |
CASES |
constant (tuple) |
||
check_checksums |
function | Files whose checksum does not match SHA256SUMS (empty when intact). |
Run the conformance suite › Score it |
CHECKSUMS |
constant (str) |
||
load_manifest |
function | The suite's expected.json. |
Run the conformance suite › Publish a suite |
publish |
function | Write the whole suite into outdir — the cases, expected.json, the code table, the JSON Schemas (the sample document, the clinical profile, the task and cache contract), the task-and-cache fixtures under companion/ when the clinical cases they read are among the cases, a checksum file and instructions, everything a third-party implementation needs; returns outdir. |
Run the conformance suite › Publish a suite |
run_corpus |
function | Build the corpus into outdir and check this validator against it. | |
SCHEMA |
constant (str) |
||
score |
function | Score a foreign validator's results against the published expectations. | Annotation kinds › Classification |
score_companion |
function | Score another implementation of the task-and-cache contract against the fixtures under companion/ of a published suite. |
Run the conformance suite › Score a task-and-cache implementation |
SEED |
constant (int) |
||
summarize |
function | The --json summary of a run or a score. |
Run the conformance suite › Score it |
medh5.curation¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Activity |
class | One activity of the provenance graph: what an agent did, with its inputs and outputs (§11.1). | Curation records › Editing a record |
ACTIVITY_FIELDS |
constant (frozenset) |
||
ACTIVITY_TYPES |
constant (tuple) |
||
Agent |
class | An agent of the provenance graph: a person, software or organization that acts (§11.1). | |
AGENT_FIELDS |
constant (frozenset) |
||
AGENT_TYPES |
constant (tuple) |
||
Agreement |
class | One agreement measurement of a quality record, such as a Dice against another rater (§11.2). | Curation records › Agreement |
audit_splits |
function | Read every file's claims and cross-check them (spec §12.3). | Curation records › Split claims |
build_tracks |
function | Join instance_id across a sample's timepoints (Sample.tracks). |
|
carries_instance_ids |
function | Whether an annotation carries object identity (instance_ids) to join on. |
|
check_timestamp |
function | Return value if it is an RFC 3339 timestamp, else raise E604 (§11.1). |
|
Cohort |
class | The cohort member of the sample document: dataset, site, scanner and split group (§12.2). |
Curation records › Editing a record |
compare |
function | Compare two annotations, choosing the comparison their kinds support. | Curation records › Agreement |
compare_instances |
function | Object-level agreement between two instance-carrying annotations. | Curation records › Agreement |
compare_voxel |
function | Per-class Dice or IoU between two voxel annotations on the same grid. | Curation records › Two vocabularies |
DATE_PATTERN |
constant (Pattern) |
An ISO-8601 calendar date prefix, as date must start (the engine's). |
|
Deidentification |
class | The deidentification member: how identifiers were removed from the sample (§11.4). |
Curation records › Editing a record |
dice_agreement |
function | Return a mean-Dice Agreement from a mapping of class id to that class's Dice (§11.2). |
|
ID_SOURCE |
constant (str) |
||
Identity |
class | The identity member of the sample document: who and what the sample is about (§12.1). |
Python API › Identity and structure |
InstanceAgreement |
class | Object-level agreement: what matched, what did not, and how. | |
Issue |
class | A known defect recorded in a quality record: its code, severity, classes and note (§11.2). | Curation records › Quality |
ISSUE_SEVERITY |
constant (tuple) |
||
LATERALITY_VALUES |
constant (tuple) |
||
Observation |
class | One object seen once: a row of one annotation. | Python API › Tracking |
PARTITIONS |
constant (tuple) |
||
PRESENT |
constant (str) |
||
Provenance |
class | Who did what (§11.1): agents and the activities they performed. | Curation records › Provenance |
PSEUDONYM_SOURCE |
constant (str) |
||
QUALITY_FIELDS |
constant (frozenset) |
||
quality_from_json |
function | Parse the quality member of a sample document into a dict of key to QualityRecord (§11.2). |
|
QUALITY_STATUS |
constant (tuple) |
||
quality_to_json |
function | Serialize a mapping of key to QualityRecord (or its JSON form) as the quality member (§11.2). |
|
QualityRecord |
class | What is known about an annotation's trustworthiness: status, confidence, agreement, issues (§11.2). | |
REASONS |
constant (tuple) |
Why an unseen object is or is not a finding (§7.4), in precedence order. | Curation records › Tracking |
RESOLVED |
constant (str) |
||
RFC3339 |
constant (Pattern) |
The timestamp form §11.1 requires; check_timestamp is the rule. |
|
SEX_VALUES |
constant (tuple) |
||
SplitAudit |
class | What a cohort's split claims say, and where they disagree. | |
SplitClaim |
class | One entry of splits: a claim that the sample belongs to a partition of a split set (§12.3). |
Build and split a cohort › What the digest covers |
splits_from_json |
function | Parse the splits member of a sample document into a tuple of SplitClaims (§12.3). |
|
STATES |
constant (tuple) |
Curation records › Tracking | |
Timeline |
class | The sample's timepoints, in acquisition order; indexable by position or id. | Python API › Timepoints |
Timepoint |
class | One timepoint of the sample: an observation occasion, in DICOM terms usually one study (§3.7). | Curation records › Editing a record |
TIMEPOINT_FIELDS |
constant (frozenset) |
||
Track |
class | Every observation of one physical object, ordered by timepoint. | Curation records › Tracking |
Tracking |
class | {instance_id: Track} with the coverage needed to tell resolved from unexamined, and the reason for every absence. |
Curation records › Tracking |
UNEXAMINED |
constant (str) |
||
VoxelAgreement |
class | Per-class agreement between two voxel annotations. |
medh5.curation.agreement¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
box_iou |
function | IoU of two (S, 2) boxes in the same space. |
|
ClassMap |
type | Which class of b each class of a is compared with: by id (one vocabulary), by key (two inline label sets), or an explicit one-to-one map. |
Curation records › Two vocabularies |
compare |
function | Compare two annotations, choosing the comparison their kinds support. | Curation records › Agreement |
compare_instances |
function | Object-level agreement between two instance-carrying annotations. | Curation records › Agreement |
compare_voxel |
function | Per-class Dice or IoU between two voxel annotations on the same grid. | Curation records › Two vocabularies |
DEFAULT_IOU |
constant (float) |
||
dice |
function | Sørensen--Dice, or None when both masks are empty. |
Curation records › Agreement |
InstanceAgreement |
class | Object-level agreement: what matched, what did not, and how. | |
iou |
function | Intersection over union, or None when both masks are empty. |
Curation records › Agreement |
MatchBy |
type | How objects are paired: by instance_id within one sample where both sides share ids (auto), always by IoU, or by id (one sample only). |
Curation records › Agreement |
OBJECT_KINDS |
constant (tuple) |
Kinds whose objects carry an axis-aligned box that IoU can be taken over. | |
VoxelAgreement |
class | Per-class agreement between two voxel annotations. |
medh5.curation.scrub¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
apply |
function | Act on the actionable findings and write the §11.4 attestation. | Converters › DICOM |
DATE_KEYS |
constant (frozenset) |
||
Finding |
class | One place an identifier may live. | Curation records › De-identification |
IDENTIFYING_KEYS |
constant (frozenset) |
Attributes to remove, from the DICOM PS3.15 E.1 basic profile. | |
IDENTITY_RULES |
constant (tuple) |
Findings about what the sample is called. | |
MAX_DEPTH |
constant (int) |
How deep the walk goes before it reports rather than descends. | |
PROFILES |
constant (tuple) |
Curation records › De-identification | |
PSEUDONYM_PREFIX |
constant (str) |
What pseudonymise produces, and therefore what the rules skip. |
|
pseudonymise |
function | A stable pseudonym for a UID: same input, same output, everywhere. | De-identify and publish › 2. Apply, with a salt |
QUASI_IDENTIFYING_KEYS |
constant (frozenset) |
Attributes that identify in combination — and that some pipelines need. | |
scan |
function | Find identifiers in one file. | Curation records › De-identification |
scan_document |
function | Every rule, over every string in one sample document. | |
scrub_paths |
function | scan each of paths, or, with apply_changes, apply the other options to each. |
De-identify and publish › 2. Apply, with a salt |
ScrubReport |
class | What was found, what was changed, and what was never looked at. | |
STRICT_RULES |
constant (tuple) |
Rules that only --profile strict acts on. |
|
UID_KEYS |
constant (frozenset) |
Keys that hold a UID. | |
UNFIXABLE_LOCATIONS |
constant (tuple) |
Findings --apply never acts on by itself, however hard the profile looks. |
medh5.curation.splits¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
anatomy_units |
function | Grouping key -> every grouping key sharing anatomy with it, sorted. | |
audit_splits |
function | Read every file's claims and cross-check them (spec §12.3). | Curation records › Split claims |
Conflict |
class | One set_id claimed against more than one manifest (W906). |
|
Leak |
class | One unit of anatomy appearing in more than one partition of one split. | |
Membership |
class | One file's claim to one partition of one split. | |
SplitAudit |
class | What a cohort's split claims say, and where they disagree. |
medh5.dataset¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Assignment |
class | Where one group went. | |
check |
function | Every cohort-level check, over a manifest. | Cohort check codes |
CHECK_CODE_SEVERITY |
constant (dict) |
Each cohort code's severity. | Cohort check codes |
CHECK_CODES |
constant (dict) |
Cohort codes. | Cohort check codes |
ClassStats |
class | How often a class occurs, over the samples that examined it. | |
CohortReport |
class | What medh5.dataset.check found in a cohort: the manifest it read, the number of samples, every finding and each class's coverage. |
|
compute_stats |
function | Stream a whole cohort, optionally across workers threads. | Pack small samples into collections › Members in a cohort |
DatasetStats |
class | Everything one streaming pass over a cohort learned. | |
entries_for |
function | The manifest entries in one file: one per sample, so a collection fans out into one entry per member (each with its key). |
|
Entry |
class | One sample's metadata, as far as a cohort needs it. | Partial labels and coverage › What this buys you at training time |
find |
function | Every sample and collection under root, in a stable order. | |
Finding |
class | One cohort check's finding: its C-code, severity, message and the samples or paths it concerns. |
Cohort check codes |
make_splits |
function | Assign every group in manifest to a partition, or to a fold. | Train on clinical tasks › Describe the task |
Manifest |
class | A cohort as metadata, with the digest that makes a split checkable. | The cohort manifest › Paths |
Moments |
class | Count, mean and M2 for one image key — a Welford accumulator over the finite values folded in. | |
scan |
function | Build a manifest from a directory tree, and report what would not open. | The cohort manifest › Paths |
Split |
class | A complete assignment of a cohort's groups. | Curation records › Split claims |
write_claims |
function | Stamp each sample with its partition and the manifest digest (§12.3). | Build and split a cohort › Split it |
medh5.dataset.check¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
check |
function | Every cohort-level check, over a manifest. | Cohort check codes |
CHECK_CODE_SEVERITY |
constant (dict) |
Each cohort code's severity. | Cohort check codes |
CHECK_CODES |
constant (dict) |
Cohort codes. | Cohort check codes |
CohortReport |
class | What medh5.dataset.check found in a cohort: the manifest it read, the number of samples, every finding and each class's coverage. |
|
Finding |
class | One cohort check's finding: its C-code, severity, message and the samples or paths it concerns. |
Cohort check codes |
SEVERITIES |
constant (tuple) |
medh5.dataset.manifest¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
counts |
function | How many entries carry each value of by — the stratification tally. | Python API › Tasks and caches |
entries_for |
function | The manifest entries in one file: one per sample, so a collection fans out into one entry per member (each with its key). |
|
Entry |
class | One sample's metadata, as far as a cohort needs it. | Partial labels and coverage › What this buys you at training time |
find |
function | Every sample and collection under root, in a stable order. | |
GROUPABLE |
constant (tuple) |
Fields worth grouping or stratifying on — all single-valued and scannable. | |
load |
function | Read a manifest written by Manifest.save or medh5 dataset index; see Manifest.load. |
The cohort manifest › Paths |
Manifest |
class | A cohort as metadata, with the digest that makes a split checkable. | The cohort manifest › Paths |
PathStyle |
type | How Manifest.save writes paths. |
The cohort manifest › Paths |
scan |
function | Build a manifest from a directory tree, and report what would not open. | The cohort manifest › Paths |
SCHEMA |
constant (str) |
What every manifest Manifest.save writes names under schema. |
The cohort manifest › Paths |
SUFFIXES |
constant (tuple) |
medh5.dataset.split¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Algorithm |
type | How make_splits deals groups to partitions: "medh5.split/2" moves few when the cohort grows, and is medh5 3.0's default. |
Build and split a cohort › The algorithm, and continuing a split |
Assignment |
class | Where one group went. | |
DEFAULT_RATIOS |
constant (dict) |
||
load |
function | Read a split written by medh5 dataset split -o. |
The cohort manifest › Paths |
make_splits |
function | Assign every group in manifest to a partition, or to a fold. | Train on clinical tasks › Describe the task |
Split |
class | A complete assignment of a cohort's groups. | Curation records › Split claims |
write_claims |
function | Stamp each sample with its partition and the manifest digest (§12.3). | Build and split a cohort › Split it |
medh5.dataset.stats¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
ClassStats |
class | How often a class occurs, over the samples that examined it. | |
compute_stats |
function | Stream a whole cohort, optionally across workers threads. | Pack small samples into collections › Members in a cohort |
DatasetStats |
class | Everything one streaming pass over a cohort learned. | |
Moments |
class | Count, mean and M2 for one image key — a Welford accumulator over the finite values folded in. | |
stats_for |
function | One file's contribution, read plane by plane rather than whole. |
medh5.document¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
META_DATASET |
constant (str) |
||
new_document |
function | Start a SampleDocument with its two required members, identity and timepoints (§2.4). |
|
read_document |
function | The sample document under a sample root, parsed: a later minor's as its supported projection (1.1 §2.2). | |
read_document_text |
function | The raw /meta text under a sample root (sample.root). |
|
SampleDocument |
class | The whole document, typed. | Python API › Identity and structure |
schema |
function | The sample-document JSON Schema, parsed: a fresh dict on every call, so a caller's edit stays the caller's. | Cache manifest schema |
schema_text |
function | The sample-document JSON Schema (draft 2020-12), as published: the engine's embedded copy of medh5-sample-1.0.schema.json. |
Sample document schema |
validate_against_schema |
function | Validate a document, returning human-readable messages (empty when valid). |
medh5.errors¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Code |
class | One diagnostic code. | |
code |
function | Look up a diagnostic code, raising KeyError for unknown codes. |
Diagnostic codes › Reading a code |
CODES |
constant (dict) |
Every diagnostic code, keyed by code string. | Python API › Validation |
codes_for |
function | Every code in one domain, in table order. | |
CODES_REVISION |
constant (int) |
The revision of the code table this engine implements (§15.2). | Profiles and validation levels › Levels — how much to check |
Domain |
type | The area of the specification a diagnostic code belongs to (§15.2). | |
MEDH5Error |
exception | Base of the package's own exceptions: a file, version, schema, validation or integrity error. | Python API › Exceptions |
MEDH5FileError |
exception | A file cannot be opened, is not HDF5, or is structurally unreadable. | Python API › Amending |
MEDH5FileNotFoundError |
exception | The file does not exist. | Python API › Exceptions |
MEDH5IntegrityError |
exception | A digest or content_id does not match the data it covers. |
|
MEDH5IOError |
exception | A read or write the engine could not complete: HDF5 failing a damaged chunk, say. | Python API › Exceptions |
MEDH5IsADirectoryError |
exception | The path names a directory, not a file. | Python API › Exceptions |
MEDH5PermissionError |
exception | The file exists but may not be read (or written). | Python API › Exceptions |
MEDH5SchemaError |
exception | The sample document is absent, is not JSON, or violates its JSON Schema. | |
MEDH5ValidationError |
exception | Input rejected by a writer, or a validation failure raised as an exception. | Python API › Opening |
MEDH5VersionError |
exception | The file's medh5_version is one this operation cannot work with. |
Python API › Amending |
Severity |
type | A diagnostic code's severity: an error fails validation, a warning does not. |
medh5.geometry¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
affine_summary |
function | Return a dict describing an affine: spacing, origin, direction, determinant, orthonormal. |
|
apply_affine_to_box |
function | Return the (S, 2) axis-aligned bounds of a box's corners mapped through an affine. |
|
AXIS_KINDS |
constant (tuple) |
||
box_corners |
function | Return the 2**S corners of an (S, 2) axis-aligned box as a (2**S, S) array. |
|
box_to_slices |
function | Convert one (S, 2) box at voxel edges to a tuple of slice(start, stop), one per axis (§8.1). |
Detection and boxes › The half-voxel, once |
build_affine |
function | Return the (S+1, S+1) index-to-world affine built from spacing, origin and direction (§3.3). |
|
check_orthonormal |
function | Return direction as a float array, raising E102 unless it is orthonormal to within tol. |
|
check_pyramid |
function | Return a message for each pyramid level whose geometry breaks the derivation rule (§4.3). | |
COORD_SYSTEMS |
constant (tuple) |
Python API › Geometry | |
decompose_affine |
function | Split an index-to-world affine back into (spacing, origin, direction) arrays (§3.3). |
|
derive_level_grid |
function | Derive the Grid of one pyramid level from level 0 and its per-axis downsample factors (§4.3). |
|
DOWNSAMPLE_METHODS |
constant (tuple) |
||
GEOMETRY_RTOL |
constant (float) |
||
Grid |
class | The lattice of a stored array: its shape, axes and index-to-world geometry (§3.2). | Annotation kinds › Boxes |
index_to_world |
function | Map continuous index coordinates to world coordinates through an (S+1, S+1) affine (§3.3). |
|
is_orthonormal |
function | Whether direction is a square matrix with direction.T @ direction == I to within tol. |
|
is_proper_rotation |
function | Whether matrix is orthonormal to within tol and has determinant +1. |
|
KNOWN_UNITS |
constant (tuple) |
||
LABEL_SAFE_METHODS |
constant (tuple) |
||
MAX_SPATIAL |
constant (int) |
||
MIN_SPATIAL |
constant (int) |
||
MM_PER_UNIT |
constant (dict) |
Python API › Annotations | |
ORTHONORMAL_TOL |
constant (float) |
Converters › NIfTI | |
Pyramid |
class | The multiscale declaration of an image group: its levels, factors, method and grids (§4.3). | |
pyramid_factors |
function | Recover the (L, S) downsample factors of pyramid levels from their spacings relative to base. |
|
read_grid |
function | One grid group read back (sample.root["grids/ct"]). |
|
read_grids |
function | Every grid under a sample root, by id. | |
slices_to_box |
function | Convert slice(start, stop) objects to one (S, 2) float32 box at voxel edges (§8.1). |
|
SPEC_GRID_ATTRS |
constant (tuple) |
||
TIME_UNITS |
constant (tuple) |
||
voxel_volume |
function | Return the volume of one voxel: the product of spacing, in the grid's units to the power S. |
|
world_to_index |
function | Map world coordinates back to continuous index coordinates through an (S+1, S+1) affine (§3.3). |
medh5.image¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
check_value_type |
function | A known value_type, or E203. |
|
Image |
class | Lazy access to one image and its geometry. | Python API › Timepoints |
is_probability |
function | Whether every value lies in [0, 1] (and there is at least one). |
|
lossless_as_int16 |
function | Whether a float array would survive int16 storage unchanged (W907). |
|
SPEC_IMAGE_ATTRS |
constant (tuple) |
||
VALUE_TYPES |
constant (tuple) |
medh5.integrity¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
array_digest |
function | Return the "<algo>:<hex>" digest of an in-memory array stored at path (§13.1). |
|
ATTESTED_GROUPS |
constant (tuple) |
||
attrs_digest |
function | Return the digest of the canonical JSON of an object's named attributes (§13.2). | |
canonical_attrs |
function | Canonical JSON over an object's named attributes (§13.2). | |
collect_digests |
function | The digest of every dataset under a sample root that carries one. |
|
compute_content_id |
function | The Merkle root over stored digests, meta and canonical attributes. |
Python API › Integrity |
dataset_digest |
function | The digest of a stored dataset over its decompressed content (§13.1). | |
DEFAULT_ALGO |
constant (str) |
||
diagnose |
function | What is stale, mismatched or missing in one file. | |
Diagnosis |
class | What is wrong with one file, before anything is done about it. | |
DIGEST_ALGOS |
constant (tuple) |
||
digest_bytes |
function | Return the "<algo>:<hex>" digest of a byte string. |
|
fix |
function | Repair what was asked: rebuild stale indices, rewrite digests (with a reason, recorded as a provenance activity). | Storage › Atomic writes |
fix_paths |
function | fix over many files, every one of them: a file that cannot be repaired stops no other. |
|
group_digest |
function | The digest of an object group: its datasets and canonical attributes. | |
parse_digest |
function | Split a "<algo>:<hex>" digest into (algo, hex), raising E703 when it is malformed (§13.1). |
|
raw_chunks |
function | Return every stored chunk of a dataset as bytes, exactly as it sits on disk. |
|
relative_path |
function | An object's path relative to a sample root (the file root by default). | |
Repair |
class | What was actually done to one file. | |
stale_index_entries |
function | Return the names of the sampling index entries whose source_digest no longer matches (§13.3). |
|
STREAM_BYTES |
constant (int) |
Datasets are hashed in slabs of at most this many bytes. | |
subtrees_identical |
function | Return the paths at which two group trees differ byte for byte; empty means a pure copy. | |
verify_object |
function | Whether the dataset at path under root matches its stored digest attribute (§13.1). |
|
verify_root |
function | Verify a sample root (Sample.root, or a collection member's). |
|
VerifyResult |
class | Outcome of a verification pass. | Python API › Integrity |
medh5.io¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
augment_from_fhir |
function | read_fhir source and add the records to the sample at path (medh5.clinical.augment), in place or into out: the augment report and the conversion's. |
Converters › MEDS and FHIR R4 |
augment_from_meds |
function | read_meds source and add the records to the sample at path (medh5.clinical.augment), in place or into out: the augment report and the conversion's. |
Converters › MEDS and FHIR R4 |
build_label_set |
function | Mint one label set covering a whole cohort's mask names and box labels. | Converters › 0.x files |
ConversionReport |
class | Every note from one conversion, plus what it produced. | |
convert_world |
function | Re-express a 3-D index→world affine between RAS and LPS. | |
from_dicom |
function | Convert a DICOM tree into one sample per subject (or per study). | Converters › DICOM |
from_dicom_seg |
function | Add a DICOM SEG's segments to an existing sample (§7). | Converters › DICOM SEG |
from_itk_transform |
function | Add the ITK transform at path to sample, from the frame of grid fixed to that of grid moving — ITK's fixed and moving images. | Converters › ITK transforms |
from_nifti |
function | Write one sample from a set of co-registered NIfTI volumes. | Converters › Conversion reports |
from_nnunetv2 |
function | Convert an nnU-Net v2 dataset into one .medh5 per case. |
Converters › nnU-Net v2 |
from_rtstruct |
function | Import an RTSTRUCT's ROIs as contours, and optionally rasterise them. | Converters › RTSTRUCT |
group_by_subject |
function | Group occasions into subjects (mode="subject") or leave them apart. |
|
import_seg_nifti |
function | Add NIfTI masks to an existing sample, checking they sit on its grid. | Converters › NIfTI |
ItkTransform |
class | One ITK transform as a homogeneous matrix in LPS millimetres, mapping fixed points to moving ones (x_moving = T(x_fixed)). |
Converters › ITK transforms |
merge_reports |
function | One report over a whole cohort. | |
migrate |
function | Migrate one 0.x file into one 1.0 sample (Appendix B). | Converters › 0.x files |
migrate_paths |
function | Migrate a cohort, minting one label set for all of it. | Converters › 0.x files |
Note |
class | One thing a conversion did that the source did not fully determine. | |
read_fhir |
function | The Observations and DiagnosticReports of subject (a reference, such as Patient/123) in source, as clinical records on clock, and what the conversion decided. |
Converters › MEDS and FHIR R4 |
read_itk_transform |
function | Read an ITK transform file: text (.tfm, .txt) or ANTs' MATLAB v4 .mat, holding one of the linear types or a composite of them. |
Converters › ITK transforms |
read_meds |
function | The rows of MEDS subject subject_id in source, as clinical records on clock, and what the conversion decided. | Converters › MEDS and FHIR R4 |
read_nifti |
function | One NIfTI file as (array, geometry) in MEDH5 conventions. |
Converters › NIfTI |
scan_dicom |
function | Walk a directory tree and collect its image series. | Converters › DICOM |
Series |
class | One DICOM series, resolved into a volume and its geometry. | |
SubjectGroup |
class | Occasions belonging to one subject, in timepoint order. | |
to_dicom_seg |
function | Export one voxel annotation as a DICOM SEG against its source slices. | Converters › DICOM SEG |
to_itk_transform |
function | Write transform transform_id of sample as ITK reads it: its linear part to out (.tfm, .txt or .mat), and a displacement field applied first, as ANTs pairs them, to warp_out as a DISPVECT NIfTI (intent 1006) whose vectors are in the vectors convention, required. |
Converters › ITK transforms |
to_nifti |
function | Export one image, or one class of one annotation, as a NIfTI file. | Converters › NIfTI |
to_nnunetv2 |
function | Export samples as an nnU-Net v2 dataset. | Converters › nnU-Net v2 |
to_rtstruct |
function | Export a contours annotation as an RT Structure Set. |
Converters › RTSTRUCT |
write_itk_transform |
function | Write transform as ITK reads it, picking the format by suffix: .tfm or .txt text, or .mat as ANTs writes it. |
Converters › ITK transforms |
medh5.io.dicom¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
from_dicom |
function | Convert a DICOM tree into one sample per subject (or per study). | Converters › DICOM |
read_series |
function | One series as (volume, geometry), ordered and measured (§3.3). |
Converters › DICOM |
require_pydicom |
function | Import pydicom, or raise an ImportError naming the extra to install. |
|
scan_dicom |
function | Walk a directory tree and collect its image series. | Converters › DICOM |
select_series |
function | One series per modality — the thinnest, or the first seen. | Converters › DICOM |
Series |
class | One DICOM series, resolved into a volume and its geometry. | |
SPACING_TOLERANCE |
constant (float) |
How far a slice may sit from where the regular stack puts it, as a fraction of the slice spacing, and never less than 0.01 mm. | |
STORED_TAGS |
constant (tuple) |
Acquisition parameters copied to /meta → acquisition (§4.5). |
medh5.io.dicom_seg¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
BINARY |
constant (str) |
Converters › DICOM SEG | |
FRACTIONAL |
constant (str) |
Converters › DICOM SEG | |
FRACTIONAL_TYPES |
constant (tuple) |
What to_dicom_seg's fractional_type takes (DICOM's SegmentationFractionalType). |
Converters › DICOM SEG |
frames_agree |
function | Whether a SEG's frame of reference is a grid's; None when either states none, so there is nothing to compare. |
Converters › DICOM SEG |
from_dicom_seg |
function | Add a DICOM SEG's segments to an existing sample (§7). | Converters › DICOM SEG |
MAX_FRACTIONAL_VALUE |
constant (int) |
The stored value of a probability of 1 in a FRACTIONAL SEG this package writes: values are quantised to 1/255, so within 1/510 of what was given. | Converters › DICOM SEG |
place_frames |
function | Put each frame on the slice of grid that its position names (§3.3). | |
read_dicom_seg |
function | A SEG file as {segment number: volume} plus its geometry and segments. |
Converters › DICOM SEG |
read_dicom_seg_frames |
function | Every frame of a SEG, each with the segment and the position it carries. | Converters › DICOM SEG |
require_highdicom |
function | Import highdicom, or raise an ImportError naming the extra to install. |
|
SEGMENTATION_TYPES |
constant (tuple) |
What to_dicom_seg's segmentation_type takes. |
Converters › DICOM SEG |
SLICE_TOLERANCE |
constant (float) |
How far off a slice centre a frame may sit and still be that slice. | |
to_dicom_seg |
function | Export one voxel annotation as a DICOM SEG against its source slices. | Converters › DICOM SEG |
medh5.io.fhir¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
augment_from_fhir |
function | read_fhir source and add the records to the sample at path (medh5.clinical.augment), in place or into out: the augment report and the conversion's. |
Converters › MEDS and FHIR R4 |
COMPARATORS |
constant (dict) |
Quantity.comparator -> value_comparator (ad has none). |
Converters › MEDS and FHIR R4 |
read_fhir |
function | The Observations and DiagnosticReports of subject (a reference, such as Patient/123) in source, as clinical records on clock, and what the conversion decided. |
Converters › MEDS and FHIR R4 |
STATUSES |
constant (dict) |
FHIR R4 Observation and DiagnosticReport status -> event status (registered is left out). |
Converters › MEDS and FHIR R4 |
UCUM |
constant (str) |
Converters › MEDS and FHIR R4 |
medh5.io.grouping¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
build_occasions |
function | Adapt any sequence of source objects into occasions. | |
contradictions |
function | Demographics on which occasions disagree: {field: [values]}. |
|
FALLBACK_PREFIX |
constant (str) |
||
group_by_subject |
function | Group occasions into subjects (mode="subject") or leave them apart. |
|
note_instance_ids |
function | Record that objects were not joined across merged studies (§7.4). | |
Occasion |
class | One study/visit of one subject, before it becomes a timepoint. | |
output_name |
function | A unique filename stem for one group; it is added to used. | |
SubjectGroup |
class | Occasions belonging to one subject, in timepoint order. |
medh5.io.itk¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
from_itk_transform |
function | Add the ITK transform at path to sample, from the frame of grid fixed to that of grid moving — ITK's fixed and moving images. | Converters › ITK transforms |
ItkTransform |
class | One ITK transform as a homogeneous matrix in LPS millimetres, mapping fixed points to moving ones (x_moving = T(x_fixed)). |
Converters › ITK transforms |
read_itk_transform |
function | Read an ITK transform file: text (.tfm, .txt) or ANTs' MATLAB v4 .mat, holding one of the linear types or a composite of them. |
Converters › ITK transforms |
to_itk_transform |
function | Write transform transform_id of sample as ITK reads it: its linear part to out (.tfm, .txt or .mat), and a displacement field applied first, as ANTs pairs them, to warp_out as a DISPVECT NIfTI (intent 1006) whose vectors are in the vectors convention, required. |
Converters › ITK transforms |
write_itk_transform |
function | Write transform as ITK reads it, picking the format by suffix: .tfm or .txt text, or .mat as ANTs writes it. |
Converters › ITK transforms |
medh5.io.legacy¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
BOX_SHIFT |
constant (float) |
0.x [min, max) integer boxes sit at voxel edges once shifted (§8.1). |
|
build_label_set |
function | Mint one label set covering a whole cohort's mask names and box labels. | Converters › 0.x files |
is_legacy |
function | True when path is a readable 0.x file. | |
legacy_meta |
function | A 0.x file's metadata, without its arrays. | |
LegacyMeta |
class | 0.x metadata, as far as a migration needs it. | |
LegacySample |
class | A whole 0.x file in memory. | |
LegacySpatial |
class | 0.x geometry: one grid, shared by every image in the file. | |
load_sidecar |
function | Read a reviewed label-set sidecar back. | |
migrate |
function | Migrate one 0.x file into one 1.0 sample (Appendix B). | Converters › 0.x files |
migrate_paths |
function | Migrate a cohort, minting one label set for all of it. | Converters › 0.x files |
read_legacy |
function | A whole 0.x file. | |
SCHEMA_VERSION |
constant (str) |
The only 0.x schema version that ever shipped. | |
SUFFIX |
constant (str) |
||
write_sidecar |
function | Write the minted label set for review before a cohort-wide migration. |
medh5.io.meds¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
augment_from_meds |
function | read_meds source and add the records to the sample at path (medh5.clinical.augment), in place or into out: the augment report and the conversion's. |
Converters › MEDS and FHIR R4 |
BIRTH |
constant (str) |
The MEDS code of a subject's birth. | Converters › MEDS and FHIR R4 |
BOTH_VALUES |
constant (tuple) |
Converters › MEDS and FHIR R4 | |
COLUMNS |
constant (tuple) |
The columns columns= may rename: MEDS's own five, and the two MEDS lacks, which are read only when declared. |
Converters › MEDS and FHIR R4 |
read_meds |
function | The rows of MEDS subject subject_id in source, as clinical records on clock, and what the conversion decided. | Converters › MEDS and FHIR R4 |
medh5.io.nifti¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
convert_world |
function | Re-express a 3-D index→world affine between RAS and LPS. | |
COORD_SYSTEMS |
constant (tuple) |
Python API › Geometry | |
from_nifti |
function | Write one sample from a set of co-registered NIfTI volumes. | Converters › Conversion reports |
import_seg_nifti |
function | Add NIfTI masks to an existing sample, checking they sit on its grid. | Converters › NIfTI |
RAS_TO_LPS |
constant (ndarray) |
World-axis sign flip. | |
read_nifti |
function | One NIfTI file as (array, geometry) in MEDH5 conventions. |
Converters › NIfTI |
require_nibabel |
function | Import nibabel, or raise an ImportError naming the extra to install. |
|
to_nifti |
function | Export one image, or one class of one annotation, as a NIfTI file. | Converters › NIfTI |
medh5.io.nnunetv2¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
BACKGROUND |
constant (int) |
||
cases |
function | Case identifiers present in imagesTr — and, with include_test, in imagesTs. |
Run the conformance suite › Publish a suite |
from_nnunetv2 |
function | Convert an nnU-Net v2 dataset into one .medh5 per case. |
Converters › nnU-Net v2 |
read_dataset_json |
function | Load and check an nnU-Net v2 dataset.json. |
|
REQUIRED_KEYS |
constant (tuple) |
||
to_nnunetv2 |
function | Export samples as an nnU-Net v2 dataset. | Converters › nnU-Net v2 |
medh5.io.report¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
ConversionReport |
class | Every note from one conversion, plus what it produced. | |
merge_reports |
function | One report over a whole cohort. | |
Note |
class | One thing a conversion did that the source did not fully determine. | |
SEVERITIES |
constant (tuple) |
decision was determined by the data; guess was not. |
medh5.io.rtstruct¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
from_rtstruct |
function | Import an RTSTRUCT's ROIs as contours, and optionally rasterise them. | Converters › RTSTRUCT |
MIN_POLYGON_VERTICES |
constant (int) |
||
read_rtstruct |
function | An RTSTRUCT as {roi number: [contour, ...]} in patient coordinates. |
|
to_rtstruct |
function | Export a contours annotation as an RT Structure Set. |
Converters › RTSTRUCT |
medh5.labels¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
available |
function | Every vocabulary name load accepts, bundled and registered. |
Annotation kinds › Label sets |
BACKGROUND_ID |
constant (int) |
||
canonical_json |
function | Return the canonical JSON bytes of a document: sorted keys, no whitespace, UTF-8 (§5.1). | |
check |
function | Whether sample files share one vocabulary, as medh5 labels check --json. |
Choose and map a label set › Find where a cohort disagrees |
check_class_id |
function | Return class_id if it is an assignable class id, 1 to 65534 (§5.3). |
|
CLOSURES |
constant (tuple) |
||
describe |
function | Name -> {id, version, classes, sha256}. |
Python API › Sub-packages |
FORMS |
constant (tuple) |
||
from_keys |
function | Mint an inline LabelSet from bare class keys, with ids counting up from start. |
|
IGNORE_ID |
constant (int) |
||
INLINE_REQUIRED_BELOW |
constant (int) |
||
LabelClass |
class | One semantic class (§5.2). | Annotation kinds › Closure |
LabelSet |
class | A controlled vocabulary (§5.1). | Annotation kinds › Label sets |
load |
function | A bundled or registered vocabulary by name; E305 for an unknown one. | Annotation kinds › Label sets |
load_file |
function | A vocabulary from a JSON file on disk. | Converters › NIfTI |
MAX_CLASS_ID |
constant (int) |
||
OntologyCode |
class | A binding of a class to a code of an external vocabulary, such as SNOMED-CT or RadLex (§5.2). | |
register |
function | Make a vocabulary loadable by name for the rest of the process. | Curation records › Provenance |
Relation |
class | A non-is_a edge between two classes of a label set, such as part_of (§5.4). |
|
Skeleton |
class | A keypoint topology declared by a label set: keypoint class ids and edges between them (§5.5). | |
unregister |
function | Drop a registered vocabulary; bundled ones cannot be removed. |
medh5.monai¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
affine_for |
function | The index→world affine of one image, as MONAI receives it: optionally re-expressed in space, and in millimetres (see _monai_affine). |
PyTorch and MONAI › MONAI |
available |
function | Whether MONAI can be imported. | PyTorch and MONAI › MONAI |
convert_affine |
function | Re-express an index→world affine in another world convention. | PyTorch and MONAI › A reader for LoadImage |
from_metatensor |
function | A MetaTensor back to (array, geometry) a writer can consume. |
PyTorch and MONAI › MONAI |
LoadMedH5d |
class | medh5.monai.to_dict as a MONAI dictionary transform. |
PyTorch and MONAI › A reader for LoadImage |
MedH5Reader |
class | A MONAI ImageReader for .medh5 samples and collection members. |
PyTorch and MONAI › A reader for LoadImage |
meta_dict |
function | The metadata MONAI carries alongside a tensor. | PyTorch and MONAI › MONAI |
require_monai |
function | Import MONAI, or explain how to install it. | |
SPACES |
constant (tuple) |
Python API › Geometry | |
to_dict |
function | A MONAI dictionary-transform item: {image_id: MetaTensor, ...}. |
PyTorch and MONAI › MONAI |
to_metatensor |
function | One image (or ROI of it) as a MONAI MetaTensor. |
PyTorch and MONAI › MONAI |
medh5.nodes¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Attrs |
class | An object's attributes, as a mutable mapping. | |
Dataset |
class | A stored dataset: shape, dtype, chunks, filters, attributes and ds[...]. |
Python API › Stored objects |
Group |
class | A stored group: members by name (or path), and attributes. |
medh5.sample¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
amend |
function | Copy-on-write amend: build a new file from the old and replace it. | Python API › Amending |
annotation_id |
function | An annotation id from a reference that may be written as a path. | |
AnnotationCollection |
class | The sample's annotations, with task- and timepoint-aware views. | |
create |
function | Create a new sample; use as a context manager, or call commit(). |
Annotation kinds › Closure |
FORMAT_VERSION |
constant (str) |
medh5 › Versioning | |
FRAME_ATTRS |
constant (tuple) |
Where frame-of-reference uids are named: (group, attribute names). |
|
ImageCollection |
class | The sample's images, with timepoint- and modality-aware views. | |
MANAGED_ROOT_ATTRS |
constant (tuple) |
Root attributes commit writes itself; an amend does not copy them. |
|
open_sample |
function | Open a .medh5 sample file, read-only. |
Python API › Opening |
PROFILES |
constant (tuple) |
Profiles and validation levels › Profiles — what to hold the file to | |
ROOT_DIGEST_ATTRS |
constant (tuple) |
Root attributes covered by content_id. |
|
Sample |
class | A read-only view of one sample root (a file, or a collection member). | Python API › Sample |
SampleWriter |
class | Builder for one sample. | Python API › Writing |
STANDARD_GROUPS |
constant (tuple) |
||
TimepointView |
class | Everything in the sample that belongs to one timepoint. |
medh5.sampling¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
BLEND_MODES |
constant (tuple) |
How overlapping patch predictions are weighted when stitched back: constant averages them, gaussian trusts each patch most at its centre, where its model saw the most context. |
PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
blend_weights |
function | The weight of each voxel of a patch when patches are stitched back. | PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
coerce_patch_size |
function | Broadcast a scalar patch size across ndim spatial axes. | |
grid_patches |
function | Deterministic sliding-window cover of a volume — the inference path. | PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
iter_patches |
function | The patches of PatchSampler.draws, drawn one per next(). |
Python API › Sampling patches |
PAIR_MODES |
constant (tuple) |
||
PairReport |
class | What a paired dataset kept and what it skipped. | |
Patch |
class | One draw: where to read, and how the location was chosen. | Python API › Sampling patches |
PatchAggregator |
class | Stitch patch predictions back into one volume. | PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
PatchSampler |
class | Choose patch windows in a volume (spec §14.3). | Python API › Sampling patches |
Seed |
type | What seeds a draw: an integer, a sequence of integers — (seed, epoch, index) — a numpy.random.Generator, which supplies one seed and advances, or None for fresh entropy. |
Python API › Sampling patches |
STRATEGIES |
constant (tuple) |
||
TimepointPair |
class | One ordered pair of visits, and the change label spanning it, if any. | |
TimepointPairSampler |
class | Enumerate the visit pairs a longitudinal model trains on (§3.7, §9). | PyTorch and MONAI › PairedPatchDataset — the same place at two visits |
window_around |
function | Slices covering patch voxels around center, plus the padding needed. |
medh5.storage¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
BLOSC2_FILTER_ID |
constant (int) |
||
BLOSC_FILTER_ID |
constant (int) |
||
build_index |
function | Compute the sampling index of one voxel annotation (not written). | Python API › Derived data |
BUILTIN_FILTER_IDS |
constant (frozenset) |
||
BULK_MIN_BYTES |
constant (int) |
Datasets at least this large are bulk: W902 wants them compressed. | |
CACHE_SAFETY |
constant (float) |
||
chunk_report |
function | Return a dict describing a chunking: chunks, chunk_bytes, chunk_mib and n_chunks. |
|
Codec |
class | One codec setting. | Storage › Codec profiles |
CodecProfile |
class | A named pairing of codecs for image data and for label/field data. | |
COMPRESS_MIN_BYTES |
constant (int) |
Datasets smaller than this are stored contiguous and unfiltered. | |
dataset_layout |
function | The layout the writer gives one dataset: {} when it is stored contiguous (small or empty), else {"chunks": ..., "codec": ...}, the codec being profile's for role — a CodecProfile of your own as much as a named one. |
Storage › Codec profiles |
DEFAULT_L3_BYTES |
constant (int) |
||
DEFAULT_MAX_COORDS |
constant (int) |
||
DEFAULT_OCCUPANCY_FACTOR |
constant (int) |
||
DEFAULT_PATCH |
constant (int) |
||
DEFAULT_PROFILE |
constant (str) |
||
describe_filters |
function | A dataset's actual filter pipeline, e.g. | |
detect_l3_bytes |
function | Return one CPU's share of the L3 cache in bytes, best effort, with a fallback of ~1.375 MiB. | |
field_chunks |
function | Return the chunks of a displacement field on grid: one vector component per chunk, or None. |
|
fit_chunks |
function | Return the trailing len(shape) entries of proposed clipped to shape, or None. |
|
grid_chunks |
function | Return the chunk shape the writer gives an array laid out on grid (§14.1). |
|
IndexPayload |
class | The datasets of one annotation's index entry (§14.3). | |
is_bulk |
function | Whether a dataset is large enough for the W902 warning. | |
MAX_CHUNK_BYTES |
constant (float) |
||
MIN_CHUNK_BYTES |
constant (float) |
||
occupancy |
function | The occupancy map of a mask: one bit per factor-cube of voxels (factor at least 1). |
Storage › The sampling index |
optimize_chunks |
function | Return a full chunk shape for an array whose axes are described by axis_kinds (§14.1). |
|
OVERSHOOT_LIMIT |
constant (float) |
||
profile_family |
function | portable when every dataset of the file needs only HDF5's own filters, else balanced — what an amend of it defaults to. |
|
PROFILES |
constant (dict) |
Storage › Codec profiles | |
read_indices |
function | Every stored index entry under a sample root (Sample.root, or the Sample), by annotation id. |
|
recompress |
function | Rewrite path (or write out) with every bulk dataset re-encoded under profile; rechunk also re-derives chunk shapes from the grids. |
Storage › Atomic writes |
recompress_paths |
function | Recompress many files, one result each: every one of them — a file that cannot be recompressed stops no other. | |
RecompressResult |
class | What one file's re-encoding did. | Storage › Integrity |
resolve_profile |
function | A profile by name (None is balanced), or the profile given. |
Storage › Codec profiles |
Role |
type | What a dataset holds, which picks its codec profile (§14.2). | |
SamplingIndex |
class | A reader for one index/<ann_id> entry: the sampling index of the training profile (§14.3). |
Python API › Sampling index |
spatial_chunk_for |
function | Return chunk extents for the spatial axes alone, sized to a training patch and the L3 cache. |
medh5.task¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
CENSORING |
constant (tuple) |
What a target does with a row it cannot label (contract §5). | |
CODES |
constant (dict) |
The companion contract's finding codes (T1xx manifest, T2xx identity and splits, T3xx sources, T4xx caches) and what each means. | Python API › Tasks and caches |
concept_token |
function | An event's concept token: kind|code_system|code, or kind| when it is uncoded. |
Python API › Tasks and caches |
Confine |
type | Where a runner lets a task's sources be opened from (contract §2): True confines them to the base relative URIs resolve against, a path to that directory, False opens wherever the URIs point. |
Python API › Tasks and caches |
EventTable |
class | One subject's merged event versions, as columns. | |
Finding |
class | One thing wrong with a task, its sources, or a cache. | Python API › Tasks and caches |
LinkTable |
class | One subject's links, every fragment's, as columns; indexing builds a medh5.clinical.Link, and fragment(i) says whose it is. |
|
Note |
class | Something a manifest should state and does not. | Python API › Tasks and caches |
Packed |
class | A packed UTF-8 column: one buffer, int64 offsets, and a validity mask (None when every cell is valid) — the clinical tables' own encoding (1.1 §4). |
|
Preflight |
class | A task's preflight: manifest and source findings, every subject's merged history, and every row's view. | Python API › Tasks and caches |
preflight |
function | Preflight a task (a manifest, or the path of one); confine says where sources may be opened (Confine). |
Python API › Tasks and caches |
Reconciled |
class | An event version several fragments hold, and the digest they share. | |
Repinned |
class | One source pinned to a new version. | Python API › Tasks and caches |
RepinReport |
class | What TaskManifest.repin did, or would do. |
Python API › Tasks and caches |
ROI |
constant (tuple) |
What a slot may request its region be centred on (contract §3.5). | Segmentation › Read them back |
ROIS |
constant (tuple) |
How a slot's region was centred: ROI, and center_fallback when a slot asked for an eligible instance and the row has none. |
|
Row |
class | One example: a subject at a cutoff. | |
ROW_STATUSES |
constant (tuple) |
||
RowView |
class | Everything a task admits for one row, and nothing else. | Python API › Tasks and caches |
SCHEMA |
constant (str) |
The manifest's own version. | |
schema_text |
function | The medh5.task/1 JSON Schema. |
Task manifest schema |
SELECTION_STATUSES |
constant (tuple) |
||
Slot |
class | A stable modality slot, filled per row by the newest eligible image of its modality — never by a filename (contract §3.5). | Python API › Tasks and caches |
SlotFill |
class | How one slot was filled for one row — or that it was not. | |
SourceRef |
class | One sample — a file, or a member of a .medh5c — at a pinned version. |
Python API › Tasks and caches |
Subject |
class | One subject: its fragments, its clock and its partition. | |
SubjectHistory |
class | One subject's history, merged across its fragments: what every row of the subject indexes. | |
Target |
class | What a row is labelled with (contract §5): an event concept whose final value_text falls in positive or negative inside (cutoff, cutoff + horizon_us], read from the full history. |
Python API › Tasks and caches |
TARGET_STATUSES |
constant (tuple) |
||
TargetLabel |
class | A row's target: positive (1.0), negative (0.0), or unobserved (censored, prevalent, none) with the reason. |
|
TaskManifest |
class | A medh5.task/1 manifest: build it, check it, save it, preflight it. |
Python API › Tasks and caches |
medh5.torch¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
ALIGNMENTS |
constant (tuple) |
||
AVAILABLE |
constant (bool) |
||
CACHE |
constant (HandleCache) |
PyTorch and MONAI › Keeping a file's items together | |
ClinicalTaskDataset |
class | One item per admitted row of a task. | PyTorch and MONAI › Clinical tasks (format 1.1) |
collate |
function | DataLoader(collate_fn=...) for the MEDH5 item shape. |
PyTorch and MONAI › Keeping a file's items together |
collate_clinical |
function | DataLoader(collate_fn=...) for ClinicalTaskDataset items. |
PyTorch and MONAI › Clinical tasks (format 1.1) |
ConceptVocabulary |
class | Concept indices, per-concept value statistics and the categories each concept's text values took, fitted on one partition of one task — and saying which. | PyTorch and MONAI › Clinical tasks (format 1.1) |
FileGroupedSampler |
class | Shuffle files, and yield every item of a file before the next file. | PyTorch and MONAI › Keeping a file's items together |
grid_patches |
function | Deterministic sliding-window cover of a volume — the inference path. | PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
GridPatchDataset |
class | Deterministic sliding-window cover of every file — the inference path. | PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
GridStitcher |
class | Reassemble a medh5.torch.GridPatchDataset's predictions. |
PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
HandleCache |
class | PID-scoped, thread-safe LRU cache of open samples. | PyTorch and MONAI › Keeping a file's items together |
LABEL_FORMATS |
constant (tuple) |
||
open_cached |
function | Open a sample — or a collection member — through the per-worker cache. | |
PairedPatchDataset |
class | Corresponding patches from two visits of one subject (§3.7, §10). | PyTorch and MONAI › PairedPatchDataset — the same place at two visits |
PairReport |
class | What a paired dataset kept and what it skipped. | |
Patch |
class | One draw: where to read, and how the location was chosen. | Python API › Sampling patches |
PatchDataset |
class | samples_per_volume patches from each file, drawn by a sampler. |
PyTorch and MONAI › PatchDataset — random patches |
PatchSampler |
class | Choose patch windows in a volume (spec §14.3). | Python API › Sampling patches |
require_torch |
function | Without PyTorch, raise an ImportError that says how to install it — or, when it is installed and fails to import, why. |
|
set_cache_size |
function | Resize this process's cache: how many files each worker keeps open. | PyTorch and MONAI › Keeping a file's items together |
stack_images |
function | Channel-stack several images into one (B, C, *patch) tensor. |
|
TimepointPair |
class | One ordered pair of visits, and the change label spanning it, if any. | |
TimepointPairSampler |
class | Enumerate the visit pairs a longitudinal model trains on (§3.7, §9). | PyTorch and MONAI › PairedPatchDataset — the same place at two visits |
VolumeDataset |
class | One item per file: the whole volume, eagerly read. | PyTorch and MONAI › VolumeDataset — whole volumes |
worker_init_fn |
function | DataLoader(worker_init_fn=...): drop handles inherited across fork (in a process that opened them, close them; see HandleCache.clear). |
PyTorch and MONAI › The DataLoader |
medh5.torch.clinical¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
ClinicalTaskDataset |
class | One item per admitted row of a task. | PyTorch and MONAI › Clinical tasks (format 1.1) |
collate_clinical |
function | DataLoader(collate_fn=...) for ClinicalTaskDataset items. |
PyTorch and MONAI › Clinical tasks (format 1.1) |
concept_of |
function | An event's concept token: kind|code_system|code (kind| uncoded), a \ or | in the system or code escaped (medh5.task.concept_token). |
|
ConceptVocabulary |
class | Concept indices, per-concept value statistics and the categories each concept's text values took, fitted on one partition of one task — and saying which. | PyTorch and MONAI › Clinical tasks (format 1.1) |
PAD |
constant (int) |
Concept index of padding. | |
UNKNOWN |
constant (int) |
Concept index of a concept the vocabulary was not fitted on. |
medh5.torch.collate¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
collate |
function | DataLoader(collate_fn=...) for the MEDH5 item shape. |
PyTorch and MONAI › Keeping a file's items together |
stack_images |
function | Channel-stack several images into one (B, C, *patch) tensor. |
medh5.torch.datasets¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
ALIGNMENTS |
constant (tuple) |
||
GridPatchDataset |
class | Deterministic sliding-window cover of every file — the inference path. | PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
LABEL_FORMATS |
constant (tuple) |
||
PairedPatchDataset |
class | Corresponding patches from two visits of one subject (§3.7, §10). | PyTorch and MONAI › PairedPatchDataset — the same place at two visits |
PatchDataset |
class | samples_per_volume patches from each file, drawn by a sampler. |
PyTorch and MONAI › PatchDataset — random patches |
VolumeDataset |
class | One item per file: the whole volume, eagerly read. | PyTorch and MONAI › VolumeDataset — whole volumes |
medh5.torch.handles¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
CACHE |
constant (HandleCache) |
PyTorch and MONAI › Keeping a file's items together | |
DEFAULT_MAXSIZE |
constant (int) |
||
HandleCache |
class | PID-scoped, thread-safe LRU cache of open samples. | PyTorch and MONAI › Keeping a file's items together |
open_cached |
function | Open a sample — or a collection member — through the per-worker cache. | |
set_cache_size |
function | Resize this process's cache: how many files each worker keeps open. | PyTorch and MONAI › Keeping a file's items together |
worker_init_fn |
function | DataLoader(worker_init_fn=...): drop handles inherited across fork (in a process that opened them, close them; see HandleCache.clear). |
PyTorch and MONAI › The DataLoader |
medh5.torch.samplers¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
FileGroupedSampler |
class | Shuffle files, and yield every item of a file before the next file. | PyTorch and MONAI › Keeping a file's items together |
medh5.torch.stitch¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
GridStitcher |
class | Reassemble a medh5.torch.GridPatchDataset's predictions. |
PyTorch and MONAI › GridPatchDataset — deterministic tiling, for inference |
medh5.transforms¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
AffineTransform |
class | A homogeneous (S+1, S+1) matrix in world coordinates. |
Converters › ITK transforms |
basis |
function | The B-spline basis weights at t: (order + 1, *t.shape). |
|
BSplineTransform |
class | A free-form deformation evaluated with a uniform B-spline basis. | |
ChainTransform |
class | Several transforms applied in order — a resolved path. | Registration between visits › Write one |
check_transform_id |
function | Return transform_id if it is a valid object id, else raise E003. |
|
CompositeTransform |
class | Components applied in order; each one's to_frame is the next's from_frame. |
Converters › ITK transforms |
cubic_sample |
function | Interpolate (C, *spatial) data with cubic splines at (N, S) continuous indices: (N, C). |
|
DEFAULT_ORDER |
constant (int) |
||
DisplacementTransform |
class | T(x) = x + u(x) with u sampled on field_grid. |
|
encode_affine |
function | Pack a homogeneous world-to-world (S+1, S+1) matrix as an affine transform payload (§10.3). |
|
encode_bspline |
function | Pack (S, *cp_shape) B-spline control-point coefficients as a bspline payload (§10.5). |
|
encode_composite |
function | Declare a composite transform: two or more component transform ids, applied in order (§10.5). |
|
encode_displacement |
function | Pack a (S, *spatial) displacement field (§10.4), cast to dtype. |
|
encode_identity |
function | Return the payload of an identity transform, which stores nothing but its endpoints. | |
EXTRAPOLATIONS |
constant (tuple) |
||
FLOAT16_SAFE_VOXELS |
constant (float) |
||
folding_fraction |
function | Return the fraction of Jacobian determinants that are <= 0: where the transform folds. |
Python API › Transforms |
frame_graph |
function | Frame -> frames one hop away, as resolve_between would walk them: a reverse edge exists only where the inverse can be evaluated, and a transform and the stored inverse its inverse_id names are one edge each way (§10.1). |
|
frames_of_timepoint |
function | The frames of every grid of one timepoint, in grid order. | Registration between visits › When there is no path |
IdentityTransform |
class | Two frames that coincide, said explicitly. | Converters › ITK transforms |
inside_extent |
function | Return a boolean array saying which points lie within a lattice's voxel extent, edges included. | |
INTERPOLATIONS |
constant (tuple) |
||
InverseTransform |
class | The inverse of another transform, evaluated (not stored). | Registration between visits › Write one |
jacobian_determinant |
function | Return det(I + du/dx) per voxel of a displacement field on grid; values <= 0 mark folding. |
Python API › Transforms |
LAST_ROW_TOL |
constant (float) |
||
linear_part |
function | Return a grid's direction @ diag(spacing): the (S, S) map from index to world displacement. |
|
linear_sample |
function | Interpolate (C, *spatial) data multilinearly at (N, S) continuous indices: an (N, C) array. |
|
refuse_outside |
function | Raise MEDH5ValidationError if any of the inside flags is false: extrapolation='error'. |
|
resolve_between |
function | The transform relating two frame uids, or None when none does. |
|
sample_field |
function | Interpolate a field at (N, S) continuous indices with the declared interpolation (§10.4). |
|
SPEC_TRANSFORM_ATTRS |
constant (tuple) |
||
SUPPORTED_ORDERS |
constant (tuple) |
||
target_registration_error |
function | TRE ‖T(p_F) − p_M‖ over world landmarks with matching row order (§10.6): {mean, median, max, n}. |
Python API › Transforms |
to_world_vectors |
function | Convert (N, S) displacement vectors in vector_space on grid to world units (§10.4). |
|
Transform |
class | What every transform answers, whatever its kind. | Python API › Transforms |
TRANSFORM_KINDS |
constant (tuple) |
||
TransformHeader |
class | The attribute header every transform carries (spec §10.1). | |
VECTOR_SPACES |
constant (tuple) |
||
wrap_transform |
function | The facade class for an engine transform handle. |
medh5.validate¶
| Name | Kind | Summary | Documented in |
|---|---|---|---|
Diagnostic |
class | One finding. | Python API › Validation |
Level |
type | A validation level (§15.1); each includes the checks of the levels before it. | |
LEVEL_ORDER |
constant (dict) |
||
LEVELS |
constant (tuple) |
||
merge |
function | Combine several reports, prefixing each diagnostic's location with its file. | |
Report |
class | Everything a validation pass found. | |
rules_for |
function | The rules a pass at level runs, in order. | |
validate_file |
function | Validate one .medh5 sample or .medh5c collection file. |
Python API › Validation |
validate_paths |
function | Validate many files, one report each, as validate_file does. |
Python API › Validation |
validate_root |
function | Validate an open medh5.sample.Sample — a file, or a member of a collection — held to the profiles it declares and to profiles besides. |