Skip to content

Code Implementation of VAE Model inspired from NormVAE Paper using PyTorch Framework on Custom dataset

License

Notifications You must be signed in to change notification settings

sandeshkatakam/NormVAE-Neuroimaging

Repository files navigation

NormVAE Model for NeuroImaging Data

Implementation of VAE Model inspired by NormVAE Paper using PyTorch Framework on Custom Dataset of Healthy Controls(ADNI Dataset).

Model's Objective: To reconstruct samples using the decoder part of the VAE which resemble that of Healthy Control Brain Region Volumes from the Dataset Paper link: Link to the NormVAE paper

Model Architecture from the Paper:

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 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 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 Model

  • 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

About

Code Implementation of VAE Model inspired from NormVAE Paper using PyTorch Framework on Custom dataset

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages