MaskMedPaint: Masked Medical Image Inpainting with Diffusion Models for Mitigation of Spurious Correlations

Qixuan Jin, Walter Gerych, Marzyeh GhassemiarXiv 2024 · DOI

Introduction

Machine learning models in medical imaging are often "lazy learners," identifying "shortcuts" or spurious correlations rather than genuine biological features. For instance, a model might associate surgical rulers or ink markings with malignancy simply because they appear more frequently in biopsy-confirmed cases. This phenomenon, known as domain shift, poses significant safety risks when deploying AI across different healthcare environments. While generative AI offers a potential solution by creating counterfactual images to break these correlations, standard text-to-image methods often fail to preserve critical clinical details. This paper introduces MaskMedPaint, a framework that leverages diffusion models to align source data with a target domain while strictly preserving the diagnostic Region of Interest (ROI).

Methodology

MaskMedPaint utilizes a three-step pipeline to generate high-fidelity augmented data that forces classifiers to focus on disease features rather than background artifacts.

  1. Class-conditional Source Fine-tuning: A diffusion model is first fine-tuned on the labeled source dataset. This step ensures the model understands the essential characteristics of different clinical classes (e.g., benign vs. malignant lesions).
  2. Unconditional Target Fine-tuning: Using a small set of unlabeled images from the target domain, the model is fine-tuned via Dreambooth to learn a specific "dummy token" (e.g., target-domain). This captures the unique environmental style, lighting, and artifacts of the new hospital or dataset.
  3. Masked Inpainting: To create augmented training data, the system takes a source image and masks the ROI. The diffusion model then "repaints" the background to match the target domain while keeping the clinical features 100% authentic.
The three-step MaskMedPaint pipeline: class-conditional source fine-tuning, unconditional target fine-tuning using Dreambooth, and masked inpainting for data augmentation.

Experimental Results

The framework was evaluated on both natural imaging benchmarks (Waterbirds, iWildCam) and critical medical datasets, including dermatology (ISIC 2018) and chest X-rays (MIMIC-CXR to NIH).

Dermatology Performance

In the ISIC 2018 dataset, where rulers are spuriously correlated with malignancy, a baseline model achieved only 14.6% accuracy on a test set where the shortcut was broken. MaskMedPaint improved this to 34.4%, significantly outperforming other generative baselines like ALIA (10.6%) and LADS (18.3%). By generating counterfactual examples—such as benign lesions with rulers—the model effectively decoupled the artifact from the diagnosis.

Comparison of source and augmented skin lesion images. MaskMedPaint generates counterfactual examples (e.g., benign lesions with rulers) to break spurious correlations.

Cross-Hospital Generalization

When transferring models between the MIMIC-CXR and NIH ChestXray14 datasets, MaskMedPaint achieved the highest generalization score (0.546 AUROC). The method successfully handled global shifts in contrast and hardware-specific artifacts. Furthermore, the authors found that 2,500 generated images provided a performance boost equivalent to 100 additional real, expert-labeled images from the target domain, representing a major efficiency gain.

Discussion and Conclusion

MaskMedPaint demonstrates that preserving the ROI through hard masking is crucial for medical applications. Unlike standard image-to-image methods, it ensures that diagnostic features remain untouched while the background is updated to match the target domain's "style." This approach does not require prior knowledge of what the spurious feature is; it naturally overwrites source shortcuts by matching the target background.

However, the method's efficacy depends on accurate ROI segmentation. If a spurious feature overlaps with the ROI, it may not be removed. Additionally, while the method mitigates environmental shortcuts, the authors caution that it must be applied carefully regarding sensitive human attributes (like race or gender) where the relationship between appearance and disease is complex. Overall, MaskMedPaint provides a robust, clinician-inspectable tool for improving the safety and generalizability of medical AI.

Summary updated

BibTeX
@misc{jin2024maskmedpaint,
  author = {Qixuan Jin and Walter Gerych and Marzyeh Ghassemi},
  title = {{MaskMedPaint: Masked Medical Image Inpainting with Diffusion Models for Mitigation of Spurious Correlations}},
  year = {2024},
  eprint = {2411.10686},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.10686},
}
Figure