Counterfactual Explainability with CycleGAN and CCAS for Retinal Disease

CounterFundus uses CycleGAN and a novel CCAS metric to provide clinically-grounded counterfactual explanations for retinal disease classification from fundus

sábado, 25 de julio de 2026 • 3 min read • Q2BSTUDIO Team

Marco contrafactual con alineación clasificador-contrafactual

Artificial intelligence applied to the diagnosis of retinal diseases has shown enormous potential, but its integration into clinical practice faces a fundamental challenge: the lack of transparency in model decisions. Ophthalmologists need to understand why a system classifies an image as abnormal, and that explanation must be aligned with clinically relevant anatomical regions. In this context, the CounterFundus framework proposes an innovative solution that combines cycle-consistent generative adversarial networks (CycleGAN) with an EfficientNet-B5 classifier to generate counterfactual explanations. Instead of merely displaying post-hoc heatmaps, this approach translates a pathological image into its estimated healthy counterpart, producing a difference map that highlights exactly where disease-associated changes are located. The resulting visualization is intuitive: the clinician sees the original image, the generated healthy image, and the difference map, facilitating interpretation.

To ensure that these explanations are reliable, CounterFundus introduces the Counterfactual-Classifier Alignment Score (CCAS), a composite metric that evaluates the spatial agreement between the counterfactual difference map and the regions the classifier considers relevant. CCAS integrates Spearman correlation, binary IoU, and pointing accuracy into a single indicator. This approach validates that explanations are not only visually plausible but actually reflect the evidence used by the classifier. Experiments with EigenCAM confirm that CounterFundus counterfactual maps maintain high spatial consistency across all CCAS dimensions. Furthermore, ablation studies show that using CCAS-filtered counterfactual augmentation improves downstream classification performance, establishing CounterFundus as a clinically grounded explainable AI (XAI) framework.

Implementing a system like CounterFundus requires a robust and scalable software architecture. From image acquisition to counterfactual generation and metric calculation, each stage demands careful development. CycleGAN networks, for instance, are known for training instability and mode collapse; overcoming these challenges requires careful design of loss functions, generator and discriminator architectures, and iterative training strategies. This is where expertise in custom software development becomes invaluable. Q2BSTUDIO, as a software and technology development company, offers services that allow building customized pipelines for specific medical problems. For example, integration with cloud services AWS and Azure provides the GPU computing capacity needed to train generative models and classifiers at scale. Additionally, cybersecurity is a critical aspect: Q2BSTUDIO performs security audits and pentesting to protect sensitive patient data, complying with regulations such as HIPAA or GDPR.

Explainable AI (XAI) goes beyond the core model. Q2BSTUDIO develops AI agents that automate tasks such as image segmentation, report generation, and integration with electronic health records. These agents can work alongside BI dashboards like Power BI, offering real-time visualizations of model performance metrics, diagnostic trends, and alerts. The combination of XAI, cloud, cybersecurity, and BI creates a complete ecosystem for precision medicine. Furthermore, process automation enables the workflow from image capture to diagnosis delivery to be efficient and reproducible. Q2BSTUDIO offers automation services that connect different systems and reduce manual intervention.

In summary, CounterFundus represents a step forward in transparency for deep learning-based diagnoses of retinal diseases. Its counterfactual approach with CycleGAN and the CCAS metric provide visual and quantitative explanations that align model decisions with clinical evidence. However, for this technology to be adopted in real clinical settings, a solid technological infrastructure is necessary. Q2BSTUDIO can help healthcare institutions implement customized solutions, from custom software development to cloud integration, cybersecurity, and AI. If you wish to explore how AI can transform ophthalmic diagnosis, do not hesitate to contact experts who understand both technology and the clinical domain.

For more information on developing explainable AI solutions for your organization, check our artificial intelligence and cloud AWS and Azure services.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.