Skip to content

beards-lab/PhysicalAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Physical AI — Digital Twin + AI Hybrid Framework for HFpEF

Physical AI is an integrated framework that combines digital twin cardiovascular models with modern machine learning / generative AI techniques.
This repository is the starting platform for future development of full digital twin–guided physiological AI applications.

Currently, the repo includes two core modules:

  1. Physically-Informed Generative AI (phys_informed_gen_ai)
  2. Classifiers Learning from Digital Twin Simulations (classifiers_learn_sims)

Both modules live under src/ and interact with data, pretrained models, digital twin simulations, and output results.


📁 Repository Structure

PhysicalAI/
│
├── data/                         # All datasets used by the two modules
│
├── model/                        # Trained VAE models & classifier PyTorch checkpoints
│
├── result/                       # Synthetic data, evaluation plots, predictions
│
└── src/
    ├── phys_informed_gen_ai/     # VAE + digital twin hybrid generative module
    │   ├── main.ipynb            # Main notebook for VAE-based generative DT framework
    │   └── *.m                   # MATLAB scripts for physical constraints (DT validation)
    │
    └── classifiers_learn_sims/   # Classifier training & prediction module
        └── main.ipynb            # Main notebook for training & inference

1. Physically-Informed Generative AI (phys_informed_gen_ai)

This module uses a VAE trained on HFpEF digital twin phenotypes to generate new virtual digital twin samples.

Three Sampling Modes

(1) VirtualDT_original

  • Random sampling from the VAE latent space
  • No covariance constraints

(2) VirtualDT_correlated

  • Sampling from a multivariate Gaussian that preserves the training-set latent covariance
  • Produces more realistic synthetic phenotypes

(3) VirtualDT_phys

  • Based on (2), but each generated sample is validated using the digital twin model (MATLAB)
  • Only physiologically consistent samples are retained
  • This forms a hybrid digital twin + AI dataset

Generated data are stored under:

result/
  ├── VirtualDT_original.csv
  ├── VirtualDT_correlated.csv
  └── VirtualDT_phys.csv

📊 Key Plots

Located in result/:

  • Z_Sampling_Methods_Comparison.png
  • VAE_reconstruction_PDF_CC.png
  • VAE_reconstruction_PDF_CC.png

These compare the latent sampling methods and reconstruction properties.

🧠 Digital Twin Validation

All MATLAB scripts under this directory are used to:

  • Evaluate generated samples for physiological plausibility
  • Reject unrealistic digital twins
  • Produce final “physically-informed” synthetic datasets

2. Classifiers Learning from Simulations (classifiers_learn_sims)

This module trains classification models using labels derived from digital twin simulations.

📄 Training & Testing Data

Located in data/:

  • TrainingC.csv
  • TestingC.csv

🧠 Trained Classifier Models

Located in model/:

  • model_LabelCO_best.pth
  • model_LabelFillingP_best.pth
  • (additional best models)

📊 Evaluation Results

In result/:

evaluation_plots/           # Confusion matrices (train/validation)
external_validation_plots/  # Confusion matrices for external test set

3. Predicting New Patient Data (Most Directly Usable Feature)

You can run the full pipeline on new clinical data.

Step 1 — Prepare New Patient File

Replace the placeholder file:

data/inputclassifierMYPACE.csv

The repo includes 10 synthetic example patients.
Replace them with real patients using identical column names.

Step 2 — Run the Prediction Cell

Inside:

src/classifiers_learn_sims/main.ipynb

Run the second-to-last cell (the script clearly marks it).

Step 3 — View Output Predictions

Results will appear in:

result/inputclassifierMYPACE_with_predictions.csv

Step 4 — More Details

The final cell in main.py contains a detailed explanation of the inference pipeline.


🌟 Future Development

This repository is the initial version of a broader “Physical AI” framework which will include:

  • PINN-based digital twin inversion
  • Longitudinal prediction models
  • Adaptive pacing-response estimation
  • Full digital-heart physical simulation integration

Future updates will expand the src/ modules and add additional datasets and models.


📦 Requirements

  • Python 3.8–3.11
  • PyTorch
  • NumPy / SciPy / Pandas / Matplotlib
  • MATLAB + MATLAB Engine for physically-informed VAE filtering

🧑‍💻 Contact

For questions or collaboration:

Feng Gu
University of Michigan
Email: fenggu@umich.edu

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published