Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Generate synthetic medical images with medigan

Synthetic medical imaging concept showcasing MRI, CT, and X-ray scans generated using Python and GAN models.

Generate synthetic medical images with medigan is a 2024 PYCAD Team how-to: call the open-source medigan library, pick a pretrained GAN, write PNG/array samples. It is not a PYCAD synthetic-data product. It is not a dataset marketplace.

If you meant what imaging ML actually returnsmachine learning for medical imaging. If you meant annotation of real studiesmedical image annotation. If you meant public dataset lists that is a different leftover, not this URL.

Early imaging MVPs stall on data. Public sets are the wrong anatomy, a bought set is slow, and a hospital partner is not in the room yet. Synthetic samples are one way to stand up a pipeline before the real studies exist. They are not a substitute for a site’s own labeled hold-out when you go to clinic.

What medigan is

medigan (Osuala et al., Frontiers in Oncology 2022, doi:10.3389/fonc.2022.1044496) is a Python wrapper around pretrained generative models — mostly GANs — for medical images. The 2022 paper listed 21 models, 9 GAN architectures, 11 datasets, covering mammography, endoscopy, X-ray, and MRI. The catalogue grows; check the repo for the current IDs. The library is framework-agnostic: you ask for a model_id and a count.

A GAN is two nets: a generator that fakes an image, a discriminator that tries to tell fake from real. At convergence the generator’s fakes are supposed to be hard to call. That is the method. It does not make a heart on the wrong side “creative.” If the anatomy is wrong, the sample is trash.

The call

Install is pip install medigan.

from medigan import Generators

generators = Generators()
# model_id=1 is a mammography GAN in the 2022 catalogue — confirm IDs in the repo
generators.generate(model_id=1, num_samples=6, install_dependencies=True)

install_dependencies=True pulls whatever that model needs the first time. You get arrays or files you can feed a segmentation or classification loop. Six samples is a smoke test, not a training set.

Example synthetic mammography / CT / X-ray samples from a GAN catalogue

Why you would bother

  • Class balance. Rare positives are the usual failure. A GAN trained on the rare class can oversample it. The discriminator still has to have seen real rares.
  • A pipeline before the partner. You can wire loaders, augment, and a dummy train on fakes. You cannot claim a clinical AUC on them.
  • Sharing without PHI. Weights and fakes are not the hospital’s DICOM. They are also not automatically de-identified forever — a model can memorize. Treat them as derived data, not as a waiver.

Training your own mammography GAN on a private set is a different script. One public example from the same circle: zuzaanto/mammo_gans_iwbi2022. That is their training loop, not a PYCAD SKU.

What this page is not

  • Not a PYCAD synthetic-data platform, GAN service, or dataset store. The library is RichardObi’s. The note is a how-to.
  • Not 673. Imaging ML is the mark on a real study. This page is how you mint extras when the real studies are thin.
  • Not /portfolio. Dropped.

If the fakes are only there to stand up a viewer or a training loop you will later swap for site data, that is the imaging piece. Case studies.

Repo: github.com/RichardObi/medigan. Paper: Osuala et al., 2022, as linked above.

We build custom medical imaging platforms — advanced DICOM viewers, AI segmentation, and the clinical systems around them.

Get in Touch

Copyright © 2026 PYCAD. All Rights Reserved.