Bayesian Volumetric Autoregressive generative models for better semisupervised learning
Guilherme Pombo Robert Gray Tom Varsavsky John Ashburner Parashkev Nachev
cs.LG cs.CV eess.IV stat.CO stat.ML




Bayesian Volumetric Pixel CNN





G. Pombo



Institute of Neurology, UCL School of Biomedical Engineering and Imaging Sciences, Kings College London, UK







Bayesian Volumetric Autoregressive generative models for better semisupervised learning
    Guilherme Pombo 1, Robert Gray 1, Tom Varsavsky 1, 2, John Ashburner 1, Parashkev Nachev 1
    December 30, 2023
==============================================================================================




Deep generative models are rapidly gaining traction in medical imaging. Nonetheless, most generative architectures struggle to capture the underlying probability distributions of volumetric data, exhibit convergence problems, and offer no robust indices of model uncertainty. By comparison, the autoregressive generative model PixelCNN can be extended to volumetric data with relative ease, it readily attempts to learn the true underlying probability distribution and it still admits a Bayesian reformulation that provides a principled framework for reasoning about model uncertainty. Our contributions in this paper are two fold: first, we extend PixelCNN to work with volumetric brain magnetic resonance imaging data. Second, we show that reformulating this model to approximate a deep Gaussian process yields  a measure of uncertainty that improves the performance of semi-supervised learning, in particular classification performance in settings where the proportion of labelled data is low. We quantify this improvement across classification, regression, and semantic segmentation tasks, training and testing on clinical magnetic resonance brain imaging data comprising T1-weighted and diffusion-weighted sequences.








§ INTRODUCTION


There are two common problems with discriminative learning: class imbalance and sparse labels. These problems are particularly prevalent in medical imaging, due to the essential nature of clinical data. Semi-supervised learning provides a partial solution to these problems. Semi-supervised learning can be improved by using deep generative models, to learn better representations of the data, where generalisable decision boundaries are easier to identify <cit.>. Variational autoencoders (VAEs), generative adversarial networks (GANs), and autoregressive (AR) models are the leading architectures for deep generative modelling. Unfortunately, their application to volumetric data has so far proved challenging, owing to poor convergence and distribution mode dropping, in the case of GANs <cit.>, or to potentially inaccurate error bounds and inappropriate independence assumptions, in the case of VAEs <cit.>. The use of generative modelling with high resolution 3D data is still only tentatively explored. 

Our contributions are as follows: in 3 we show how the 2D generative model PixelCNN <cit.> can be extended to work efficiently with volumetric data. We call the resulting model 3DPixelCNN.  Furthermore, we incorporate the architectural changes suggested in <cit.> so that we can compute voxel-wise measures of uncertainty with little computational overhead. In 4 we show the benefits of using these uncertainty measures and 3DPixelCNN's hidden layer activations, in semi-supervised scenarios where labelled data is limited. Our evaluation incorporates three tasks: semantic segmentation of acute stroke lesions on diffusion weighted imaging (DWI) and age regression and sex classification on grey matter tissue compartments extracted from T1-weighted magnetic resonance imaging (MRI). Code available at https://github.com/guilherme-pombo/3DPixelCNN




§ RELATED WORK



 §.§ Generative models for brain imaging


We are interested in modelling p(x), the probability distribution for the stochastic process that generates our brain volumes. In the context of brain imaging, we have a likelihood model p_θ, where the parameters θ are found by maximising the following objective:

    ℒ(θ)=1/N∑_i=1^Nlog p_θ(x_i) ∼∫ p(x) log p_θ(x) dx;

here, x_1,...,x_N are the training volumes, which we assume have been sampled i.i.d from p(x). In medical imaging it is common to process volumes as 2D slices to reduce processing time and memory consumption. However, in order to utilise all of the information in x_i, and to demonstrate the feasibility 3DPixelCNN, we use a fully 3D model. To the best of our knowledge, <cit.> is the only work prior to ours to train a generative model on high-resolution 3D brain imagery. They model the (relatively low-detail) computed tomography (CT) modality using an approximation to a deep Gaussian process (c.f. <ref>) and an Autoencoder (AE). In the present article we also use this approximation but with a generative model that has increased representational power. We describe this model in the following section.



 §.§ PixelRNN


In <cit.>, the authors show how to model p(x) autoregressively, by modelling the joint distribution of pixels in an image using recurrent neural networks. They treat their (2D) images, with dimensions M × N, as a one-dimensional sequence of length MN, and  they write the product of the conditional distributions over pixels as:


    p(x)=∏_i=1^MN p(x_i | x_1, …, x_i-1).


This model is comparatively slow due to RNNs' difficulty in parallelising, so the authors approximate it with much faster standard convolutional networks. To ensure the receptive field of each convolution around each pixel only includes the pixels on which its probability is conditioned (thus, avoiding seeing the future context) they add masks to the convolutions. However, the bounded nature of this `masked' convolutional architecture causes a significant part of the input image to be ignored: a triangular pattern of omitted voxels they call the `blind spot'. To remedy this, the authors of <cit.> use two masks instead of one, which they call `stacks': the first one is conditioned on the row so far (the `horizontal' stack) and the second one conditions on all rows above (the `vertical' stack). The greater computational efficiency of PixelCNN compared with PixelRNN carries a cost in reconstruction quality. However, it has been shown <cit.> that this can be ameliorated by replacing the rectified linear units between the convolutional stacks with a gated activation unit. This results in a better emulation of a long short-term memory (LSTM) gate. This use of both the convolutional stacks and the gated unit has enabled PixelCNN to match PixelRNN's reconstruction quality, whilst maintaining computational feasibility. 



 §.§ Dropout as a Bayesian Approximation


Unlike VAEs, AR models are not Bayesian by construction, and they do not produce implicit or explicit estimates of model uncertainty. In <cit.>, Gal and Ghahramani show that simply incorporating Dropout <cit.> in every layer of any given neural network makes it capable of doing Bayesian inference, without harming performance. Once these changes are made, the standard deviation of a large-enough batch of forward passes yields a robust measure of uncertainty.  

In <cit.> it is shown that since natural images exhibit strong spatial correlation, the feature map activations are strongly correlated - so applying standard Dropout to the kernels of the convolution operators is ill advised. Hence, they purpose a new dropout method, SpatialDropout, whereby for a given convolution feature tensor of size H×W×D×channels, a mask of size 1 × 1 × 1 ×channels is applied. 




§ METHODS


To extend the PixelCNN solution to volumetric data we must first solve the blind spot problem for 3D (c.f. <ref>). Consider our model processing an M × N × K volume, and currently calculating the conditional distribution of the voxel with coordinates (R,C,D), which we denote x_R, C, D. We must now use three stacks (c.f. <ref>): horizontal, depth and vertical. The Horizontal stack conditions on the current depth channel and takes as input the output of the previous horizontal stack gate, as well as the output of the depth and vertical stacks. The set of voxels it considers is {x_R, C, d | d ∈{1, …, D-1 }}. In turn the Depth stack conditions on all the entries to the left of the current voxel, but does not go up any rows. It takes as input the output of the previous depth gate, as well as the output of the vertical stack. Its receptive field grows in 2D rectangular fashion, defined by the set {x_R, c, d | c ∈{1, …, C-1 }, d ∈{1, …, K }}.  Finally, the Vertical Stack  conditions on all the rows and columns in the level above the current voxel. It does not have any masking. Its output is fed into the horizontal and depth stacks and its receptive field grows as a cuboid, defined by the set {x_r, c, d | r ∈{1, …, R-1}, c ∈{1, …, N}, d ∈{1, …, K }}. These stacks ensure our convolution operations have the correct receptive fields. To reiterate, using just regular convolutions would lead to a bounded receptive field, which in turn would have led to the omission of several voxels from calculations of the conditional distribution (a pyramidal `blind spot'). These stacks are represented in figure <ref>. We use the gated activation unit from <cit.> to efficiently combine the information of different stacks. We first add the stacks together and do a channel-wise split. If the tensor has N channels, then we now have tensor W_1 with the first N/2 channels and tensor W_2 with the remaining channels. The gated activation unit is calculated as tanh (W_1) ⊙ sigmoid(W_2), where ⊙ is the Hadamard product.
After each gate we have a skip shortcut <cit.> to the next stack in the model. After the first layer, as in <cit.> we also add a residual connection <cit.> from a Gated unit to the next one. SpatialDropout is applied after every convolution operator so that we can approximate a deep Gaussian process (see 2.2). Model statistics are derived at test time from batches of multiple forward passes with dropout enabled. We denote the mean and standard deviation of these batches by μ and σ respectively. 

We train our 3DPixelCNN models using continuous negative log likelihood (NLL), and evaluate using log likelihood. We used continuous rather than discrete NLL as it has been shown <cit.> that treating pixel intensities as emission probabilities performs poorly for large images, resulting in noisy and speckly reconstructions. We trained for 20 epochs using the Adam optimiser <cit.>. The initial learning rate was 0.001, the batch size was 1 and the dropout rate was 0.15 (dropout rates between 0.1 and 0.2 are recommended in <cit.>). Our model has five layers with the structure depicted in figure <ref>. We use kernel sizes of 3×3×3 for all non-masked convolutions in the network. We could have incorporated downsampling as in <cit.>, but we leave this for future work. 





§ EXPERIMENTS AND RESULTS


Data: We use two separate datasets. One is a collection of routinely acquired DWI from patients evaluated for acute stroke at our clinic. This comprises 1333 scans with evidence of an acute ischaemic lesion, and 982 scans with no evidence of an acute lesion but variable presence of chronic vascular disease. The volumes we use consist of the b1000 sequence non-linearly registered to MNI space with unified segmentation <cit.>. A manually-curated binary mask delineating the area of ischaemic damage is our ground truth for lesion semantic segmentation <cit.>. We also use a manually curated mask to remove any voxels outside of the brain.  

The second dataset consists of 13287 SPM Grey Matter (GM) tissue compartments from MRIs obtained from UK Biobank, and routinely acquired clinical imaging at UCLH. The GM segmentations were derived using methods from <cit.>. Sex and age are known for all patients and were used to evaluate models on classification and regression tasks. For both modalities we reduced the computational burden (due to time constraints) by downsampling the volumes, using bilinear resampling, to 3mm resolution 52×64×52 volumes. 

Image reconstructions: For each volume in the DWI and GM datasets, we produce its reconstruction, and then generate μ and σ by performing T=20 forward passes with dropout left on (c.f. <ref>). We use a train/validation/test split of 80/10/10. The best log likelihood obtained by the model in the task of volume reconstruction on the test sets at 3mm, are 0.360 for the DWI data and 0.105 for the GM data. Our model outperforms the Bayesian AE from <cit.> which achieves 0.378 on DWI and 0.222 on GM. Notice that on the more detailed modality (T1-GM) our model performs 111% better.

In order to produce uncertainty estimates (σ) for DWI, we trained our 3DPixelCNN only on data with no evidence of stroke lesion, i.e. from the distribution p(x|no lesion). Therefore, when producing σ for lesioned data, the uncertainty masks provide a measure of the distance from the lesioned brain to the expected distribution of non-lesioned brains. We use a simple classification strategy on the volumes -  thresholding the average intensity of the volume, x_i, which we denote as τ(x_i). On the DWI ischemic stroke lesion test set, applying this classification strategy on regular volumes yields Dice coefficients of 14.7 %, whereas on σ it yields Dice coefficients of 23.7 %. This same strategy on the Bayesian AE, |x_i - AE(x_i)| (see <cit.> for more details)  yields a performance of 17.3 %. This provides early confirmation that uncertainty estimates of generative models capture useful task-independent signal. Figure <ref> shows a representative selection of reconstructions of GM volumes and unsupervised lesion masks produced using τ(x_i). Notice on the MRI reconstruction, when the original image is corrupted, the 3DPixelCNN model acts as a super resolution mechanism, further showing the model has learnt p(x) and is not simply memorising the training set.



Semi-supervised learning: To experiment with using our uncertainty measures to improve supervised tasks, we use our DWI dataset for evaluating models on the task of semantic segmentation and our GM dataset to evaluate regression and classification tasks. For the segmentation task we use a 3D U-Net <cit.> as the baseline. As the DWI dataset is not yet public, there are no state of the art results to which we can compare our results. For the age regression and sex classification tasks we use the architecture from <cit.> as our baseline, which we'll call ASC, adding only L2 regularisation and Dropout to ensure better generalisation. All models are trained with early stopping using the validation set, the criterion being 20 successive epochs without a drop in validation error. The models are trained in 5-fold fashion (80/10/10 split) for added statistical resilience. We compare the models' Dice scores on a semantic segmentation task, their mean absolute errors on an age regression task and their binary accuracy on a sex classification task, all evaluated on the test set. 

Figure <ref> shows mean model performance with error bars for three different types of inputs into both the 3D-UNet and ASC classifiers: (1) using just the original volumes as input (red- χ); (2) using original data concatenated with μ and σ (blue - ξ). For the case Bayesian AE we concatenate μ and |x_i - AE(x_i)|; (3) using the activations of the penultimate convolutional layer of the 3DPixelCNN. (black/green - ψ). For the Bayesian AE we use its latent space. When using 3DPixelCNN, we notice that performance with ξ was significantly better than with χ, for all dataset sizes tested and classification tasks. For sex classification and age regression, using ψ results in better performance than both χ and ξ. We speculate that this is because the embeddings, which are higher-dimensional (10 vs 3 channels), comprise a decomposition of the data from which useful decision boundaries can be more readily identified, although this extra dimensionality comes at the cost of greater GPU memory requirements. On the other hand, for lesion segmentation, using ξ performs better than using either χ or ψ. For semantic segmentation using ξ, the increase is most noticeable at smaller N with an improvement of 0.082 (25.6%) in Dice coefficient for N < 500 and an average increase of 0.056 (15.2%) for all N. Using ψ provides less of a performance gain, with an average increase in Dice of 0.025 (6.9%). For age regression and sex classification, we notice a steady increase in performance when using ξ, with an average error reduction of 0.30 years (3.98%) and accuracy increase of 1.87%, respectively. Using ψ, on the other hand, results in an average error reduction of 0.68 years (9.09%) for age regression and accuracy increase of 3.36%, for sex classification. Using the Bayesian AE's ξ results in a performance degradation of at least 2% for all tasks, compared to using the original volume. We suspect this is because here ξ is relatively noisy, as can be seen in Fig. <ref>. On the other hand, using the latent space, ψ, results in an average 5.6% increase for the age regression task and a 2.2% increase for sex classification. The Bayesian AE's latent space degraded performance for the semantic segmentation task. 

Clearly, 3DPixelCNN's uncertainty measures help most with semantic segmentation. They seem to be most useful for tasks with more localised signal (lesion segmentation) as opposed to global signal. We speculate this is  because in the lesioned brains σ is more focused on the lesion, since we had the generative model learn p(x|no lesion), whereas the uncertainty maps are much noisier for volumes with less obvious abnormalities, since the 3DPixelCNN learnt only p(x). We hypothesize these uncertainty measures are also helpful in the presence of artifacts (as can be seen in Figure  <ref>), which is why they also helped for tasks with less abnormal brains. 




§ CONCLUSION


We have presented the first implementation of a volumetric neural network-based autoregressive model. We have shown that it is a method that can capture the richness of a complicated 3D probability distribution and is therefore well-suited to medical imaging. By augmenting labelled data with measures of uncertainty derived from unsupervised models, we saw improved performance in every supervised task we carried out. For tasks on brains without gross abnormalities, we found it was better to use 3DPixelCNN's penultimate layer activations than the uncertainty estimates. For lesion detection, we found that the uncertainty measures provided a bigger performance increase, which is of more utility in the medical imaging domain. Acknowledgments: This research has been conducted using the UK Biobank Resource under Application Number 16273. This work is supported by the EPSRC-funded UCL CDT in Medical Imaging (EP/L016478/1), the Department of Health’s NIHR-funded BRC at UCLH and the Wellcome Trust.








*
10




john
Ashburner, J., et al.: Unified segmentation. Neuroimage  26(3),
  839–851 (2005)

unet
Çiçek, Ö., et al.: 3D U-Net: learning dense volumetric
  segmentation from sparse annotation. In: MICCAI. pp. 424–432. Springer
  (2016)

age
Cole, J.H., et al.: Predicting brain age with deep learning from raw imaging
  data results in a reliable and heritable biomarker. NeuroImage  163,
   115–124 (2017)

dropout_bayes
Gal, Y., Ghahramani, Z.: Dropout as a Bayesian approximation: Representing
  model uncertainty in deep learning. In: ICML. pp. 1050–1059 (2016)

skip_connections
He, K., et al.: Deep residual learning for image recognition. CoRR  (2015)

adam
Kingma, D.P., et al.: Adam: A method for stochastic optimization. arXiv
  preprint arXiv:1412.6980  (2014)

semi_kingma
Kingma, D.P., et al.: Semi-supervised learning with deep generative models. In:
  NIPS. pp. 3581–3589 (2014)

glow
Kingma, D.P., et al.: Glow: Generative flow with invertible 1x1 convolutions.
  In: NIPS. pp. 10236–10245 (2018)

c_pixel_cnn
van den Oord, A., et al.: Conditional image generation with PixelCNN
  decoders. In: NIPS. pp. 4790–4798 (2016)

pixel_rnn
van den Oord, A., et al.: Pixel recurrent neural networks. arXiv preprint
  arXiv:1601.06759  (2016)

nick_encoder
Pawlowski, N., et al.: Unsupervised lesion detection in brain CT using
  Bayesian convolutional autoencoders  (2018)

pixel_cnn_pp
Salimans, T., et al.: PixelCNN++. In: ICLR (2017)

dropout
Srivastava, N., et al.: Dropout: a simple way to prevent neural networks from
  overfitting. The journal of machine learning research  15,
  1929–1958 (2014)

spatial_dropout
Tompson, J., et al.: Efficient object localization using convolutional
  networks. In: CVPR. pp. 648–656 (2015)

tianbo
Xu, T., et al.: High-dimensional therapeutic inference in the focally damaged
  human brain. Brain  141,  48–54 (2017)



