This repository provides code and anonymized data to accompany our paper "Unsupervised multimodal modeling of cognitive and brain health trajectories for early dementia prediction" 1. In it, we propose and validate a mixture of state space models to perform unsupervised clustering of short trajectories. Within the state space framework, we let expensive-to-gather biomarkers correspond to hidden states and readily obtainable cognitive metrics correspond to measurements. Upon training with expectation maximization, we find that our clusters stratify persons according to clinical outcome. Furthermore, we can effectively predict on held-out trajectories using cognitive metrics alone. Our approach accommodates missing data through model marginalization and generalizes across research and clinical cohorts.
We consider a training dataset
consisting of np.nan
's to shorter trajectories.
We adopt a mixture of state space models for the data:
Each individual
In our main framework, we additionally assume that the cluster-specific state
initialisation is Gaussian, i.e.
In particular, we assume that the variables we are modeling are continuous and
changing over time. When we train a model like the above, we take a dataset
- (E) Expectation step: given the current model, we assign each data instance
$(z^i_{1:T}, x^i_{1:T})$ to the cluster to which it is mostly likely to belong under the current model - (M) Maximization step: given the current cluster assignments, we compute the
sample-level cluster assignment probabilities (the
$\pi_c$ ) and optimal cluster-specific parameters
Optimization completes after a fixed (large) number of steps or when no data instances change their cluster assignment at a given iteration.
The approach (in framework) uses mixtures the above modeling formulation for training and inference. A Bayesian version of this approach was pioneered by Chiappa and Barber2. The EM3 approach we take with hard cluster assignment allows us to extend the above model to to nonlinear specifications (see framework_extended), with the tradeoff that certain types of model marginalisation are currently unsupported.
Model training and predictions are done in Python. Statistical tests on the results are mostly performed in R (with survival models being a notable exception). An environment suitable for running this code can be created using either:
-
a conda environment as described in
environment.yml
and an renv environment as inrenv.lock
—conda env create -f environment.yml conda activate hydrangea R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))" R -e "remotes::install_github('rstudio/renv@v1.0.0')" R -e "renv::restore()"
or
-
docker —
docker build -t thistly-cross .
After choosing one of the above, on a machine with
Make installed, and with all required
data in the data
folder, one can then
make all
to reproduce the figures and analyses related to ADNI. (Due to patient privacy,
we provide the code used to produce the results for MACC here, but not the
data.) If using docker, uncomment line #9 of the Makefile to define
docker
prior to running.
We provide a publicly available package
unsupervised-multimodal-trajectory-modeling
on pypi. A template repository containing starter code is available here:
https://github.com/burkh4rt/Unsupervised-Trajectory-Clustering-Starter
Some efforts have been made to automatically handle edge cases. For a given training run, if any cluster becomes too small (fewer than 3 members), training terminates. In order to learn a model, we make assumptions about our training data as described above. While our approach seems to be robust to some types of model misspecification, we have encountered training issues with the following problems:
- Extreme outliers. An extreme outlier tends to want to form its own cluster (and that's problematic). In many cases this may be due to a typo or failed data-cleaning (i.e. an upstream problem). Generating histograms of each feature is one way to recognize this problem.
- Discrete / static features. Including discrete data violates our Gaussian assumptions. If we learn a cluster where each trajectory has the same value for one of the states or observations at a given time step, then we are prone to estimating a singular covariance structure for this cluster which yields numerical instabilities. Adding a small bit of noise to discrete features may remediate numerical instability to some extent.
Footnotes
-
M. Burkhart, L. Lee, D. Vaghari, A. Toh, E. Chong, C. Chen, P. Tiňo, & Z. Kourtzi, Unsupervised multimodal modeling of cognitive and brain health trajectories for early dementia prediction, Scientific Reports 14 (2024) ↩
-
S. Chiappa & D. Barber, Dirichlet Mixtures of Bayesian Linear Gaussian State-Space Models: a Variational Approach, Tech. rep. 161, Max Planck Institute for Biological Cybernetics, 2007 ↩
-
A. Dempster, N. Laird, & D. Rubin, Maximum Likelihood from
Incomplete Data via the EM Algorithm, Journal of the Royal Statistical Society: Series B (Methodological) 39 (1977) ↩