Disentangling representations of retinal images with generative models

Sarah Müller, Lisa Margret Koch, Hendrik Lensch, Philipp Berens · DOI · OpenReview

Introduction

In medical imaging, "shortcut learning" presents a significant challenge to the reliability of artificial intelligence. A common scenario involves datasets where specific technical factors, such as camera brand, are confounded with patient demographics. For instance, if one hospital uses a particular camera for a predominantly Latin American population while another uses a different brand for a Caucasian population, a standard deep learning model might erroneously identify ethnicity based on camera-specific color hues rather than biological markers.

This research addresses the challenge of disentanglement: separating intrinsic patient features from extrinsic technical factors like camera type, illumination, or image quality. Successful disentanglement enables the development of more robust diagnostic tools and the generation of realistic, controllable synthetic medical data.

Methodology

The authors propose a framework based on StyleGAN2, extended with GAN-inversion to encode real images into a latent space. The approach is grounded in a Causal Directed Acyclic Graph (DAG) that identifies "Camera" and "Patient Attribute" as distinct causal paths contributing to the final fundus image.

Core Innovations

  1. Subspace Learning: The latent space is partitioned into dedicated subspaces for patient attributes (e.g., age or ethnicity), camera type, and a general "style" space for remaining variance.
  2. Distance Correlation (dCor) Loss: To ensure independence between these subspaces, the model employs a dCor loss. Unlike standard linear correlation, dCor captures both linear and non-linear dependencies. Minimizing dCor prevents information leakage (e.g., camera artifacts appearing in the age subspace).
  3. Joint Optimization: The model is trained end-to-end to generate high-quality images while simultaneously classifying attributes within their respective subspaces and maintaining statistical independence.
Overview of the causal framework, model architecture, and disentanglement results.

Datasets

The study utilizes the EyePACS dataset, a large-scale collection of retinal fundus images from a telemedicine screening program. The final filtered dataset consists of approximately 75,000 healthy images from over 24,000 patients. Metadata includes labels for age, ethnicity, and 14 different camera models (e.g., Canon, Topcon, Optovue). Images were preprocessed by cropping to the fundus circle, resizing to 256x256, and standardizing the orientation of the optic disc.

Dataset distribution showing age, ethnicity, and camera model frequencies alongside sample retinal images.

Experimental Results

The model demonstrates successful "latent surgery," allowing for the manipulation of specific attributes without altering underlying structures. For example, swapping the "age subspace" of a young patient with that of an older patient results in biologically plausible changes, such as the loss of the "inner limiting membrane glint."

Quantitative Performance

  • Disentanglement: Without dCor loss, camera information was predictable from the age subspace at 28% above chance. With the loss, this leakage dropped to ~7-8%, while age classification accuracy remained high.
  • Image Fidelity: The model achieved a Frechet Inception Distance (FID) of 11–13, indicating that disentanglement constraints did not compromise visual quality.
  • Attribute Control: Swapping ethnicity subspaces successfully modified fundus pigmentation, a key biological marker, while preserving other anatomical details.

Discussion and Limitations

While the model produces highly realistic images, it still faces challenges in reconstructing the finest retinal vessels ("twig" vessels) essential for some clinical diagnoses. Additionally, inherent correlations in real-world data—such as specific ethnicities being tied to certain camera types in the EyePACS dataset—make complete disentanglement difficult. The dCor loss is also computationally intensive, posing scaling challenges.

Future work aims to extend this framework to disease features (e.g., Diabetic Retinopathy) to generate counterfactual images, visualizing how a specific patient's retina might appear as a disease progresses or improves.

Summary updated

BibTeX
@article{muller2025disentangling,
  author = {Sarah Müller and Lisa Margret Koch and Hendrik Lensch and Philipp Berens},
  title = {{Disentangling representations of retinal images with generative models}},
  journal = {Medical Image Analysis},
  year = {2025},
  doi = {10.1016/j.media.2025.103628},
}
Figure