Repository to generate and simulate patient-specific cardiac mechanics using anonymized data from the UK Biobank. The code also can be used to generate training data for machine-learning applications.
- In an empty folder (assume DL-Cardiac), clone this repository using:
git clone https://github.com/rakshakonanur/DL-Cardiac.git- Create a "clones" folder, which will contain editable versions of the libraries used.
mkdir clones
cd clones- Follow installation instructions from this repo: https://github.com/rakshakonanur/rk-sscp25-deep-learning-cardiac-mechanics.git
- Inside the "clones" folder, clone the following repos:
- Create a new folder in the parent directory called "refs", add the following two files:
- https://drive.google.com/file/d/1nGlaEU_l6eJrSsk2DGX7Uqq0DgcDJU31/view
- Copy the cohort data file from this directory: sscp25/Data/virtual_cohort_data.xlsx
- Sample code can be run using:
python3 sample.py- To create meshes for the ED, ES, and undefoxrmed ED, in the src/ folder, run:
python3 mesh.pyThis by-default creates meshes for all three cases.
- The simulation.py code is set to generate training data for a particular patient. To run simulations on a singular case, use command-line arguments. For example:
python3 simulation.py --single_case True --PLV 15.0 --PRV 3.0 --Ta 120.0 --N 200Excluding these command-line arguments will result in the running all pressures/material properties combination for that patient. This script can be run in parallel. Final results are recommended to be visualized in Paraview.
- To run simulations in batch, adjust the ED values, material properties, and patient ID in batch.py. The code will automatically loop through all combinations.
python3 batch.py- To extract the PCA scores from the deformed meshes, either manually point to the ED and ES files in the main function of extract_pca.py and run:
python3 extract_pca.pyOr, if batch-extraction is required, move all patients to datasets/final/ (sister of clones and src). Then run:
python3 postprocessing.pyThis will automatically extract the PCA scores from the simulation results, and combine them into a large table. Details of volume/mass are also included.
- To run the Machine Learning code, run:
python3 ML.pyThe code currently trains on all patients exluding patient_id=5. This is used for testing. A random material/pressure condition is chosen, and its true/predicted deformed PCA are displayed. These PCA scores can be visualized by copying them into test.py and running:
python3 test.pyTo make sure code is up-to-date, follow either of the following:
- Navigate to the parent directory DL-Cardiac (above src and clones) and update the src code using:
git pullRepeat this command in each of the cloned repositories.
- To automatically update this repo (still testing): In the src/ folder, run:
python3 update.py