Skip to main content

CI github pages

Laplace-Dirichlet Rule-Based (LDRB) algorithm for assigning myocardial fiber orientations

A software for assigning myocardial fiber orientations based on the Laplace Dirichlet Ruled-Based algorithm.

Bayer, J.D., Blake, R.C., Plank, G. and Trayanova, N.A., 2012. A novel rule-based algorithm for assigning myocardial fiber orientation to computational heart models. Annals of biomedical engineering, 40(10), pp.2243-2254.(https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3518842/)

# Generate an example geometry using https://github.com/ComputationalPhysiology/cardiac_geometries
import cardiac_geometries  # pip install cardiac-geometries
import ldrb

geo = cardiac_geometries.mesh.create_biv_ellipsoid(char_length=0.2)

# Decide on the angles you want to use
angles = dict(
    alpha_endo_lv=30,  # Fiber angle on the LV endocardium
    alpha_epi_lv=-30,  # Fiber angle on the LV epicardium
    beta_endo_lv=0,  # Sheet angle on the LV endocardium
    beta_epi_lv=0,  # Sheet angle on the LV epicardium
    alpha_endo_sept=60,  # Fiber angle on the Septum endocardium
    alpha_epi_sept=-60,  # Fiber angle on the Septum epicardium
    beta_endo_sept=0,  # Sheet angle on the Septum endocardium
    beta_epi_sept=0,  # Sheet angle on the Septum epicardium
    alpha_endo_rv=80,  # Fiber angle on the RV endocardium
    alpha_epi_rv=-80,  # Fiber angle on the RV epicardium
    beta_endo_rv=0,  # Sheet angle on the RV endocardium
    beta_epi_rv=0,  # Sheet angle on the RV epicardium
)

# Convert markers to correct format
markers = {
    "base": geo.markers["BASE"][0],
    "lv": geo.markers["ENDO_LV"][0],
    "rv": geo.markers["ENDO_RV"][0],
    "epi": geo.markers["EPI"][0],
}

# Choose space for the fiber fields
# This is a string on the form {family}_{degree}
fiber_space = "P_2"

# Compute the microstructure
fiber, sheet, sheet_normal = ldrb.dolfin_ldrb(
    mesh=geo.mesh, fiber_space=fiber_space, ffun=geo.ffun, markers=markers, **angles
)
# Store files using a built in xdmf viewer that also works for functions
# defined in quadrature spaces
ldrb.fiber_to_xdmf(fiber, "fiber")
# And visualize it in Paraview

_

Installation

pip

In order to install the software you need to have installed FEniCS (versions older than 2016 are not supported)

The package can be installed with pip.

python3 -m pip install ldrb

or if you need the most recent version you can install the source

python3 -m pip install git+https://github.com/finsberg/ldrb.git

Issues with h5py

You might run into issues with incompatible version of h5py. To resolve this you can try to first uninstall the existing version

python3 -m pip uninstall h5py

and then reinstall h5py from source using the command

python3 -m pip install h5py --no-binary=h5py

Conda

ldrb is also available on conda

conda install -c conda-forge ldrb

Docker

If you don't already have FEniCS installed you can use one of the provided docker images, e.g

docker pull ghcr.io/finsberg/ldrb:latest

to pull the image and use the following command to start a container and sharing your current directory

docker run --rm -v $PWD:/home/shared -w /home/shared -it ghcr.io/finsberg/ldrb:latest

Documentation

Documentation is hosted at http://finsberg.github.io/ldrb

Getting started

Check out the demos

License

ldrb is licensed under the GNU LGPL, version 3 or (at your option) any later version. ldrb is Copyright (2011-2019) by the authors and Simula Research Laboratory.

Contributors

Henrik Finsberg (henriknf@simula.no)

Release files for ldrb 2025.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ldrb 2025.0.1
File Size Uploaded
ldrb-2025.0.1.tar.gz 22.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ldrb 2025.0.1
File Interpreter ABI Platform
ldrb-2025.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.4 kB

Release files / ldrb-2025.0.1.tar.gz

Download URL ldrb-2025.0.1.tar.gz
Size 22.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f17205bc3004762e8d66346695ddfc95ebb5566cff2d90cf7e6deebb98545534
BLAKE2b-256 checksum
How to use checksums
c7dacb2d02aa6d30fda530acbe1cb37b5284773d4804801b255e526e617a099a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / ldrb-2025.0.1-py3-none-any.whl

Download URL ldrb-2025.0.1-py3-none-any.whl
Size 19.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39fb92b93b9783fa5c4cf7f51e848077cbdb64e2614457e825cefc1b698e46dc
BLAKE2b-256 checksum
How to use checksums
590762427623bf39a1aec175fc99eaa6845a7e721401efb1eae9448d65f99344
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page