Giter VIP home page Giter VIP logo

soft-tissue-pignn's Introduction

Physics-Informed Graph Neural Network Emulation of Soft-Tissue Mechanics (CMAME 2023)

Online version: https://www.sciencedirect.com/science/article/pii/S0045782523004759

This repository contains Python scripts to perform the Physics-Informed Graph Neural Network (PI-GNN) emulation experiments as described in the above paper. Please cite this paper if you use the code:

@article{daltonPIGNN2023,
    title = {Physics-informed graph neural network emulation of soft-tissue mechanics},
    journal = {Computer Methods in Applied Mechanics and Engineering},
    volume = {417},
    pages = {116351},
    year = {2023},
    issn = {0045-7825},
    author = {David Dalton and Dirk Husmeier and Hao Gao},
    keywords = {Soft-tissue mechanics, Graph neural networks, Physics-informed machine learning},
}

Left Ventricle Emulation Results

Environment Setup

Experiments are performed in Python, using the JAX, Flax and Optax libraries.

Assuming conda is installed, a virtual environment with the required packages can be set up using the below shell commands. Firstly, create and activate a new environment.

conda create --name pignnEmulationEnv
conda activate pignnEmulationEnv

OPTIONAL - install Paraview, which is used to create 3D visualisations of the results.

conda install -c conda-forge paraview

Finally, use pip to install remaining packages.

pip install --upgrade "jax[cuda11_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
pip install flax
pip install tensorflow
pip install absl-py
pip install -U scikit-learn

The specific versions of these packages we used were jax 0.4.16 (jaxlib 0.4.16+cuda11.cudnn86 ), flax 0.7.4, tensorflow 2.13.0, absl-py 2.0.0 and scikit-learn 1.3.1. Other required packages, such as optax, are installed automatically with the above commands.

Warning on Paraview Install

Unfortunately I have found it difficult sometimes to install paraview on Linux, depending on the machine (it generally works fine on Windows). Or sometimes it will install correctly, but then a warning appears when I try to load the paraview.simple package. For additional installation instructions, see here and here. If you cannot get paraview installed correctly, the rest of the code relating to training and evaluating the PIGNN emulator will still work.

Running Experiments

Various datasets from the manuscript are included in the data subdirectory. Physics-informed training and subsequent evaluation on the test data can then be run by calling main.py from the shell. For example, to train for 1000 epochs on the Liver model and then predict on the test data, run:

python -m main --mode="train_and_evaluate" --data_path="Liver" --n_epochs=1000

Pretrained Emulators

Pre-trained emulation parameters for the TwistingBeam, Liver and LeftVentricle models are stored in emulationResults/trainedParameters. Instructions on how to make predictions using these parameters are given in PRETRAINED_EMULATORS.md.

Monitoring Training

Tensorboard can be used to monitor training, for example for the Liver data by running:

tensorboard --logdir=emulationResults/Liver

and then following the instructions printed to the console.

Other Comments

  • Varying Input Geometry - The data handling code in this repository has been written assuming that a fixed soft-tissue geometry is of interest. If you wish to model data where the input geometry can vary, see the data handling code in dodaltuin/passive-lv-gnn-emul.
  • Left Ventricle Data - The data provided here in data/LeftVentricle assumes a fixed blood pressure of 8 mmHg is applied to the inner surface of the LV. This is slightly different to the model considered in the paper, where the blood pressure varied in the range [4,10] mmHg. The data handling code had been written assumed that pressure would be fixed. During the revision process, a reviewer asked us to consider emulation of the LeftVentricle model where the pressure value varies. To account for varying pressure values, we made use of an adjustment which breaks generalisability of the code, so we do not make it public. The results in either case are almost identical.

Directory Layout

Files:

Main script to call PI-GNN emulation

Implements PrimalGraphEmulator GNN emulation architecture

utils_*

Various script containing utility functions for data handling, potential energy evaluation, model training, etc

Details how predictions can be made using pre-trained emulation parameters

Subdirectories:

Stores data on each model (such as geometry, constitutive law, etc) and test simulation data generated using FEniCS used for evaluating of emulation performance. See the data/README.md file for further details

Stores the trained emulator parameters and predictions.

soft-tissue-pignn's People

Contributors

dodaltuin avatar

Stargazers

Jin-Hu Pan avatar  avatar  avatar  avatar Gyksyj avatar  avatar Jiang Bingyue avatar Shi Yihao avatar Ehsan Naghavi avatar Tianyi Li avatar PierceTheWorld avatar  avatar  avatar Dennis Ogiermann avatar  avatar  avatar Shuo HAO avatar Jijo Derick Abraham avatar Mitchel Colebank avatar

Watchers

 avatar  avatar  avatar

soft-tissue-pignn's Issues

Material Parameters Problem

Dear David,
In the TwistingCube part, the E is [1,25] in your code(as well as your article) , what's the unit of E ?
We are tring to perform the steel matertial with E = 210e9. The problem is the train_loss is very huge
image
How to solve this problem?

Another question is the loading of each part seems the same. If I want to change the loading, what can I do? Should I retrain the model, which is timeconsuming.

Thank you very much!

Data Preprocessing for Custom Soft Tissue Models?

Hello, thank you for providing the open-source code!

Now I want to apply custom soft tissue data (such as kidney.stl and kidney.vtk) to the network, but I have some questions about the data preprocessing steps.

I noticed the TwistingBeamUnprocessed folder, which already contains files like elements.npy and interior-points.npy. The DATA_FORMAT_REQUIREMENTS.md also details the contents of each .npy file, but what preprocessing steps are needed to obtain these .npy files?
Also, is the FE mesh mentioned in DATA_FORMAT_REQUIREMENTS.md generated by FEniCS as mentioned in the paper or obtained using other tools?

Could you please provide more detailed information regarding these aspects? Thank you in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.