Guides

Loading data

Public package status: the Python distributions and desktop installers are not released yet. These pages document an evolving interface, not currently usable install artifacts. View release status.

load_dataset turns any catalog entry into an indexable and iterable view of Sample objects — a uniform shape across all 130 datasets, regardless of each dataset’s native file format or loader implementation.

Loading a dataset

def load_dataset(name: str, *, split="train", type="image", source=None, **kwargs)
import medotter as mo

ds = mo.load_dataset("ACDC", split="test")
len(ds)                 # number of samples in the test split
sample = ds[0]           # indexable
for sample in ds:        # also iterable
    ...

The Sample contract

Every element is a Sample(image, mask, spacing, meta):

FieldTypeContract
imagenp.ndarray(H, W) or (H, W, 3). Native dtype — never re-normalized. Normalization (scaling, mean/std) is the model’s job, not the loader’s.
masknp.ndarray | NoneInteger label map, same spatial shape as image. In the dataset’s native label space — label 0 is not universally background (see LabelSchema and a dataset’s DatasetInfo.background_id). None if the loader returns no mask.
spacingtuple[float, ...] | NonePixel/voxel spacing, if the underlying loader surfaces it. Never fabricatedNone when the dataset doesn’t carry spacing metadata, not a guessed default.
metadictAt least {"dataset": name}; commonly also modality, case_id, slice_idx, class_names, image_path, mask_path — present only when the loader surfaces them.

meta["case_id"] (plus meta["slice_idx"] when present) is what mo.score uses to key predictions, so two samples from the same volume are only safely distinguishable when slice_idx is present.

Common errors