Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery

Thomas SchleglPhilipp SeeböckSebastian M. WaldsteinUrsula Schmidt-ErfurthGeorg Langs

article2017IPMI2,548 citationsBest Paper Award

Introduces AnoGAN, a deep generative adversarial framework that detects and localizes pathological markers in medical images without labeled disease data by mapping unseen scans against a learned distribution of healthy anatomy.

Listen

The article addresses the challenge of identifying disease markers in medical images such as retinal optical coherence tomography scans. Current methods rely on large annotated datasets of known markers, which restricts discovery of new indicators and demands high labeling effort. This limits the ability to exploit rich imaging data for diagnosis, progression monitoring, and treatment decisions.

The work set out to evaluate whether unsupervised learning with generative adversarial networks could model normal anatomical variability and flag anomalies as candidate markers without any labeled pathology examples.

Researchers trained a deep convolutional generative adversarial network on one million image patches extracted from 270 volumes of healthy retinas. They developed a mapping procedure from image space to the latent space that combines a residual loss and a discrimination loss based on intermediate discriminator features. They tested the resulting anomaly score on 8192 patches from 20 additional volumes, including both healthy cases and cases with retinal fluid.

The model generated realistic images of normal anatomy and produced an area under the ROC curve of 0.89 for image-level anomaly detection. It correctly identified regions of retinal fluid and also flagged hyperreflective foci never seen during training. The proposed discrimination loss improved performance over a reference approach, while the residual score alone already yielded strong results. An adversarial convolutional autoencoder performed noticeably worse.

These findings indicate that the method can surface both known and previously unannotated anomalies at scale, supporting data-driven marker discovery and reducing dependence on exhaustive manual annotation. The approach shows potential to accelerate identification of new imaging indicators for disease monitoring.

Further work should include clinical validation of newly discovered anomalies and testing on additional imaging modalities or disease types. A pilot study on larger unlabeled cohorts would help confirm generalizability before routine deployment.

The evaluation used only a modest number of test volumes and focused quantitative metrics on known fluid regions, so performance on entirely novel anomalies remains uncertain. Results are encouraging but should be interpreted with caution until larger-scale confirmation is available.

arXiv: 1703.05921
  • Paper: Generative Adversarial Networks, Ian J. Goodfellow et al. (2014). It introduces the foundational generative adversarial network (GAN) framework, which forms the core architecture that the source adapts for unsupervised anomaly detection.
  • Paper: Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks, Alec Radford et al. (2016). It establishes the deep convolutional GAN (DCGAN) architecture used directly by the source to model healthy anatomical variability.
  • Paper: Autoencoding beyond pixels using a learned similarity metric, Anders Boesen Lindbo Larsen et al. (2015). It develops the concept of using intermediate discriminator feature representations as perceptual similarity metrics, inspiring the discriminator-based loss used in the source's anomaly scoring.
  • Paper: Adversarial Autoencoders, Alireza Makhzani et al. (2015). It introduces adversarial autoencoders, establishing the adversarial reconstruction baseline against which the source compares its latent-space mapping GAN approach.
Cover for Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery

Abstract

Obtaining models that capture imaging markers relevant for disease progression and treatment monitoring is challenging. Models are typically based on large amounts of data with annotated examples of known markers aiming at automating detection. High annotation effort and the limitation to a vocabulary of known markers limit the power of such approaches. Here, we perform unsupervised learning to identify anomalies in imaging data as candidates for markers. We propose AnoGAN, a deep convolutional generative adversarial network to learn a manifold of normal anatomical variability, accompanying a novel anomaly scoring scheme based on the mapping from image space to a latent space. Applied to new data, the model labels anomalies, and scores image patches indicating their fit into the learned distribution. Results on optical coherence tomography images of the retina demonstrate that the approach correctly identifies anomalous images, such as images containing retinal fluid or hyperreflective foci.

Table of Contents

  • 1 Introduction
  • 2 Generative Adversarial Representation Learning to Identify Anomalies
  • 2.1 Unsupervised Manifold Learning of Normal Anatomical Variability
  • 2.2 Mapping new Images to the Latent Space
  • Residual Loss
  • Discrimination Loss
  • An improved discrimination loss based on feature matching
  • 2.3 Detection of Anomalies
  • 3 Experiments
  • 3.1 Results
  • 4 Conclusion
  • References

Knowls

  1. Knowl 1 — AnoGAN Framework for Unsupervised Anomaly Detection

    model/method

    The AnoGAN framework utilizes unsupervised generative adversarial representation learning to model the distribution of normal anatomical appearance and detect anomalies in unseen medical images. A deep convolutional generative adversarial network (DCGAN) is trained exclusively on healthy image patches xX\mathbf{x} \in \mathcal{X}, where a generator GG learns a mapping G(z)G(\mathbf{z}) from a latent space Z\mathcal{Z} (sampled from uniform noise zpz\mathbf{z} \sim p_z) to the image manifold of healthy anatomy, while a discriminator DD is trained to distinguish generated samples G(z)G(\mathbf{z}) from real healthy samples x\mathbf{x}. The network parameters are optimized via a two-player minimax game with value function:

    minGmaxDV(D,G)=Expdata(x)[logD(x)]+Ezpz(z)[log(1D(G(z)))]\min_G \max_D V(D, G) = \mathbb{E}_{\mathbf{x} \sim p_{\text{data}}(\mathbf{x})}[\log D(\mathbf{x})] + \mathbb{E}_{\mathbf{z} \sim p_z(\mathbf{z})}[\log(1 - D(G(\mathbf{z})))]

    After training on healthy data, the model parameters of GG and DD are frozen. To evaluate an unseen query image x\mathbf{x}, the framework finds the point zΓZ\mathbf{z}_\Gamma \in \mathcal{Z} whose generated image G(zΓ)G(\mathbf{z}_\Gamma) is closest to x\mathbf{x} in both pixel space and discriminator feature space via backpropagation in latent space. When presented with an anomalous image containing pathological alterations, the generator cannot reconstruct the anomalous features because they are absent from the learned manifold of healthy variability, resulting in high reconstruction discrepancy and high anomaly scores.

  2. Knowl 2 — Latent Space Mapping via Feature-Matching Backpropagation

    algorithm

    To invert the trained generator and map an arbitrary query image x\mathbf{x} to its optimal latent representation zΓ\mathbf{z}_\Gamma, an iterative optimization procedure is performed directly on the latent coefficients z\mathbf{z} using backpropagation while keeping generator GG and discriminator DD weights fixed.

    Input: Query image x\mathbf{x}, trained generator GG, trained discriminator feature extractor f()f(\cdot), trade-off weight λ\lambda, step count Γ\Gamma, learning rate η\eta
    Output: Optimal latent representation zΓ\mathbf{z}_\Gamma, generated closest healthy image G(zΓ)G(\mathbf{z}_\Gamma)
    Initialize z1U(1,1)\mathbf{z}_1 \sim \mathcal{U}(-1, 1)
    for γ=1\gamma = 1 to Γ1\Gamma - 1 do
        Generate candidate image x^γ=G(zγ)\hat{\mathbf{x}}_\gamma = G(\mathbf{z}_\gamma)
        Compute residual loss LR(zγ)=xx^γ\mathcal{L}_R(\mathbf{z}_\gamma) = \sum |\mathbf{x} - \hat{\mathbf{x}}_\gamma|
        Compute discrimination loss LD(zγ)=f(x)f(x^γ)\mathcal{L}_D(\mathbf{z}_\gamma) = \sum |f(\mathbf{x}) - f(\hat{\mathbf{x}}_\gamma)|
        Compute total loss L(zγ)=(1λ)LR(zγ)+λLD(zγ)\mathcal{L}(\mathbf{z}_\gamma) = (1 - \lambda) \cdot \mathcal{L}_R(\mathbf{z}_\gamma) + \lambda \cdot \mathcal{L}_D(\mathbf{z}_\gamma)
        Compute gradient gγ=zγL(zγ)g_\gamma = \nabla_{\mathbf{z}_\gamma} \mathcal{L}(\mathbf{z}_\gamma)
        Update latent vector zγ+1=zγηgγ\mathbf{z}_{\gamma+1} = \mathbf{z}_\gamma - \eta \cdot g_\gamma
    end for
    Return zΓ\mathbf{z}_\Gamma and G(zΓ)G(\mathbf{z}_\Gamma)

    The mapping optimization updates the latent coordinates z\mathbf{z} across Γ=500\Gamma = 500 iterations using gradient descent, guiding the latent vector toward the most visually and statistically consistent healthy reconstruction of x\mathbf{x}.

  3. Knowl 3 — AnoGAN Latent Mapping Loss and Anomaly Scoring Functions

    equation

    The latent mapping loss L(zγ)\mathcal{L}(\mathbf{z}_\gamma) and the resulting image-level anomaly score A(x)A(\mathbf{x}) combine a residual term measuring pixel visual dissimilarity with a feature-matching discrimination term measuring statistical representation discrepancy.

    The residual loss is defined as the L1L_1 pixel difference between the query image x\mathbf{x} and the generated image G(zγ)G(\mathbf{z}_\gamma): LR(zγ)=xG(zγ)\mathcal{L}_R(\mathbf{z}_\gamma) = \sum |\mathbf{x} - G(\mathbf{z}_\gamma)|

    The discrimination loss is computed from the output of an intermediate convolutional layer f()f(\cdot) of the discriminator DD acting as a feature extractor, forcing generated images to match the statistical feature activations of real healthy images: LD(zγ)=f(x)f(G(zγ))\mathcal{L}_D(\mathbf{z}_\gamma) = \sum |f(\mathbf{x}) - f(G(\mathbf{z}_\gamma))|

    The overall mapping loss at step γ\gamma is a convex combination weighted by hyperparameter λ[0,1]\lambda \in [0, 1]: L(zγ)=(1λ)LR(zγ)+λLD(zγ)\mathcal{L}(\mathbf{z}_\gamma) = (1 - \lambda) \cdot \mathcal{L}_R(\mathbf{z}_\gamma) + \lambda \cdot \mathcal{L}_D(\mathbf{z}_\gamma)

    Upon completing Γ\Gamma optimization steps, the image-level anomaly score A(x)A(\mathbf{x}) is computed using the final residual score R(x)=LR(zΓ)R(\mathbf{x}) = \mathcal{L}_R(\mathbf{z}_\Gamma) and discrimination score D(x)=LD(zΓ)D(\mathbf{x}) = \mathcal{L}_D(\mathbf{z}_\Gamma): A(x)=(1λ)R(x)+λD(x)A(\mathbf{x}) = (1 - \lambda) \cdot R(\mathbf{x}) + \lambda \cdot D(\mathbf{x})

    A large anomaly score A(x)A(\mathbf{x}) indicates that the query image x\mathbf{x} cannot be accurately modeled as healthy anatomy on the learned manifold.

  4. Knowl 4 — Pixel-Level Anomaly Segmentation via Residual Images

    model/method

    In addition to computing an image-level anomaly score, the AnoGAN model performs localized pixel-level anomaly segmentation by computing a residual image xR\mathbf{x}_R:

    xR=xG(zΓ)\mathbf{x}_R = |\mathbf{x} - G(\mathbf{z}_\Gamma)|

    where x\mathbf{x} is the input query image and G(zΓ)G(\mathbf{z}_\Gamma) is the image reconstructed from the optimal latent vector zΓ\mathbf{z}_\Gamma found after Γ\Gamma backpropagation iterations. Because the generator GG has only been trained on healthy anatomical structures, it can only synthesize healthy representations that reside on the learned normal manifold X\mathcal{X}. In regions where the input x\mathbf{x} exhibits non-healthy structures (such as retinal fluid cysts or hyperreflective foci), G(zΓ)G(\mathbf{z}_\Gamma) reconstructs the corresponding healthy tissue morphology. The absolute difference across pixels in xR\mathbf{x}_R isolates and highlights anomalous lesions without requiring prior pixel-level annotations during training.

  5. Knowl 5 — Retinal SD-OCT Dataset and Preprocessing Protocol

    experimental setup

    The AnoGAN framework was evaluated on clinical high-resolution spectral-domain optical coherence tomography (SD-OCT) volumes of the retina. Each volume contains 49 B-scans (zx-plane image slices) with dimensions 496×512×49496 \times 512 \times 49 voxels in the zz-, xx-, and yy-directions, respectively.

    Preprocessing steps:

    1. Gray-value intensities were normalized to the range [1,1][-1, 1].
    2. The OCT volumes were resized in the xx-direction to a spatial scale of 22μm22\,\mu\text{m}, yielding approximately 256 columns per B-scan.
    3. The retinal slab was segmented between top and bottom intraretinal boundaries using an automated layer segmentation algorithm and flattened to remove variations in anatomical curvature, orientation, and thickness.
    4. From the preprocessed healthy volumes of 270 subjects (selected based on the absence of fluid), 1,000,000 2D patches of size 64×6464 \times 64 pixels were randomly extracted for unsupervised GAN training.
    5. The test set comprised 8,192 image patches (64×6464 \times 64 pixels) extracted from 10 unseen healthy cases and 10 unseen pathological cases exhibiting intraretinal fluid. Voxel-wise annotations of fluid from clinical retina experts served as ground truth for statistical evaluation, where a patch was labeled anomalous if it contained at least one pixel of annotated fluid.
  6. Knowl 6 — AnoGAN DCGAN Architecture and Optimization Configuration

    experimental setup

    The GAN used in AnoGAN adapts the Deep Convolutional GAN (DCGAN) architecture for single-channel grayscale 64×6464 \times 64 pixel inputs:

    • Generator GG: Composed of 4 fractionally-strided convolution layers with 5×55 \times 5 filters and feature map depths of 512, 256, 128, and 64, followed by an output layer producing a 64×6464 \times 64 grayscale patch.
    • Discriminator DD: Composed of 4 standard convolution layers with 5×55 \times 5 filters and matching intermediate channel depths of 64, 128, 256, and 512, mapped to a scalar prediction. The intermediate feature map f()f(\cdot) for feature-matching loss is extracted from the last convolutional layer before the final scalar output.
    • Training Optimization: Trained for 20 epochs using the Adam stochastic optimizer.
    • Latent Mapping Optimization: For testing query images, Γ=500\Gamma = 500 backpropagation steps were run per image patch.
    • Loss Weighting: The trade-off parameter between residual and discriminator feature losses was set to λ=0.1\lambda = 0.1 for all mapping and scoring computations.
  7. Knowl 7 — Performance Comparison Across Anomaly Detection Models

    data/table

    The quantitative detection performance of AnoGAN was evaluated on the SD-OCT test set against an adversarial convolutional autoencoder (aCAE), direct discriminator classification output (PDP_D), and a reference GAN mapping baseline (GANR\text{GAN}_R) that uses cross-entropy discriminator classification loss LD^(zγ)=σ(D(G(zγ)),1)\mathcal{L}_{\hat{D}}(\mathbf{z}_\gamma) = \sigma(D(G(\mathbf{z}_\gamma)), 1) instead of feature matching.

    Method Precision Recall Sensitivity Specificity AUC
    aCAE 0.7005 0.7009 0.7011 0.6659 0.73
    PDP_D 0.8471 0.5119 0.5124 0.8970 0.72
    GANR\text{GAN}_R 0.8482 0.7631 0.7634 0.8477 0.88
    AnoGAN 0.8834 0.7277 0.7279 0.8928 0.89

    Metrics were computed at the optimal cut-off point on the receiver operating characteristic (ROC) curves identified using Youden's index. AnoGAN achieved the highest AUC (0.89) and precision (0.8834). While the autoencoder-based model (aCAE) provided direct latent mappings, it demonstrated lower performance (AUC 0.73) due to over-adapting to anomalous images. The feature-matching discrimination score in AnoGAN (D(x)D(\mathbf{x}), AUC 0.74) also substantially outperformed the scalar cross-entropy discrimination score (D^(x)\hat{D}(\mathbf{x}), AUC 0.50), demonstrating the advantage of intermediate discriminator feature matching.

  8. Knowl 8 — Unsupervised Discovery of Unannotated Retinal Pathologies

    empirical result

    When evaluated on clinical SD-OCT test cases, AnoGAN accurately detected both targeted fluid anomalies and previously unannotated disease markers. While training was conducted exclusively on fluid-free healthy scans and quantitative evaluations used expert annotations of retinal fluid, the residual image xRx_R and anomaly score A(x)A(\mathbf{x}) correctly localized and flagged other distinct retinal lesions, specifically hyperreflective foci (HRF). Because HRF represent pathological structural deviations absent from the learned manifold of healthy retinal anatomy, the generator produced healthy tissue in their place, creating localized residual peaks. This demonstrates that unsupervised manifold learning with GANs can discover novel or unannotated biomarker candidates without task-specific supervisory labels.

Coverage note — None was omitted; all contributed methodology, algorithm steps, loss formulations, architectural details, dataset configurations, and quantitative/qualitative results have been captured.

References

  1. 1.Del Giorno, A., Bagnell, J.A., Hebert, M.: A discriminative framework for anomaly detection in large videos. In: ECCV, Springer (2016) 334–349
  2. 2.Matteoli, S., Diani, M., Theiler, J.: An overview of background modeling for detection of targets and anomalies in hyperspectral remotely sensed imagery. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing 7(6) (2014) 2317–2336
  3. 3.Carrera, D., Boracchi, G., Foi, A., Wohlberg, B.: Detecting anomalous structures by convolutional sparse models. In: 2015 International Joint Conference on Neural Networks (IJCNN), IEEE (2015) 1–8
  4. 4.Erfani, S.M., Rajasegarar, S., Karunasekera, S., Leckie, C.: High-dimensional and large-scale anomaly detection using a linear one-class SVM with deep learning. Pattern Recognition 58 (2016) 121–134
  5. 5.Pimentel, M.A., Clifton, D.A., Clifton, L., Tarassenko, L.: A review of novelty detection. Signal Processing 99 (2014) 215–249
  6. 6.Venhuizen, F.G., van Ginneken, B., Bloemen, B., van Grinsven, M.J., Philipsen, R., Hoyng, C., Theelen, T., S´anchez, C.I.: Automated age-related macular degen- eration classification in oct using unsupervised feature learning. In: SPIE Medical Imaging, International Society for Optics and Photonics (2015) 94141I–94141I
  7. 7.Schlegl, T., Waldstein, S.M., Vogl, W.D., Schmidt-Erfurth, U., Langs, G.: Predict- ing semantic descriptions from medical images with convolutional neural networks. In: International Conference on Information Processing in Medical Imaging. Vol- ume 24., Springer (2015) 437–448
  8. 8.Seeb¨ock, P., Waldstein, S., Klimscha, S., Gerendas, B.S., Donner, R., Schlegl, T., Schmidt-Erfurth, U., Langs, G.: Identifying and categorizing anomalies in retinal imaging data. NIPS 2016 MLHC workshop. preprint arXiv:1612.00686 (2016)
  9. 9.Goodfellow, I., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., Bengio, Y.: Generative adversarial nets. In: Advances in Neural Information Processing Systems. (2014) 2672–2680
  10. 10.Denton, E.L., Chintala, S., Fergus, R., et al.: Deep generative image models using a laplacian pyramid of adversarial networks. In: Advances in neural information processing systems. (2015) 1486–1494
  11. 11.Donahue, J., Kr¨ahenb¨uhl, P., Darrell, T.: Adversarial feature learning. arXiv:1605.09782 (2016)
  12. 12.Radford, A., Metz, L., Chintala, S.: Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv:1511.06434 (2015)
  13. 13.Yeh, R., Chen, C., Lim, T.Y., Hasegawa-Johnson, M., Do, M.N.: Semantic image inpainting with perceptual and contextual losses. arXiv:1607.07539 (2016)
  14. 14.Salimans, T., Goodfellow, I., Zaremba, W., Cheung, V., Radford, A., Chen, X.: Improved techniques for training GANs. In: Advances in Neural Information Pro- cessing Systems. (2016) 2226–2234
  15. 15.Garvin, M.K., Abr`amoff, M.D., Wu, X., Russell, S.R., Burns, T.L., Sonka, M.: Automated 3-D intraretinal layer segmentation of macular spectral-domain optical coherence tomography images. Transactions on Medical Imaging, IEEE 28(9) (2009) 1436–1447
  16. 16.Pathak, D., Kr¨ahenb¨uhl, P., Donahue, J., Darrell, T., Efros, A.A.: Context en- coders: Feature learning by inpainting. CoRR abs/1604.07379 (2016)
  17. 17.Kingma, D., Ba, J.: Adam: A method for stochastic optimization. arXiv:1412.6980 (2014)
  18. 18.Abadi, M., Agarwal, A., Barham, P., Brevdo, E., Chen, Z., Citro, C., Corrado, G.S., Davis, A., Dean, J., Devin, M., Ghemawat, S., Goodfellow, I., Harp, A., Irving, G., Isard, M., Jia, Y., Jozefowicz, R., Kaiser, L., Kudlur, M., Levenberg, J., Man´e, D., Monga, R., Moore, S., Murray, D., Olah, C., Schuster, M., Shlens, J., Steiner, B., Sutskever, I., Talwar, K., Tucker, P., Vanhoucke, V., Vasudevan, V., Vi´egas, F., Vinyals, O., Warden, P., Wattenberg, M., Wicke, M., Yu, Y., Zheng, X.: TensorFlow: Large-scale machine learning on heterogeneous systems (2015) Software available from tensorflow.org.

Citation

MLA
Schlegl, T., et al. “Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery”. Lecture Notes in Computer Science, Springer International Publishing, 2017, pp. 146–57, https://doi.org/10.1007/978-3-319-59050-9_12.
APA
Schlegl, T., Seeböck, P., Waldstein, S. M., Schmidt-Erfurth, U., & Langs, G. (2017). Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery. In Lecture Notes in Computer Science (pp. 146–157). Springer International Publishing. https://doi.org/10.1007/978-3-319-59050-9_12
Chicago
Schlegl, T., P. Seeböck, S. M. Waldstein, U. Schmidt-Erfurth, and G. Langs. 2017. “Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery”. In Lecture Notes in Computer Science. Springer International Publishing. https://doi.org/10.1007/978-3-319-59050-9_12.
Harvard
Schlegl, T. et al. (2017) “Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery”, Lecture Notes in Computer Science. Springer International Publishing, pp. 146–157. Available at: https://doi.org/10.1007/978-3-319-59050-9_12.
Vancouver
1. Schlegl T, Seeböck P, Waldstein SM, Schmidt-Erfurth U, Langs G (2017) Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery. In: Lecture Notes in Computer Science. Springer International Publishing, pp 146–157

BibTeX

@inbook{Schlegl_2017, title={Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery}, ISBN={9783319590509}, ISSN={1611-3349}, url={http://dx.doi.org/10.1007/978-3-319-59050-9_12}, DOI={10.1007/978-3-319-59050-9_12}, booktitle={Information Processing in Medical Imaging}, publisher={Springer International Publishing}, author={Schlegl, Thomas and Seeböck, Philipp and Waldstein, Sebastian M. and Schmidt-Erfurth, Ursula and Langs, Georg}, year={2017}, pages={146–157} }
Metadata:Crossref

Access the Paper

This paper is available from its original source. Click below to access the PDF.

Open PDF