cardiac-geometriesx 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cardiac-geometriesx might be problematic. Click here for more details.

@@ -7,6 +7,58 @@ from ..utils import space_from_string
7
7
  from . import utils
8
8
 
9
9
 
10
+ def mu_theta(
11
+ x: np.ndarray, y: np.ndarray, z: np.ndarray, long_axis: int = 0
12
+ ) -> tuple[np.ndarray, np.ndarray, list[int]]:
13
+ """Get the angles mu and theta from the coordinates x, y, z
14
+ given the long axis.
15
+
16
+ Parameters
17
+ ----------
18
+ x : np.ndarray
19
+ The x-coordinates
20
+ y : np.ndarray
21
+ The y-coordinates
22
+ z : np.ndarray
23
+ The z-coordinates
24
+ long_axis : int, optional
25
+ The long axis, by default 0 (x-axis)
26
+
27
+ Returns
28
+ -------
29
+ tuple[np.ndarray, np.ndarray, list[int]]
30
+ The angles mu and theta and the permutation of the axes
31
+
32
+ Raises
33
+ ------
34
+ ValueError
35
+ If the long axis is not 0, 1 or 2
36
+ """
37
+ if long_axis == 0:
38
+ a = np.sqrt(y**2 + z**2)
39
+ b = x
40
+ theta = np.pi - np.arctan2(z, -y)
41
+ perm = [0, 1, 2]
42
+ elif long_axis == 1:
43
+ a = np.sqrt(x**2 + z**2)
44
+ b = y
45
+ theta = np.pi - np.arctan2(z, -x)
46
+ perm = [1, 0, 2]
47
+ elif long_axis == 2:
48
+ a = np.sqrt(x**2 + y**2)
49
+ b = z
50
+ theta = np.pi - np.arctan2(x, -y)
51
+ perm = [2, 1, 0]
52
+ else:
53
+ raise ValueError("Invalid long_axis")
54
+
55
+ mu = np.arctan2(a, b)
56
+
57
+ theta[mu < 1e-7] = 0.0
58
+
59
+ return mu, theta, perm
60
+
61
+
10
62
  def compute_system(
11
63
  t_func: dolfinx.fem.Function,
12
64
  r_short_endo=0.025,
@@ -15,8 +67,36 @@ def compute_system(
15
67
  r_long_epi=0.097,
16
68
  alpha_endo: float = -60,
17
69
  alpha_epi: float = 60,
70
+ long_axis: int = 0,
18
71
  **kwargs,
19
72
  ) -> utils.Microstructure:
73
+ """Compute the microstructure for the given time function.
74
+
75
+ Parameters
76
+ ----------
77
+ t_func : dolfinx.fem.Function
78
+ Solution of the Laplace equation
79
+ r_short_endo : float, optional
80
+ Short radius at the endocardium, by default 0.025
81
+ r_short_epi : float, optional
82
+ Short radius at the epicardium, by default 0.035
83
+ r_long_endo : float, optional
84
+ Long radius at the endocardium, by default 0.09
85
+ r_long_epi : float, optional
86
+ Long radius at the epicardium, by default 0.097
87
+ alpha_endo : float, optional
88
+ Angle at the endocardium, by default -60
89
+ alpha_epi : float, optional
90
+ Angle at the epicardium, by default 60
91
+ long_axis : int, optional
92
+ Long axis, by default 0 (x-axis)
93
+
94
+ Returns
95
+ -------
96
+ utils.Microstructure
97
+ The microstructure
98
+ """
99
+
20
100
  V = t_func.function_space
21
101
  element = V.ufl_element()
22
102
  mesh = V.mesh
@@ -40,11 +120,7 @@ def compute_system(
40
120
  y = dof_coordinates[:, 1]
41
121
  z = dof_coordinates[:, 2]
42
122
 
43
- a = np.sqrt(y**2 + z**2) / rs
44
- b = x / rl
45
- mu = np.arctan2(a, b)
46
- theta = np.pi - np.arctan2(z, -y)
47
- theta[mu < 1e-7] = 0.0
123
+ mu, theta, perm = mu_theta(x, y, z, long_axis=long_axis)
48
124
 
49
125
  e_t = np.array(
50
126
  [
@@ -52,7 +128,7 @@ def compute_system(
52
128
  drs_dt * np.sin(mu) * np.cos(theta),
53
129
  drs_dt * np.sin(mu) * np.sin(theta),
54
130
  ],
55
- )
131
+ )[perm]
56
132
  e_t = utils.normalize(e_t)
57
133
 
58
134
  e_mu = np.array(
@@ -61,7 +137,7 @@ def compute_system(
61
137
  rs * np.cos(mu) * np.cos(theta),
62
138
  rs * np.cos(mu) * np.sin(theta),
63
139
  ],
64
- )
140
+ )[perm]
65
141
  e_mu = utils.normalize(e_mu)
66
142
 
67
143
  e_theta = np.array(
@@ -70,7 +146,7 @@ def compute_system(
70
146
  -rs * np.sin(mu) * np.sin(theta),
71
147
  rs * np.sin(mu) * np.cos(theta),
72
148
  ],
73
- )
149
+ )[perm]
74
150
  e_theta = utils.normalize(e_theta)
75
151
 
76
152
  f0 = np.sin(al) * e_mu + np.cos(al) * e_theta
@@ -113,6 +189,7 @@ def create_microstructure(
113
189
  r_long_epi=0.097,
114
190
  alpha_endo: float = -60,
115
191
  alpha_epi: float = 60,
192
+ long_axis: int = 0,
116
193
  outdir: str | Path | None = None,
117
194
  ):
118
195
  endo_marker = markers["ENDO"][0]
@@ -143,6 +220,7 @@ def create_microstructure(
143
220
  r_long_epi=r_long_epi,
144
221
  alpha_endo=alpha_endo,
145
222
  alpha_epi=alpha_epi,
223
+ long_axis=long_axis,
146
224
  )
147
225
  if outdir is not None:
148
226
  utils.save_microstructure(mesh, system, outdir)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cardiac-geometriesx
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A python library for cardiac geometries
5
5
  Author-email: Henrik Finsberg <henriknf@simula.no>
6
6
  License: MIT
@@ -5,12 +5,12 @@ cardiac_geometries/gui.py,sha256=9WYR850wLrqsUrVUC37E2SaO0OWA_oagSe-YNrsxz3k,837
5
5
  cardiac_geometries/mesh.py,sha256=JSm69BTS7WRUldwaQ9-Gnjq_KbX66FTnl2ouFKRtFhA,26825
6
6
  cardiac_geometries/utils.py,sha256=EwEXAuB4XiJaqlZaGZ1cc6sIBSPJLCx-43As1NUcJrA,16488
7
7
  cardiac_geometries/fibers/__init__.py,sha256=WpRrn9Iakl-3m8IGtFkqP0LXGjw5EZHZ8Eg9JCnCdrg,137
8
- cardiac_geometries/fibers/lv_ellipsoid.py,sha256=jFloAhrFRkKrhsWVKcOiZrGioPLBN3_yiIXiyr1mHCQ,3665
8
+ cardiac_geometries/fibers/lv_ellipsoid.py,sha256=KuWnx9yZ5KDyoeoYyDnXLZYb82DRiNveZyNIboD3uJ8,5768
9
9
  cardiac_geometries/fibers/slab.py,sha256=5tMvOSqXQ4_nbdUUtho_tQjDrmICxZfN7SXNq4FKdlY,3836
10
10
  cardiac_geometries/fibers/utils.py,sha256=j1ERqXcdaWCwO2yjbYGlgTt2G1DxZCVzbNHuDhh_QrM,2541
11
- cardiac_geometriesx-0.2.0.dist-info/LICENSE,sha256=lo5K2rJPZOSv6luutGHbzzi3IpXNaB9E2UWq60qvNx0,1111
12
- cardiac_geometriesx-0.2.0.dist-info/METADATA,sha256=VHm0LNhB1GsjrcY8fPTJH0C6UzvV01FW07kIxgmVAwc,4163
13
- cardiac_geometriesx-0.2.0.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
14
- cardiac_geometriesx-0.2.0.dist-info/entry_points.txt,sha256=xOBnlc6W-H9oCDYLNz3kpki26OmpfYSoFSrmi_4V-Ec,52
15
- cardiac_geometriesx-0.2.0.dist-info/top_level.txt,sha256=J0gQxkWR2my5Vf7Qt8buDY8ZOjYdVfIweVunCGXWKNE,19
16
- cardiac_geometriesx-0.2.0.dist-info/RECORD,,
11
+ cardiac_geometriesx-0.3.0.dist-info/LICENSE,sha256=lo5K2rJPZOSv6luutGHbzzi3IpXNaB9E2UWq60qvNx0,1111
12
+ cardiac_geometriesx-0.3.0.dist-info/METADATA,sha256=xfAjdCgXBkVeMi-R2psGWeh2t2Y0wBPHxcVJ5m6_6MU,4163
13
+ cardiac_geometriesx-0.3.0.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
14
+ cardiac_geometriesx-0.3.0.dist-info/entry_points.txt,sha256=xOBnlc6W-H9oCDYLNz3kpki26OmpfYSoFSrmi_4V-Ec,52
15
+ cardiac_geometriesx-0.3.0.dist-info/top_level.txt,sha256=J0gQxkWR2my5Vf7Qt8buDY8ZOjYdVfIweVunCGXWKNE,19
16
+ cardiac_geometriesx-0.3.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.2.0)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5