CardiacMeshDataset#

class CardiacMeshDataset(mesh, mesh_numbers, timing_ms)[source]#

Cardiac mesh model assuming the continuous node-ordering:

[apex, n_points_per_ring(1st slice, 1st shell), n_points_per_ring(2st slice, 1st shell), …, n_points_per_ring(1st slice, 2nd shell)]

shell –> radial slice –> longitudinal

Parameters:
  • mesh (Union[UnstructuredGrid, DataSet]) – pyvista mesh containing the field-array ‘displacement_{time}ms’ for each time specified in timing_ms

  • mesh_numbers ((int, int, int)) – (shells, circ, long)

  • timing_ms (ndarray) – array containing the times corresponding to the stored displacements

Methods:

compute_cylinder_coords(time_stamp)

Computes cylinder coordinates (transmural_depth, polar_angle, z-pos) for all mesh nodes.

compute_local_basis(time_stamp[, keys])

Computes the local coordinate system (radial, circumferential, longitudinal) for a left ventricle mesh.

evaluate_cellsize(points, connectivity)

Evaluates cell centers and cell volumes for the tetra-mesh given as points and connectivity.

evaluate_connectivity(n_theta, n_radial, ...)

Generates connectivity for tetrahedral UnstructuredGrid in vtk format Inputs: - n_theta : number of points along circumferential contour (n points for each ring) - n_radial : number of points along longitudinal direction - n_layers : number of points along radial direction

evaluate_cylinder_coordinates(...)

type positional_vectors:

ndarray

from_list_of_arrays(initial_mesh, ...[, ...])

Loads a mesh and its displacements from a list of numpy files each containing the positional vectors for all points in initial_mesh.

from_list_of_meshes(list_of_files, timing, ...)

Loads vti/vtk files that contain the motion states of the same mesh, calculates the displacements from positional differences and returns a CardicMeshDataset instance containing the displacements

from_single_vtk(file_name, mesh_numbers[, ...])

Loads a vtk-file that contains the displacements

interpolate_mesh(mesh_points[, ...])

Function to linear interpolate points of LV meshes in circular, longitudinal and

refine(longitudinal_factor, ...)

Refines the cardiac mesh model assuming the continuous node-ordering:

Attributes:

mesh_numbers

(n_shells, n_points_per_ring, n_slices)

compute_cylinder_coords(time_stamp)[source]#

Computes cylinder coordinates (transmural_depth, polar_angle, z-pos) for all mesh nodes.

Parameters:

time_stamp (Quantity) – time Quantity used to determine reference mesh configuration

compute_local_basis(time_stamp, keys=('e_t', 'e_c', 'e_l'))[source]#

Computes the local coordinate system (radial, circumferential, longitudinal) for a left ventricle mesh. The local basis vectors per point are stored with specified keys

Parameters:
  • time_stamp (Quantity) – time Quantity used to determine reference mesh configuration

  • keys (Tuple[str, str, str]) – array names used to store (radial, circumferential, longitudinal) basis vectors

static evaluate_cellsize(points, connectivity)[source]#

Evaluates cell centers and cell volumes for the tetra-mesh given as points and connectivity.

Parameters:
  • points (ndarray) – (#points, 3)

  • connectivity (ndarray) – (#cells, 4)

Return type:

(ndarray, ndarray, ndarray)

Returns:

cell_center (#cells, 3), cell_volumes (#cells), point_weights (#points)

static evaluate_connectivity(n_theta, n_radial, n_layers)[source]#

Generates connectivity for tetrahedral UnstructuredGrid in vtk format Inputs:

  • n_theta : number of points along circumferential contour (n points for each ring)

  • n_radial : number of points along longitudinal direction

  • n_layers : number of points along radial direction

Outputs:
  • connectivity : connectivity array where row i contains the vertex id of points

defining tetrahedron with index i

Dr. Buoso Stefano (2020) email: buoso@biomed.ee.ethz

Parameters:
  • n_theta (int) –

  • n_radial (int) –

  • n_layers (int) –

static evaluate_cylinder_coordinates(positional_vectors, n_shells, points_per_shell)[source]#
Parameters:
  • positional_vectors (ndarray) – (-1, 3)

  • n_shells (int) – (int)

  • points_per_shell (int) – (int)

Returns:

np.ndarray (-1, 3) [radial, angle, relative z]

classmethod from_list_of_arrays(initial_mesh, mesh_numbers, list_of_files, timing, time_precision_ms=1)[source]#

Loads a mesh and its displacements from a list of numpy files each containing the positional vectors for all points in initial_mesh.

Raises:

FileNotFoundError - if not all files in given list of files exist

Parameters:
  • initial_mesh (DataSet) – Initial mesh configuration

  • mesh_numbers ((int, int, int)) – (shells, circ, long)

  • list_of_files (List) – List of .npy containing the position of all mesh nodes per time

  • timing (Quantity) –

  • time_precision_ms (int) – number of decimals used in the field name and timepoints (e.g. displacements_0.01ms)

classmethod from_list_of_meshes(list_of_files, timing, mesh_numbers, field_key='displacement', time_precision_ms=1)[source]#

Loads vti/vtk files that contain the motion states of the same mesh, calculates the displacements from positional differences and returns a CardicMeshDataset instance containing the displacements

Raises:

FileNotFoundError - if not all files in given list of files exist

Parameters:
  • list_of_files (List) – List of .vtk or .vti files each containing a mesh in which the displacement vectors for each node is stored under the name of specified by the argument field_key

  • timing (Quantity) –

  • mesh_numbers ((int, int, int)) – (shells, circ, long)

  • field_key (str) – key to extract

  • time_precision_ms (int) – number of decimals used in the field name and timepoints (e.g. displacements_0.01ms)

Return type:

CardiacMeshDataset

classmethod from_single_vtk(file_name, mesh_numbers, time_precision_ms=3)[source]#

Loads a vtk-file that contains the displacements

Parameters:
  • file_name (str) –

  • mesh_numbers ((int, int, int)) – (shells, circ, long)

  • time_precision_ms (int) – number of decimals used in the field name and timepoints (e.g. displacements_0.01ms)

Returns:

static interpolate_mesh(mesh_points, points_per_ring=40, n_shells=4, n_slices=30, interp_factor_c=1, interp_factor_l=1, interp_factor_r=1)[source]#
Function to linear interpolate points of LV meshes in circular, longitudinal and
radial direction. Indexing of the points is assumed to adhere to the following structure:

0th element -> Apex 1:points_per_ring+1 -> inner most shell most apical slice. Repeated for n_slices. Repeated for n_shells.

Parameters:
  • mesh_points (ndarray) – np.ndarray - (-1, 3) Flattened array of 3D positional vectors of mesh points.

  • points_per_ring (int) – (int) number of points per ring (circumferential direction)

  • n_shells (int) – (int) number of shells (radial direction)

  • n_slices (int) – (int) number of slices (longitudinal direction)

  • interp_factor_c (int) – (int) interpolation multiplier for circumferential direction

  • interp_factor_l (int) – (int) interpolation multiplier for longitudinal direction

  • interp_factor_r (int) – (int) interpolation multiplier for radial direction

Return type:

(ndarray, Tuple[int, int, int])

Returns:

np.ndarray - (n_shell_new, 1 + (n_theta_new*n_slices_new), 3), (n_theta_new, n_slices_new, n_shells_new)

refine(longitudinal_factor, circumferential_factor, radial_factor)[source]#

Refines the cardiac mesh model assuming the continuous node-ordering:

[apex, n_points_per_ring(1st slice, 1st shell), n_points_per_ring(2st slice, 1st shell), …, n_points_per_ring(1st slice, 2nd shell)]

shell –> radial slice –> longitudinal

Parameters:
  • longitudinal_factor (int) – nl_new = f * nl_old

  • circumferential_factor (int) – nc_new = n

  • radial_factor (int) –

Return type:

CardiacMeshDataset

Returns:

New CardiacMeshDataset instance with refined mesh and new in

mesh: Union[UnstructuredGrid, DataSet]#

Mesh containing the displacements for each time-point

mesh_numbers: Tuple[int, int, int]#

(n_shells, n_points_per_ring, n_slices)

timing: ndarray#

Time points corresponding to the mesh states given by the list of files in ms