The laplace_post.py module#

Summary#

read_laplace_solution

Read laplace fields from d3plot files.

update_transmural_by_normal

Use surface normal for transmural direction.

orthogonalization

Create a orthonormal coordinate system.

compute_la_fiber_cs

Compute left atrium fibers coordinate system.

compute_ra_fiber_cs

Compute right atrium fibers coordinate system.

set_rotation_bounds

Define rotation bounds from input parameters.

compute_rotation_angle

Rotate by alpha and beta angles.

compute_ventricle_fiber_by_drbm

Compute the fiber coordinate system from the Laplace solutions.

Description#

Postprocessing script related to Laplace solving (UHC, fibers).

Module detail#

laplace_post.read_laplace_solution(directory: str, field_list: list[str], read_heatflux: bool = False) pyvista.UnstructuredGrid#

Read laplace fields from d3plot files.

Parameters:
directorystr

Directory of d3plot files.

field_listlist[str]

Name of each d3plot file/field.

read_heatfluxbool, default: False

Whether to read heatflux.

Returns:
pv.UnstructuredGrid

Grid with point data of each field.

laplace_post.update_transmural_by_normal(grid: pyvista.UnstructuredGrid, surface: pyvista.PolyData) numpy.ndarray#

Use surface normal for transmural direction.

Parameters:
gridpv.UnstructuredGrid

Atrium grid.

surfacepv.PolyData

Atrium endocardium surface.

Returns:
np.ndarray

Cell transmural direction vector.

Notes

Assume mesh is coarse compared to the thickness. Solid cell normal is interpolated from closest surface normal.

laplace_post.orthogonalization(e1: numpy.ndarray, e2: numpy.ndarray) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]#

Create a orthonormal coordinate system.

Parameters:
e1np.ndarray

First unit (N,M) vector of the coordinate system.

e2np.ndarray

Second unit (N,M) vector of the coordinate system.

Returns:
tuple[np.ndarray, np.ndarray, np.ndarray]

Local orthonormal coordinate system e1, e2, e3.

Notes

e3 is orthogonal to the plane spanned by e1 and e2 following the right hand rule. Project e2 onto e1, and subtract to ensure orthogonality.

laplace_post.compute_la_fiber_cs(directory: str, settings: ansys.health.heart.settings.settings.AtrialFiber, endo_surface: pyvista.PolyData = None) pyvista.UnstructuredGrid#

Compute left atrium fibers coordinate system.

Parameters:
directorystr

Directory of d3plot files.

settingsAtrialFiber

Atrial fiber settings.

endo_surfacepv.PolyData, default: None

Endocardium surface mesh. If provided, normal direction is updated by the surface normal instead of the Laplace solution.

Returns:
pv.UnstructuredGrid

PV object with fiber coordinates system.

Notes

This method is described in Modeling cardiac muscle fibers in ventricular and atrial electrophysiology simulations.

laplace_post.compute_ra_fiber_cs(directory: str, settings: ansys.health.heart.settings.settings.AtrialFiber, endo_surface: pyvista.PolyData = None) pyvista.UnstructuredGrid#

Compute right atrium fibers coordinate system.

Parameters:
directorystr

Directory of d3plot files.

settingsAtrialFiber

Atrial fiber settings.

endo_surfacepv.PolyData, default: None

Endocardium surface mesh. If provided, normal direction is updated by the surface normal instead of the Laplace solution.

Returns:
pv.UnstructuredGrid

PV object with the fiber coordinates system.

Notes

This method is described in Modeling cardiac muscle fibers in ventricular and atrial electrophysiology simulations.

laplace_post.set_rotation_bounds(w: numpy.ndarray, endo: float, epi: float, outflow_tracts: list[float, float] = None) tuple[numpy.ndarray, numpy.ndarray]#

Define rotation bounds from input parameters.

Parameters:
wnp.ndarray

Intra-ventricular interpolation weight if outflow_tracts is not None.

endofloat

Rotation angle at endocardium.

epifloat

Rotation angle at epicardium.

outflow_tractslist[float, float], default: None

Rotation angle of enendocardium do and epicardium on outflow tract.

Returns:
tuple[np.ndarray, np.ndarray]

Cell-wise rotation bounds for endocardium and epicardium.

laplace_post.compute_rotation_angle(grid: pyvista.UnstructuredGrid, w: numpy.ndarray, rotation: list[float, float], outflow_tracts: list[float, float] = None) numpy.ndarray#

Rotate by alpha and beta angles.

Parameters:
gridpv.UnstructuredGrid

Mesh grid.

wnp.ndarray

Intral ventricular interpolation weight.

rotationlist[float, float]

Rotation angles in degrees at endocardium and epicardium.

outflow_tractslist[float, float], default: None

Rotation angle of enendocardium do and epicardium on outflow tract.

Returns:
np.ndarray

Cell-wise rotation angles.

Notes

Compute for all cells, but filter by left/right mask outside of this function.

laplace_post.compute_ventricle_fiber_by_drbm(directory: str, settings: dict = {'alpha_left': [60, -60], 'alpha_right': [90, -25], 'alpha_ot': None, 'beta_left': [-65, 25], 'beta_right': [-65, 25], 'beta_ot': None}, left_only: bool = False) pyvista.UnstructuredGrid#

Compute the fiber coordinate system from the Laplace solutions.

Parameters:
directorystr

Directory of d3plot/tprint files.

settingsdict[str, list[float] | None]

Rotation angles for fiber generation. The defaults are {"alpha_left": [60, -60], "alpha_right": [90, -25], "alpha_ot": None, "beta_left": [-65, 25], "beta_right": [-65, 25], "beta_ot": None}.

left_onlybool, default: False

Whether to only compute fibers on the left ventricle.

Returns:
pv.UnstructuredGrid

Grid containing fiber, cross-fiber, and sheet vectors.

Notes

The D-RBM method is described in Modeling cardiac muscle fibers in ventricular and atrial electrophysiology simulations.