USING LSTMS TO CREATE GENERATIVE MODELS FOR PREDICTING FMRI TIME SERIES

Despite significant existing analysis of fMRI data sets representing human brain activity, there still exist large gaps in our understanding of them. For example, we still do not have a full understanding of the temporal properties of the BOLD signal represented by fMRI time series. This research project investigates the feasibility of using LSTMs to construct a generative model trained on and predicting fMRI signals of brain regions. Altogether, we successfully constructed and trained a discretized probability distribution (DPD) LSTM architecture capable of producing stable models, which accurately reproduce the autoregressive (AR) and moving average (MA) properties of the original time series used for training. This was accomplished both for artificially generated ARMA time series and fMRI scans from various isolated human brain regions. The output of the DPD-LSTM model is bounded, ensuring stability, and probabilistic, aiding in the capture of the stochastic nature of brain activity. Time series generated by “vanilla” LSTM models, on the other hand, which predict the next timestep directly, were prone to exploding or collapsing to zero. Of the architectures tested, two-layer DPD-LSTMs with 10 to 20 bins and 200 to 300 total units were the most effective. The networks tested trained very quickly and significant precautions had to be taken to avoid overfitting. We are hopeful that the success of this DPD-LSTM model will lead to the future success of similar models incorporating data from many different regions of the brain at once and aiding in the discovery of new insights into the structural and functional connectivity of the brain. 1 BACKGROUND AND OVERVIEW Advances in the application of deep neural networks in recent years have proven successful in analyzing large data sets with complex feature spaces. Even though these methods have achieved widespread success only within the last half decade, there are many fascinating questions in a variety of scientific disciplines that neural networks can help us investigate. Studying time series in the context of computational neuroscience is one such example. In particular there exist rich data sets collected by means of Functional Magnetic Resonance Imaging (fMRI) representing the brain activity associated with changes in blood flow (Ogawa und Sung (2007)). Although there are instances in which neural networks have been applied to fMRI data for purposes of classification (Dvornek u. a. (2017)), there is little to no work which uses neural networks to create generative models of fMRI time series. The Long Short Term Memory (LSTM) network is an obvious candidate for this analysis (Hochreiter und Schmidhuber (1997)). Similar to Recurrent Neural Networks (RNNs) from which they are adapted, LSTMs are capable of analyzing signals that change over time thanks to their recurrent structure which allows information to persist in the network. Unlike RNNs, LSTMs include additional cell structures allowing the network to effectively “remember” high value past information while “forgetting” low value information over long periods of time. 3 It is unclear whether existing fMRI data sets are sufficient in size for data intensive deep network methods. In order to construct the generative model, I will train the network on a data set which includes approximately 300 brains. There are 360 brain regions associated with each scan and 1350 time samples were collected for each region. The data set includes fMRI data of “healthy” participants with no known disorders. Despite the significant previous analysis of these data sets using other methods, there still exist large gaps in our understanding. For example, we still do not fully understand the temporal properties of the BOLD signal represented by fMRI time series. We are hopeful that a successful neural network model will shed light on this lacuna and others. 2 DESCRIPTION This research project seeks to determine whether we can train an LSTM network using existing fMRI data to develop a useful generative model. In other words – can we train an LSTM on a certain number of points in a particular time series in order to predict any of the remaining timesteps? Moreover, do the time series generated by the trained model mimic any of the underlying properties of the original data set? The first models developed for this purpose involved a very straightforward LSTM architecture that will hereafter be referred to as the vanilla LSTM model. The vanilla LSTM attempted to directly predict the value of the next timestep of a given time series. The vanilla LSTM proved to be unworkable given the instability of the resulting generative model. Any lengthy prediction more than a few hundred timesteps in length resulted in values exploding towards infinity or collapsing to zero. Although stability improved dramatically with multiple layers, this change did not prove sufficient. The instability of the vanilla LSTM motivated the construction of a second more sophisticated architecture – a discretized probability density LSTM (DPD-LSTM). Instead of predicting a single value the DPD-LSTM model predicted a bounded and discretized probability distribution for the next step of a given time series (for similar architectures see (Flunkert u. a. (2017)) and (Yeo u. a. (2018))). Models trained from the DPD-LSTM architecture were robust and stable, even after thousands of predictions, and proved capable of accurately reflecting autoregressive and moving average components of the original data. The success of the DPD-LSTM architecture motivated its application to time series of fMRI data from various regions of the human brain. 4 3 IMPLEMENTATION 3.1 Libraries The LSTM networks developed over the course of this research project were written using the Python programming language and Keras, a popular API for building neural networks built on top of the Tensorflow library. Keras offered a sufficient level of customization for the architectures developed – including experimentation with custom loss, training, and output postprocessing procedures. 3.2 Vanilla LSTM The vanilla LSTM consisted of a very straightforward and familiar neural network architecture. One or two LSTM layers, each with the same number of units, preceded a final dense layer with one unit. The input size of the first LSTM layer was equivalent to the length of the time series being used as training samples. The samples used for training could be collected from a time series of any arbitrary length. Supposed the LSTM model expected samples of size n. A time series of length m could be split into (m −n) training samples each of length n. Each possible group of n consecutive timesteps would serve as the training data, X , while the (n +1)th timestep would serve as the target data, y . Mean square error was used as the loss function. A trained model could then be used to generate a time series of arbitrary length as follows. The model is provided with “seed” data of length n to initialize its predicted time series. Given the 1st through nth timesteps as input the model predicts the (n +1)th timestep. The model then uses the 2nd through (n +1)th steps to predict the (n +2)th step and so on and so forth. The models constructed used an input of size n = 10. 3.3 Discretized Probability Distribution LSTM The DPD-LSTM model trains and predicts in a process that is fundamentally similar to that described above for the vanilla model with several important modifications. First, the output of the network must be equal to the number of bins in the discretized probability distribution function. Suppose we are trying to predict a probability distribution function discretized into b bins. In this case the last dense fully connected output layer of the DPD-LSTM must have b units as well (not just 1). This is because the DPD-LSTM does not attempt to predict the next time step itself but rather the probabilities that the time step will have particular values (the possible values have been discretized into b buckets). 5 Second, for training we must modify the target data to make each target timestep value directly comparable to the predicted probability distribution. To do so we will convert each target value into a discretized delta function. Instead of one target value there will be a target vector of length b representing each of the bins. The bin containing the original target value will have value 1 whereas all other bins will have value 0. This new target vector can now be directly compared to the predicted probability distribution using various loss functions. This conversion is completed as a preprocessing step by the provided code before training for each model begins. While training the model seeks to maximize the likelihood that its chosen bucket contains the true target value. Finally, for prediction using the resulting generative model we choose the next timestep probabilistically based on the probability distribution returned for each timestep. Choosing values probabilistically from a bounded probability distribution will be helpful in capturing the stochastic nature of the brain signals. 3.4 Overfitting Precautions needed to be taken in every case to prevent the model from overfitting the provided data. In the case of the ARMA models this was accomplished by generating a new training sample of size n for each epoch. This means that during training the model was never exposed to the same time series twice. In the case of the fMRI models an analogous methodology was used such that each fMRI scan was used during only one training epoch. Given a specific brain region, a list of every scan of that region across all subjects and samples was curated and then shuffled randomly. The model was fitted using a unique scan for every epoch of training until there were no more scans remaining. As a result the model was never exposed to the same the same fMRI scan twice. Fortunately, this was reasonable given the quantity o