arXiv:2609.02697cs.CVSep 2026

Manuscript Offprint

arXiv:2609.02697

Generating Medical Image Counterfactuals using Causal Explanations

David A. Kelly, Tom Yaacov, Nathan Blake, Sander Beckers, Hana Chockler

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Deep learning models have achieved impressive performance in medical image diagnosis, yet their deployment in clinical settings remains constrained by limited explainability. Counterfactual images provide one means of auditing model behavior by showing how an image would need to change for a classifier to produce a different prediction. Existing approaches typically generate such explanations using auxiliary models, including generative adversarial networks and diffusion models. While often capable of producing visually realistic images, these methods explain one black-box model using another, making it difficult to separate the classifier's decision-making process from the inductive biases of the generator.

We propose a novel counterfactual-generation framework that requires no generative model. Instead, counterfactuals are constructed directly from causal evidence extracted from the classifier. The resulting approach is deterministic, requires no additional model training, and enables controllable edits within user-specified regions of interest. Experiments on real-world medical imaging datasets demonstrate that the proposed method successfully changes classifier predictions while remaining closer to the original image than generative baselines, providing a more direct and transparent view of the classifier's decision boundary.

1. Introduction

Deep image classifiers achieve strong performance across many medical-imaging tasks, yet their use remains limited by poor generalization, dataset shift, and a lack of transparent explanations [6]. These concerns are not unique to healthcare: they reflect a broader challenge in computer vision, where high-capacity models may produce accurate predictions while relying on features that are difficult for domain experts to inspect. In medical imaging, the cost of such opacity is especially acute. A clinician or model audi-

tor may need to know not only where a classifier attends, but also what visual evidence would have changed its decision.

Counterfactual explanations address this question by asking how an input image would need to change for a classifier to assign it to a different class [28]. In medical imaging, this often takes the form of transforming an image classified as healthy into one classified as diseased. Such 'what-if' images can help users probe the decision boundary of a model and identify its modes of failure. This differs from many post-hoc explainable AI (XAI) methods such as SHAP [20], LIME [25], or REX [10], which identify those features responsible for a given classification. These attribution methods ask which features support the current prediction; counterfactual generation asks what would need to change for the prediction to change. This is not the same as simulating plausible pathological counterfactuals, but rather a model-specific audit. A small non-pathological alteration may induce a class to change to 'disease': such a discrepancy is precisely what the method seeks to expose.

Most existing approaches to image counterfactual generation rely on generative models, including GANs, conditional GANs, and diffusion models [19, 21, 22, 26, 34]. These methods synthesize plausible samples from a target class and have been widely adopted in medical imaging because they can model complex anatomical and pathological variation [26]. However, they introduce a fundamental challenge for explainability: the explanation of one black-box model is produced by another. As a result, it can be difficult to determine whether a counterfactual reflects the classifier's decision boundary, the generative model's image prior, or artifacts of the optimization procedure. Generative approaches are also typically data-intensive and sensitive to training choices, which is problematic in medical imaging where large, well-annotated datasets are often scarce [11]. For model auditing, the most informative counterfactual is not necessarily the most realistic target-class image, but a close image that the classifier itself accepts as belonging to the target class.

In this paper, we introduce a non-generative approach to image counterfactual generation. Instead of learning a separate image-generation process, we directly exploit the classifier's own causal explanations (Section 2.1) to construct targeted counterfactual perturbations. We pre-compute causal explanations for positively classified im-

¹ King's College London, {firstname.lastname}@kcl.ac.uk ² University College London, srekcebrednas@gmail.com

  • Equal contribution. ** This work was supported by the Causality in Healthcare AI (CHAI) Hub [UKRI AI and EPSRC grant EP/Y028856/1].

ages, retrieve explanations from images close to the target instance, and partially transfer the associated causal pixel values to generate candidate counterfactuals. Consequently, the search space is constrained entirely by evidence that the classifier has already identified as causally relevant, rather than by a learned image prior.

To our knowledge, this is the first counterfactual-generation framework that directly reuses causal explanation. Our method offers three advantages for visual model auditing. First, it requires no additional trained models, isolating the behavior of the classifier under inspection and eliminating generator-induced confounding effects. Second, the procedure is deterministic, avoiding the stochasticity common to training and sampling from generative models. Third, perturbations are local and controllable: users can restrict the search to a region of interest and directly test whether modifying a specific anatomical structure is sufficient to alter the classifier's prediction (Figure 1).

Conceptually, our work reframes counterfactual generation as a causal-retrieval problem rather than a generative-modeling problem. Instead of learning how to synthesize target-class images, we identify and transfer causal evidence already used by the classifier when making positive predictions. This produces counterfactuals that are inherently model-specific: every modification can be traced to a previously observed causal explanation. As a result, the generated images provide a more direct view of the classifier's decision boundary and avoid the ambiguity introduced by auxiliary generative models.

Our principle contributions are:

• The first counterfactual framework built directly from causal explanations.

• Counterfactuals are constrained by classifier-derived causal evidence rather than image realism priors.

• Every perturbation is traceable to an identified causal contribution.

• Counterfactual generation becomes a model-auditing procedure rather than an image-synthesis procedure.

The complete code for the evaluation and the implementation are available in [3].

References (30)