Source-linked AI summary

Generating Medical Image Counterfactuals using Causal Explanations

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

arXiv:2609.02697v1cs.CV

TL;DR

Medical-image counterfactuals are often generated by auxiliary models, making it difficult to distinguish classifier evidence from generator priors. The paper instead constructs deterministic counterfactuals directly from classifier-derived causal explanations, and reports prediction changes with smaller image modifications than generative baselines.

  • Problem

    Auxiliary generative models can make counterfactual explanations difficult to attribute to the classifier rather than the generator, while medical imaging also faces limited transparency.

  • Method

    The framework retrieves classifier-derived causal explanations and transfers their causal pixel values to construct targeted counterfactual perturbations without training an additional generative model.

  • Results

    The method changes classifier predictions with substantially smaller changes than state-of-the-art generative models, producing counterfactuals closer to the original images.

  • Takeaways & Limitations

    Classifier-specific causal counterfactuals provide a more direct view of the decision boundary and support model auditing through localized, traceable perturbations.

  • Takeaways & Limitations

    Performance depends on the diversity of the reference set and its explanations; underrepresented pathological patterns or imaging conditions can limit available perturbations.

Abstract

from arXiv · show

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

Counterfactual explanations expose what visual evidence would need to change for a medical-image classifier to alter its prediction. This paper replaces auxiliary generative models with deterministic, classifier-derived causal evidence, enabling localized and traceable edits.

  • Motivation: Counterfactual explanations ask how an input image must change for a classifier to assign a different class.They can probe decision boundaries and reveal model failure modes, unlike attribution methods that identify evidence for an existing classification.
  • Motivation: Generative counterfactual methods can confound classifier behavior with the image priors and optimization artifacts of auxiliary models.They are also typically data-intensive and sensitive to training choices.
  • Approach: The proposed framework retrieves causal explanations from nearby positively classified images and partially transfers their causal pixel values to construct counterfactuals.Its search space is constrained by evidence already identified by the classifier rather than by a learned image prior.
  • Advantages: The method requires no additional trained model, is deterministic, and supports local edits restricted to user-specified regions of interest.These properties isolate the inspected classifier and allow users to test whether changing a specific anatomical structure alters its prediction.
  • Contribution: The framework reframes counterfactual generation as causal retrieval and makes each perturbation traceable to a previously observed causal contribution.The resulting images provide a more direct view of the classifier’s decision boundary than auxiliary generative explanations.

2. Background

The background treats a classifier as a causal model over image pixels and defines explanations through masking-based sufficiency, necessity, and minimality. ReX operationalizes these ideas by testing superpixel mutants and extracting ranked causal pixel sets.

  • 2.1. Causal Explanations: The causal formulation models image pixels as variables that jointly cause the classifier’s output through the classifier’s implemented mechanism.This permits explanations grounded in actual-causality concepts.
  • 2.1. Causal Explanations: Sufficient explanations are minimal pixel subsets whose unmasked values preserve the original classification against a masking baseline.They are called Minimal Sufficient Pixel Sets, or MSPS.
  • 2.1. Causal Explanations: Complete explanations are minimal sets that are both sufficient against the baseline and necessary because removing them changes the classification.They are generally larger than sufficient explanations and contain more information.
  • 2.2. ReX: ReX generates causal explanations by masking combinations of four image superpixels, testing them against the model, and refining combinations that preserve the required classification.Responsibility is distributed across superpixels according to their causal influence.
  • 2.2. ReX: ReX repeats random partitions to rank pixels by responsibility and greedily extracts a minimal sufficient pixel set.The initial explanation search uses O(2snN) model calls, with default partition size s = 4.
  • 2.2. ReX: ReX also computes complete explanations, which are generally larger than sufficient explanations because they encode both sufficiency and necessity.The study evaluates both explanation types.

3. Causal Explanations and Counterfactual Generation

The method constructs counterfactuals by transferring causal evidence from nearby positively classified images into user-selected regions of a target image, then querying the classifier iteratively. It uses sufficient or complete explanations without a second learned generative representation.

  • Reference retrieval: For a negatively classified target, the algorithm retrieves the closest positive image and its explanation, then extracts the explanation’s pixel values.The positive image is selected using a distance function, and its explanation is represented as a binary mask.
  • Counterfactual search: The main loop moves masked pixel values toward reference causal values, enlarging the mask when needed and continuing while the distance remains below the threshold.An optional smoothing step reduces hard lines or unnatural shapes after a successful mask is found.
  • Method: The approach reuses causal evidence extracted from the classifier rather than a separately learned generative representation.Causal explanations are precomputed for positive reference images and used to construct candidate perturbations.
  • Controlled perturbations: A user-defined binary mask restricts which target-image pixels can be perturbed, with the mutation location selectable by the user or derived from the reference abnormality.The experiments use rectangular masks and the reference explanation’s abnormality centroid, while clinician-selected locations are also supported.
  • Termination and complexity: The algorithm terminates over finite masks and value arrays, returning an empty set if no allowed perturbation changes the classification.Its overall computational complexity is O(|M| × |V|), with precomputed explanations reused for the trained classifier.

4. Evaluation

The evaluation compares sufficient and complete causal explanations with naive, GAN-based, and diffusion-based counterfactuals on brain MRI and skin-lesion datasets. Causal approaches generally preserve the original image distribution better, while complete explanations achieve the strongest low-distance success rates.

  • Evaluation setup: The evaluation measures correctness and similarity across brain MRI and skin-lesion case studies, using L2 during generation and multiple metrics during assessment.Distances include L1, L2, SSIM, and LPIPS; the evaluation includes 560 MRI images and 277 skin-lesion images predicted negative by the classifiers.
  • Comparison: The comparison includes sufficient explanations, complete explanations, naive sufficient and complete explanations, GANterfactual, and MoPaDi.All methods received the same training data, although generative methods trained on the full set while causal methods used positively classified samples for reference explanations.
  • Brain MRI results: 85% success was achieved by complete explanations on brain MRI at distance thresholds of 0.25 in LPIPS and 0.2 in SSIM.Complete explanations outperformed other approaches at lower distance thresholds, while GAN and diffusion counterfactuals were substantially farther from their originals.
  • Skin-lesion results: 67% success was achieved by complete explanations on skin lesions at distance thresholds of 0.48 in LPIPS and 0.21 in SSIM.At higher thresholds, naive complete explanations, GAN, and diffusion methods obtained higher rates, driven by larger transformations that reduced practical usefulness.
  • Distributional analysis: All causal approaches preserved the original pairwise distance distribution, whereas GAN counterfactuals became narrowly clustered and dissimilar from the original data distribution.The distribution comparison uses the same intersection of images for which every method produced a valid counterfactual.
  • Limitations: The method depends on a diverse reference set and corresponding explanations, because underrepresented pathological or imaging patterns can limit available perturbations.This dependence is described as less restrictive than the data requirements of generative models.

5. Related Work

Counterfactual-generation research has primarily used generative models for image-to-image translation, while this paper instead constructs counterfactuals directly from classifier-derived causal evidence.

  • Generative counterfactual methods: Most image counterfactual methods use generative models, including CycleGANs, diffusion models, and dedicated medical-image generators.These approaches synthesize alternative images assigned a different classifier label.
  • This work: Figure 4 compares original healthy samples, the proposed method, naive patching, and diffusion-model outputs across MRI and skin-lesion datasets.Naive patching replaces large image regions, while diffusion outputs can depict different samples or nonlocal changes.
  • Retrieval-based counterfactual methods: The closest retrieval-based method copies regions from a distractor image, but selects transferred content through optimization rather than known causal responsibility.Its successful perturbations therefore remain difficult to explain mechanistically.
  • This work: This framework constructs counterfactuals from causal explanations extracted from the classifier, rather than learning latent representations or searching for effective pixel substitutions.Causal explanations serve as the primary representation from which counterfactuals are constructed.

6. Conclusion

The paper generates counterfactual medical images from the classifier’s perspective, changing healthy images toward diseased predictions with smaller image changes than generative baselines. It leaves clinician usefulness for future evaluation.

  • Conclusion: The method computes the information change needed to move healthy images to diseased classifications using only the classifier.It provides what-if images for examining model failure modes.
  • Conclusion: The method induces classification changes with far smaller image changes than state-of-the-art generative models, producing counterfactuals closer to the original image.This conclusion concerns the relative image distance of the generated counterfactuals.
  • Conclusion: Future work will assess whether clinicians find the counterfactual images useful for auditing models.Clinical usefulness has not yet been established in the supplied conclusion.
Loading 2609.02697v1…