-
Notifications
You must be signed in to change notification settings - Fork 49
adding fiber generation codes #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
javijv4
wants to merge
19
commits into
SimVascular:main
Choose a base branch
from
javijv4:dev_#479
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b010f79
adding fiber generation codes
javijv4 c36a6b8
increasing linear solver max iterations
javijv4 c401a9a
changing paths and README.md
javijv4 f15a136
adding .pngs for fiber, sheet, sheetnormal directions
javijv4 6fd7d15
updating README.md
javijv4 6941248
Merge branch 'main' into dev_#479
aabrown100-git 63d5e7c
Merge branch 'main' into dev_#479
javijv4 b5dde5c
object oriented implementation; updated documentation; added validation
javijv4 f86777e
updating surfaces names;
javijv4 fc2a7fd
Merge branch 'main' into dev_#479
aabrown100-git 065cd44
changing svfsi to svmultiphysics
javijv4 1380666
setting coherent convention; fixing vectorized rodrigues
javijv4 ff5ae3f
cleaning up and updating paraview files
javijv4 9f19ff2
changing names of example folders; modifying Doste to assign 2/3 of t…
javijv4 aeacf6c
Merge branch 'main' into dev_#479
aabrown100-git a71e017
package is working; renaming scripts
javijv4 bdf7183
moving rescaling outside gradient function
javijv4 d9aa81c
forcing paraview to use white background
javijv4 fe67a44
accidentally deleted paraview scripts are back
javijv4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # svMultiPhysics fiber generation codes | ||
| Python + svMultiPhysics codes for fiber generation. Two methods are implemented: | ||
| * Bayer et al. (2012). [link](https://doi.org/10.1007/s10439-012-0593-5) | ||
| * Doste et al. (2018). [link](https://doi.org/10.1002/cnm.3185) | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Installing as a Python Package | ||
| You can install the `fiber_generation` codes as a package using pip: | ||
|
|
||
| ```bash | ||
| pip install -e . | ||
| ``` | ||
| This will install all the required packages and will allow you to call the functions in these packages from any directory. | ||
|
|
||
| ## Examples | ||
| The `main_bayer.py` and `main_doste.py` are scripts to run both methods in the geometry described in the `example/biv_truncated` and `example/biv_with_outflow_tracts` folders respectively. | ||
|
|
||
| <img src="example/biv_truncated/bayer_fiber.png" alt="Results for truncated BiV (Bayer)" width="640" /> | ||
| <img src="example/biv_with_outflow_tracts/doste_fiber.png" alt="Results for BiV w/ outflow tracts (Doste)" width="640" /> | ||
|
|
||
| Note that the Doste methods needs a geometry with outflow tracts to be run (each valve needs to be defined as a separated surface). Bayer can be run in any biventricular geometry. | ||
|
|
||
|
|
||
| ### Documentation | ||
| For details ont the implementation and an study of the results, see: | ||
| - [DOCUMENTATION.md](DOCUMENTATION.md) - Comprehensive documentation on methods and usage | ||
| - [VALIDATION.md](VALIDATION.md) - Validation studies | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| # Results and validation | ||
|
|
||
| This document presents validation results for fiber generation using two methods: the Bayer method and the Doste method. | ||
|
|
||
| The `examples` folder contains two geometries: a truncated biventricle (`examples/truncated`) for the Bayer method and a biventricle with outflow tracts (`examples/ot`) for the Doste method. | ||
|
|
||
| Validation scripts (`validation_bayer.py` and `validation_doste.py`) can be run to generate the correlation plots shown below. ParaView Python scripts (`paraview_bayer.py` and `paraview_doste.py`) can be used to generate the different visualization views (fiber, sheet, sheet-normal orientations) for each case. | ||
|
|
||
| The validation codes first calculate the $\alpha$ and $\beta$ angles using scalar interpolations. Then, the $\alpha$ and $\beta$ angles are calculated from the fiber direction $\mathbf f$ and the orthogonal basis $(\mathbf e_c, \mathbf e_\ell, \mathbf e_t)$. | ||
|
|
||
| We do this for three combinations of parameters: | ||
| 1. Setting all $\alpha$ to default values, and all $\beta$ to 0. | ||
| 2. Setting all $\alpha$ to 0, and all $\beta$ to default values. | ||
| 3. Setting all $\alpha$ and $\beta$ to default values. | ||
|
|
||
| This allows to isolate and identify issues in the $\alpha$ and $\beta$ rotations. | ||
|
|
||
| Ideally both scalar interpolated and fiber derived angles should match exactly, but given that the orthogonal basis $(\mathbf e_c, \mathbf e_\ell, \mathbf e_t)$ also needs to be interpolated some differences arise. | ||
|
|
||
|
|
||
| Notes: | ||
| - To run the `validation*.py` scripts the file with the Laplace results must be created. This can be done using the `main*.py` scripts. | ||
| - To run the `paraview*.py` you must run the `validation*.py` codes first. | ||
| - `paraview*.py` codes are run within the Paraview GUI. To do so, | ||
| 1. Open Paraview, go to the Python Shell (if not visible, go to View, and click so it appears, usually at the bottom panel). | ||
| 2. Click on Run Script and select the desire script. | ||
|
|
||
| --- | ||
|
|
||
| ## Bayer Method | ||
|
|
||
| The Bayer method results are demonstrated on a truncated biventricular geometry. | ||
|
|
||
| ### Fiber Orientation | ||
|
|
||
|  | ||
|
|
||
| *Figure 1: Fiber orientation field generated using the Bayer method - full view* | ||
|
|
||
|  | ||
|
|
||
| *Figure 2: Fiber orientation field generated using the Bayer method - slice view* | ||
|
|
||
| ### Sheet Orientation | ||
|
|
||
|  | ||
|
|
||
| *Figure 3: Sheet orientation field generated using the Bayer method - full view* | ||
|
|
||
|  | ||
|
|
||
| *Figure 4: Sheet orientation field generated using the Bayer method - slice view* | ||
|
|
||
| ### Sheet-Normal Orientation | ||
|
|
||
|  | ||
|
|
||
| *Figure 5: Sheet-normal orientation field generated using the Bayer method - full view* | ||
|
|
||
|  | ||
|
|
||
| *Figure 6: Sheet-normal orientation field generated using the Bayer method - slice view* | ||
|
|
||
| ### Angle Correlations | ||
|
|
||
| To check the code, we first calculate the $\alpha$ and $\beta$ angles using scalar interpolations. Then, we calculate the $\alpha$ and $\beta$ angles using the fiber direction $\mathbf f$ and the orthogonal basis $\mathbf e_c$, $\mathbf e_\ell$, $\mathbf e_t$. | ||
|
|
||
|  | ||
|
|
||
| *Figure 7: Correlation plots comparing scalar interpolation angles with fiber derived angles for the Bayer method. Blue and red dots show the $\alpha$ and $\beta$ angles. For reference, the original Bayer method with no modifications is shown.* | ||
|
|
||
| --- | ||
|
|
||
| ## Doste Method | ||
|
|
||
| The Doste method results are demonstrated on a complete biventricular geometry with outflow tracts. | ||
|
|
||
| ### Fiber Orientation | ||
|
|
||
|  | ||
|
|
||
| *Figure 8: Fiber orientation field generated using the Doste method - full view* | ||
|
|
||
|  | ||
|
|
||
| *Figure 9: Fiber orientation field generated using the Doste method - slice view* | ||
|
|
||
| ### Sheet Orientation | ||
|
|
||
|  | ||
|
|
||
| *Figure 10: Sheet orientation field generated using the Doste method - full view* | ||
|
|
||
|  | ||
|
|
||
| *Figure 11: Sheet orientation field generated using the Doste method - slice view* | ||
|
|
||
| ### Sheet-Normal Orientation | ||
|
|
||
|  | ||
|
|
||
| *Figure 12: Sheet-normal orientation field generated using the Doste method - full view* | ||
|
|
||
|  | ||
|
|
||
| *Figure 13: Sheet-normal orientation field generated using the Doste method - slice view* | ||
|
|
||
| ### Angle Correlations | ||
|
|
||
|  | ||
|
|
||
| *Figure 14: Correlation plots comparing scalar interpolation angles with fiber derived angles for the Doste method. Blue and red dots show the $\alpha$ and $\beta$ angles** | ||
|
|
||
| --- |
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/bayer_angle_correlations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/bayer_fiber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/bayer_fiber_slice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/bayer_sheet-normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/bayer_sheet-normal_slice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/bayer_sheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/bayer_sheet_slice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/betaendo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/flipping.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/mesh-surfaces/BASE.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/mesh-surfaces/EPI.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/mesh-surfaces/EPI_APEX.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/mesh-surfaces/EPI_MID.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/mesh-surfaces/LV.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/mesh-surfaces/RV.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_truncated/mesh-surfaces/exterior.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
...s/fiber_generation/example/biv_with_outflow_tracts/doste_angle_correlations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/doste_fiber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/doste_fiber_slice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/doste_sheet-normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...s/fiber_generation/example/biv_with_outflow_tracts/doste_sheet-normal_slice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/doste_sheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/doste_sheet_slice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-complete.mesh.vtu
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-surfaces/av.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-surfaces/endo_lv.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-surfaces/endo_rv.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-surfaces/epi.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-surfaces/epi_apex.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-surfaces/mv.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-surfaces/pv.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-surfaces/top.vtp
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
utilities/fiber_generation/example/biv_with_outflow_tracts/mesh-surfaces/tv.vtp
Git LFS file not shown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| """Fiber generation package for biventricular heart models. | ||
|
|
||
| This package provides classes and utilities to generate myocardial fiber | ||
| orientations for biventricular heart models using Laplace-Dirichlet | ||
| rule-based methods. | ||
|
|
||
| Modules: | ||
| fiber_generator: Core fiber generation classes (FibGen, FibGenBayer, FibGenDoste) | ||
| laplace_solver: Laplace-Dirichlet equation solver | ||
| surface_names: Surface name definitions for heart geometry | ||
| surface_utils: Utility functions for surface operations | ||
| quat_utils: Quaternion utilities for rotation operations | ||
| """ | ||
|
|
||
| from fiber_generation.fiber_generator import FibGen, FibGenBayer, FibGenDoste | ||
| from fiber_generation.laplace_solver import LaplaceSolver | ||
| from fiber_generation.surface_names import SurfaceName | ||
|
|
||
| __all__ = [ | ||
| 'FibGen', | ||
| 'FibGenBayer', | ||
| 'FibGenDoste', | ||
| 'LaplaceSolver', | ||
| 'SurfaceName', | ||
| ] | ||
|
|
||
| __version__ = '0.1.0' |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.