NormVAE Model on NeuroImaging data: Paper Implementation

NormVAE Paper Implementation

Paper link: Link to the NormVAE paper

GitHub Link : Link to the GitHub Repo

NormVAE Paper Implementation

Paper link: Link to the NormVAE paper

Implementation of NormVAE Paper using PyTorch Framework on Custom Dataset(ADNI Dataset).

drawing Source : NormVAE: Normative Modelling on Neuroimaging Data using Variational Autoencoders paper, Fig. 1

Usage:

Installing Dependencies:

pip install -r requirements.txt

The following packages will be installed :

  • PyTorch
  • Numpy
  • Pandas
  • Scikit-Learn

    Data Preprocessing Step:

    python data_preprocessing.py --path "/path/to/dataset" --bsize #batchsize
    
  • An example:
    python data_preprocessing.py --path "dataset.xlsx" --bsize 64
    

Training the Model: (step by step process)

  • Download the code from the repository and get the dataset file or modify the dimensions in the code for your dataset.
  • After downloading the repository from the terminal go to the directory and Install depedencies using :
    pip install -r requirements.txt
    
  • Preprocess data using the data preprocessing script
    python data_preprocessing.py --path "/path/to/dataset" --bsize #batchsize
    
  • To generate the reconstructed samples along with training the model:
    • number of samples can be given using –gensamples
      python reconstruct.py --bsize #batchsize --epochs #epochs --gensamples #no.ofsamples --output_format {outputformat as string} 
      

An example usage :

Only For Training the Model

python data_preprocessing.py --path "dataset.xlsx" --bsize 64

python train_model.py --epochs 1000 --bsize 1024

For Training the Model and Generating reconstructed samples

  • To save the reconstructed samples in excel file:
    ```python python data_preprocessing.py –path “dataset.xlsx” –bsize 64

python reconstruct.py –bsize 64 –epochs 1000 –gensamples 20 –output_format “xlsx”

* To save the reconstructed samples as csv file:
```python
python data_preprocessing.py --path "dataset.xlsx" --bsize 64

python reconstruct.py --bsize 64 --epochs 1000 --gensamples 20 --output_format "csv"

Note: The above command performs training of the model and generates reconstructed samples from the decoder part of the VAE in an excel file with name reconstruct.xlsx or reconstruct.csv if you choose the output_format as csv. Default output format is xlsx.

  • For more help on how to use the model with different hyperparameters:
python train_model.py -h

Example comparison of the original sample and reconstructed samples generated by VAE

  • Original data excel sheet original sample
  • Reconstructed excel sheet reconstructed sample

References:

sayantan.k (2022) NormVAE: Normative modelling on neuroimaging data using Variational Autoencoders, arXiv:2110.04903v2 [eess.IV] 30 Jan 2022