Deep Autoencoding Models for Unsupervised Anomaly Segmentation in Brain MR Images

04/12/2018 ∙ by Christoph Baur, et al. ∙ 0

Reliably modeling normality and differentiating abnormal appearances from normal cases is a very appealing approach for detecting pathologies in medical images. A plethora of such unsupervised anomaly detection approaches has been made in the medical domain, based on statistical methods, content-based retrieval, clustering and recently also deep learning. Previous approaches towards deep unsupervised anomaly detection model patches of normal anatomy with variants of Autoencoders or GANs, and detect anomalies either as outliers in the learned feature space or from large reconstruction errors. In contrast to these patch-based approaches, we show that deep spatial autoencoding models can be efficiently used to capture normal anatomical variability of entire 2D brain MR images. A variety of experiments on real MR data containing MS lesions corroborates our hypothesis that we can detect and even delineate anomalies in brain MR images by simply comparing input images to their reconstruction. Results show that constraints on the latent space and adversarial training can further improve the segmentation performance over standard deep representation learning.



There are no comments yet.


page 2

page 5

page 6

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Brain MR images are frequently acquired for detecting and diagnosing pathologies, monitoring disease progression and treatment planning. The manual identification and segmentation of pathologies in brain MR data is a tedious and time-consuming task. In an attempt to aid the detection and delineation of brain lesions arising from Multiple Sclerosis (MS), tumors or ischemias, the medical image analysis community has proposed a great variety of methods. Outstanding levels of performance have been achieved with recent supervised deep learning methods. However, their training requires vast amounts of labeled data which often is not available. Further, these approaches suffer from limited generalization since in general, training data rarely comprises the gamut of all possible pathological appearances [16]. Given the constrained anatomical variability of the healthy brain, an alternative approach is to model the distribution of healthy brains, and both detect and delineate pathologies as deviations from the norm. Here, we formulate the problem of brain lesion detection and delineation as an unsupervised anomaly detection (UAD) task based on state-of-the-art deep representation learning and adversarial training, requiring only a set of normal data and no labels at all. The detection and delineation of pathologies are thereby obtained from a pixel-wise reconstruction error (Fig. 1). To the best of our knowledge, this is the first application of deep convolutional representation learning for UAD in brain MR images which operates on entire MR slices.

Figure 1: The proposed anomaly detection oncept at a glance. A simple subtraction of the reconstructed image from the input reveals lesions in the brain.

Related work

In the medical field, many efforts have been made towards UAD, which can be grouped into methods based on statistical modeling, content-based retrieval or clustering and outlier detection 

[16]. Weiss et al. [18] employed Dictionary Learning and Sparse Coding to learn a representation of normal brain patches in order to detect MS lesions. Other unsupervised MS lesion segmentation methods rely on thresholding and 3D connected component analysis [7] or fuzzy c-means clustering with topology constraints [15]. Notably, only few approaches have been made towards deep learning based UAD. Vaidhya et al.[17]

utilized unsupervised 3D Stacked Denoising Autoencoders for patch-based glioma detection and segmentation in brain MR images, however only as a pretraining step for a supervised model. Recently, Schlegl et al.


presented the AnoGAN framework, in which they create a rich generative model of normal retinal OCT patches using a GAN. Assuming that the model cannot properly reconstruct abnormal samples, they classify query patches as either anomalous or normal by trying to optimize the latent code based on a novel mapping score, effectively also leading to a delineation of the anomalous region in the input data. In earlier work, Seeböck et al.


trained an Autoencoder and utilized a one-class SVM on the compressed latent space to distinguish between normal and anomalous OCT patches. A plethora of work in the field of deep learning based UAD has been devoted to videos primarily based on Autoencoders (AEs) due to their ability to express non-linear transformations and the ability to detect anomalies directly from poor reconstructions of input data

[11, 5, 2]. Very recently, first attempts have also been made with deep generative models such as Variational Autoencoders[8, 1]

(VAEs), however limited to dense neural networks and 1D data. Noteworthy, most of this work focused on the detection rather than the delineation of anomalies.

A major advantage of AEs is their ability to reconstruct images with fairly high resolution thanks to a supervised training signal coming from the reconstruction objective. Unfortunately, they suffer from memorization and tend to produce blurry images. GANs[4] have shown to produce very sharp images due to adversarial training, however the training is very unstable and the generative process is prone to collapse to a few single samples. The recent formulation of VAEs has also shown that AEs can be turned into generative models which can mimic data distributions, and both concepts have also been combined into the VAEGAN[3], yielding a framework with the best of both worlds.

Contribution Inarguably, AnoGAN is a great concept for UAD in patch-based and small resolution scenarios, but as our experiments show, GANs lack the capability to reliably synthesize complex, high resolution brain MR images. Further, the approach requires a time-consuming iterative optimization. To overcome these issues, we propose AnoVAEGAN: We leverage a deep generative model in the form of spatial VAEs to build a model that captures “global” normal anatomical appearance rather than the variety of local patches. The reconstruction objective allows to train a generative model on complex, high resolution data such as brain MR slices. In order to avoid the memorization pitfalls of AEs and to improve realism of the reconstructed samples, we train the decoder part of the network with the help of an adversarial network, ultimately turning the model into a VAEGAN[3]. In our experiments, we rank the AnoVAEGAN against the AnoGAN framework as well as both dense and spatial variants of the VAE, AE and Context Encoders[9] (here referred to as “AE-GAN”) in the tasks of unsupervised MS lesion delineation and report significant improvements of spatial autoencoding models over traditional ones.

2 Methodology

Figure 2: An overview of our AnoVAEGAN

In this work, we employ deep generative representation learning to model the distribution of the healthy brain, which should enable the model to fully reconstruct healthy brain anatomy while failing to reconstruct anomalous lesions in images of a diseased brain. Therefore, we utilize an adaptation of the VAEGAN[3] to establish a parametric mapping from input images to a lower dimensional representation and back to high quality image reconstructions using an encoder and a decoder :


Like in [3], the latent space

is constrained to follow a multivariate normal distribution (MVN)

, which we leverage for encoding images of normal brain anatomy. Further, we employ a discriminator network which classifies its input as either real or reconstructed.

2.0.1 Training.

We optimize the framework using two loss functions in an alternating fashion. The VAE component of the model is optimized using

, while the discriminator is trained as commonly seen in the GAN framework[4]:


Originally, VAEGAN used an abstract reconstruction loss in the latent space of the discriminator rather than a pixelwise reconstruction objective, which was not helpful for our purpose. For , we thus used the pixelwise -distance between input image and reconstruction. is the KL-Divergence between the distribution of generated and a MVN, which is only used to regularize the weights of the encoder. The third part is the adversarial loss which forces the decoder to generate images that are likely to fool the discriminator in its task to distinguish between real and reconstructed images.

A peculiarity of our approach is the fully convolutional encoder-decoder architecture which we use in order to preserve spatial information in the latent space, i.e.

is a multidimensional tensor. Fig. 

2 shows our AnoVAEGAN, and a depiction of different AE architectures is given in Fig. 3.

2.0.2 Anomaly Detection

Anomalies are detected and delineated by 1) computing the pixelwise -distance between an input image and its reconstruction and 2) thresholding the resulting residual image to obtain a binary segmentation.

(a) Dense Autoencoder dAE
(b) Spatial Autoencoder sAE
(c) Dense Variational Autoencoder dVAE
(d) Spatial Variational Autoencoder sVAE
Figure 3: An overview of different Autoencoder frameworks

3 Experiments and Results

Given the variants of AE and our proposed framework, we investigate i) whether autoencoding deep networks can be utilized in general to learn to reconstruct complex brain MR images, ii) how the dimensionality of affects the reconstruction capabilities of a model, iii) the effect of constraining to be well structured and iv) if adversarial training enhances the quality of reconstructed images. In the following paragraphs we first introduce the dataset, provide implementational details and then describe the conducted experiments.


For our experiments, we use an inhouse dataset which provides a rich variety of images of healthy brain anatomy - a neccessity for our approach. The dataset consists of FLAIR and T1 image pairs from 83 patients (1360 slices) with healthy brains and 49 patients with MS lesions (980 slices). All images have been acquired with a Philips Achieva 3T scanner. To reduce variability and relax the reconstruction problem, all images have been rigidly co-registered to the SRI24 ATLAS [10]. Further, the skull has been stripped with ROBEX [6]. The resulting images have been denoised using CurvatureFlow [14] and normalized into the range [0,1]. From every patient, we extracted 20 consecutive axial slices of resolution px around the midline.

Figure 4: Realistic (left) and unrealistic (right) samples generated with AnoGAN.

We build upon the basic architecture proposed in [3] and perform only minor modifications affecting the latent space (see Table 1

). Across different architectures we keep the model complexity of the encoder-decoder part the same to allow for a valid comparison. All models have been trained for 150 epochs in minibatches of size 8, using a learning rate of 0.001 for the reconstruction objective and 0.0001 for the adversarial training on a single nVidia 1080Ti GPU with 8GB of memory.

Evaluation Metrics.

We measure the performance of the different models by the mean and standard deviation of the Dice-Score across different testing patients as well as the average time required for reconstructing and segmenting a sample.

Figure 5: 1st Column: a selected axial slice and its ground-truth segmentation; Succeeding columns show the filtered difference images (top row) and the resulting segmentation augmented to the input image (bottom row) for the following models (in order): dAE, sAE, sAE-GAN, sVAE and sVAE-GAN.

3.1 Anomaly Detection

We first trained normal convolutional AE & VAE with a dense latent space of dimensionality and found that, besides not being capable of reconstructing brain lesions, they also lack the capability to reconstruct fine details such as the brain convolutions (Fig. 5). Similar to [5, 2], we then make the architecture fully convolutional to ensure that spatial information is not lost in the bottleneck of the model. Notably, this heavily increases the dimensionality of . We thus vary the number of featuremaps of the spatial AE to investigate the impact on reconstruction quality of normal and anomalous samples. We identify as a good parameterization and use it in further experiments on a spatial VAE, a spatial AE-GAN[9] and our AnoVAEGAN. Further, we also trained an AnoGAN on the same set of normal axial slices for 150 epochs. After approx. 82 epochs of training, we obtained realistically looking images, however continuation of the training led to instabilities which resulted in unrealistic samples (Fig. 4). Thus, we evaluated the AnoGAN approach after 82 epochs. The required iterative reconstruction of testing samples was computed in 100 steps.

3.1.1 Postprocessing

Figure 6: The histogram of residuals for normal (blue) and anomalous (red) pixels using our AnoVAEGAN.

After reconstruction of all the slices, we apply some postprocessing steps to reduce the number of False Positives. For every patient, we apply a median filter to the reconstructed subvolumes to filter out small residuals, usually belonging to brain convolutions. Further, we multiply the residuals with slightly eroded brain masks, threshold the resulting volumes to obtain a binary segmentation mask and remove tiny 3D connected components with an area less than 6 voxels as they are unlikely to constitute lesions. The threshold is model specific and determined as the 98th percentile of the models reconstruction errors on the training dataset. We chose this percentile empirically from the histogram of residuals obtained from both normal and abnormal data (Fig. 6). The performance of each model is reported in Table 1. A comparison of processed residual images and final segmentations of various models can be seen in Fig. 5.

The highest average Dice-score for MS lesion segmentation has been obtained with our AnoVAEGAN. The spatial VAEs and AEs which do not leverage adversarial training produce only slightly inferior scores, however. All spatial autoencoding models significantly outperform the ones with a dense bottleneck and, except for sAE, also the AnoGAN. Interestingly, the spatial AE with adversarial training performs worse than its generative counterpart and the other spatial AEs with the same bottleneck resolution.

MODELTYPE DICE () avg. Reco.-time [s]
dAE 0.01286
sAE 0.01217
sAE 0.01185
sAE-GAN[9] 0.01445
dVAE 0.01083
sVAE 0.01297
AnoVAEGAN 0.01541
AnoGAN[12] 19.8547
Table 1: Results of our experiments on unsupervised MS lesion segmentation. We report the Dice-Score (mean and std. deviation across patients) as well as the avg. reconstruction time per sample in seconds. Prefixes d or s stand for dense or spatial.

4 Discussion and Conclusion

Our experiments show that AE & VAE models with dense bottlenecks cannot reconstruct anomalies, but at the same time lack the capability to reconstruct important fine details in brain MR images such as brain convolutions. By utilizing spatial AEs with sufficient bottleneck resolution, i.e. px sized featuremaps, we can mitigate this problem. Noteworthy, a smaller bottleneck resolution of px seems to lead to a severe information loss and thus to large reconstruction errors in general. By further constraining the latent space to follow a MVN distribution and introducing adversarial training, we notice marginal improvements over the non-generative models. As expected, spatial autoencoding clearly outperforms the AnoGAN and is considerably faster. While AnoGAN requires an iterative optimization, which consumes 19 seconds for a single reconstruction, all of the AE models require only a fraction of a second. Interestingly, even though the models operate on 2D data, the segmentations seem very consistent among neighboring axial slices.

In summary, we presented a novel and fast UAD approach based on generative deep representation learning which encodes the full context of brain MR slices. We believe that the approach does not only open up opportunities for unsupervised brain lesion segmentation, but can also act as prior information for supervised deep learning.

In future work, we also aim to investigate the projection of healthy anatomy into a latent space which follows a Gaussian Mixture Model rather than a single multivariate normal distribution, and intend to utilize 3D autoencoding models for unsupervised anomaly detection.


We thank our clinical partners from Klinikum Rechts der Isar for providing us with their broad dataset of patients with healthy anatomy as well as the MS lesion dataset.


  • [1]

    An, J., Cho, S.: Variational Autoencoder based Anomaly Detection using Reconstruction Probability. Tech. rep. (2015)

  • [2] Chong, Y.S., Tay, Y.H.: Abnormal Event Detection in Videos using Spatiotemporal Autoencoder. CoRR (2017)
  • [3] Donahue, J., Krähenbühl, P., Darrell, T.: Adversarial Feature Learning. (May 2016)
  • [4] Goodfellow, I.J., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A.C., Bengio, Y.: Generative Adversarial Nets. NIPS (2014)
  • [5]

    Hasan, M., Choi, J., Neumann, J., Roy-Chowdhury, A.K., Davis, L.S.: Learning Temporal Regularity in Video Sequences. In: 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). pp. 733–742. IEEE (2016)

  • [6] Iglesias, J.E., Liu, C.Y., Thompson, P.M., Tu, Z.: Robust Brain Extraction Across Datasets and Comparison With Publicly Available Methods. IEEE Transactions on Medical Imaging 30(9), 1617–1634 (2011)
  • [7] Iheme, L.O., Ünay, D., Baskaya, O., Sennaz, A., Kandemir, M., Yalciner, Z.B., Tepe, M.S., Kahraman, T., Ünal, G.B.: Concordance between computer-based neuroimaging findings and expert assessments in dementia grading. SIU pp. 1–4 (2013)
  • [8] Kingma, D.P., Welling, M.: Auto-Encoding Variational Bayes. CoRR (2013)
  • [9] Pathak, D., Krähenbühl, P., Donahue, J., Darrell, T., Efros, A.A.: Context Encoders: Feature Learning by Inpainting. In: 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). pp. 2536–2544. IEEE (2016)
  • [10] Rohlfing, T., Zahr, N.M., Sullivan, E.V., Pfefferbaum, A.: The SRI24 multichannel atlas of normal adult human brain structure. Human Brain Mapping 31(5), 798–819 (Dec 2009)
  • [11] Sabokrou, M., Fathy, M., Hoseini, M.: Video anomaly detection and localisation based on the sparsity and reconstruction error of auto-encoder. Electronics Letters 52(13), 1122–1124 (Jun 2016)
  • [12] Schlegl, T., Seeböck, P., Waldstein, S.M., Schmidt-Erfurth, U., Langs, G.: Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery. CoRR cs.CV (2017)
  • [13] Seeböck, P., Waldstein, S.M., Klimscha, S., Gerendas, B.S., Donner, R., Schlegl, T., Schmidt-Erfurth, U., Langs, G.: Identifying and Categorizing Anomalies in Retinal Imaging Data. CoRR cs.LG (2016)
  • [14] Sethian, J.A., et al.: Level set methods and fast marching methods. Journal of Computing and Information Technology 11(1), 1–2 (2003)
  • [15] Shiee, N., Bazin, P.L., Ozturk, A., Reich, D.S., Calabresi, P.A., Pham, D.L.: A topology-preserving approach to the segmentation of brain images with multiple sclerosis lesions. NeuroImage 49(2), 1524–1535 (2010)
  • [16] Taboada-Crispi, A., Sahli, H.: Anomaly Detection in Medical Image Analysis. In: Handbook of Research on Advanced Techniques in Diagnostic Imaging and Biomedical Applications
  • [17] Vaidhya, K., Thirunavukkarasu, S., Varghese, A., Krishnamurthi, G.: Multi-modal Brain Tumor Segmentation Using Stacked Denoising Autoencoders. Brainles@MICCAI 9556(10), 181–194 (2015)
  • [18] Weiss, N., Rueckert, D., Rao, A.: Multiple Sclerosis Lesion Segmentation Using Dictionary Learning and Sparse Coding. MICCAI 8149(Chapter 92), 735–742 (2013)