Examples¶
Self-contained scripts that exercise the public MedAugmentX surface. From a
source checkout, install the package with pip install -e . or run with
PYTHONPATH=.:
PYTHONPATH=. python examples/<name>.py
Script |
What it shows |
|---|---|
The MedAugmentX “hello world” — build a |
|
Standardize spacing, draw reproducible class-balanced training patches and sample back onto the original grid. Core dependencies only. |
|
Train two policies with synchronized channels and compare them on the same synthetic patient holdout. Core dependencies only. |
|
Tour of the 0.6.0 additions: cutout, shape normalisation, CLAHE, histogram matching, and the new MRI/CT/X-ray/DBT artifacts. |
|
The tomosynthesis pipeline on a synthetic DBT slab with anisotropic spacing. |
|
Use |
|
How to author your own seedable transform and drop it into |
|
Validate augmented volumes with |
|
Track landmark keypoints and bounding boxes through a spatial pipeline, then prune off-frame targets after a crop. |
|
Load a real NIfTI / DICOM volume from disk, augment, and write back. Requires the |
If the optional I/O backends are not installed, the loader scripts fail
fast with a clear ImportError telling you which extra to install.
Reproducible experiment record¶
Run python examples/reproducible_experiment.py to replay a saved MRI policy
on synthetic data and print an experiment record with configuration and output
fingerprints. See Research guide.
README transformation gallery¶
Generate all four synthetic modality inputs and the eight transformed outputs:
pip install -e . matplotlib
python examples/generate_readme_gallery.py
The script writes docs/assets/modality-gallery.png and a JSON manifest with
parameters, display limits, and dependency versions. Use --output-dir PATH
for a separate preview. Matplotlib is only needed to regenerate the gallery;
it is not a core library dependency. The inputs are mathematical phantoms,
not patient data or validated anatomical simulations. Effects are intentionally
visible and are not a suggested augmentation policy.
MRI, CT, and X-ray use 2D inputs. Tomosynthesis uses a 3D phantom with spacing
(1.0, 0.5, 0.25) and displays its middle-y (z, x) plane in physical aspect
ratio. The display range is fixed within each row, and each transform receives
the original input independently.
Preview and exact replay¶
Install medaugmentx[viz], then run python examples/preview_and_replay.py --output preview-output.
This writes a synthetic image/mask montage, structural QA, versioned policy and
verified replay record. For real NIfTI use load_nifti(image_path, mask_path=mask_path)
and keep output artifacts inside your controlled data store.