Skip to content

Commit

Permalink
Add pcl as input to get_biomarkers (pacing depends on pcl) + fix time…
Browse files Browse the repository at this point in the history
… to min displacement in case we don't start at t=0
  • Loading branch information
cdaversin committed Mar 15, 2024
1 parent 3f52283 commit eca027f
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/simcardems/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,19 +451,25 @@ def extract_biomarkers(
for name, arr in zip(["norm", "x", "y", "z"], [u_norm, ux, uy, uz]):
d[f"max_displacement_{name}"] = np.max(arr)
d[f"min_displacement_{name}"] = np.min(arr)
d[f"time_to_max_displacement_{name}"] = apf.features.time_to_peak(
y=arr,
x=time,
d[f"time_to_max_displacement_{name}"] = (
apf.features.time_to_peak(
y=arr,
x=time,
)
- time[0]
)
d[f"time_to_min_displacement_{name}"] = apf.features.time_to_peak(
y=-arr,
x=time,
d[f"time_to_min_displacement_{name}"] = (
apf.features.time_to_peak(
y=-arr,
x=time,
)
- time[0]
)

return d


def get_biomarkers(results, outdir, num_models):
def get_biomarkers(results, outdir, num_models, pcl):
biomarker_dict = {}
fig, ax = plt.subplots()
for PoMm in range(1, num_models + 1):
Expand All @@ -473,7 +479,7 @@ def get_biomarkers(results, outdir, num_models):
V = results[f"m{PoMm}"]["ep"]["V"]
Ca = results[f"m{PoMm}"]["ep"]["Ca"]
Ta = results[f"m{PoMm}"]["mechanics"]["Ta"]
lmbda = results[f"m{PoMm}"]["mechanics"]["lmbda"]
# lmbda = results[f"m{PoMm}"]["mechanics"]["lmbda"]
u = results[f"m{PoMm}"]["mechanics"]["u"]
inv_lmbda = results[f"m{PoMm}"]["mechanics"]["inv_lmbda"]

Expand All @@ -486,7 +492,7 @@ def get_biomarkers(results, outdir, num_models):
# Create a list with pacing indicators
pacing = np.zeros_like(time)
for i in range(0, len(pacing)):
if time[i] % 1000 <= 0.09 or i == 0:
if time[i] % pcl <= 0.09 or i == 0:
pacing[i] = 1

# Overwrite the variables with data from only the last beat
Expand All @@ -496,9 +502,10 @@ def get_biomarkers(results, outdir, num_models):
pacing,
return_interval=True,
)

Ca = Ca[interval[0] : interval[1]]
Ta = Ta[interval[0] : interval[1]]
lmbda = lmbda[interval[0] : interval[1]]
# lmbda = lmbda[interval[0] : interval[1]]

u = u[interval[0] : interval[1], :]
inv_lmbda = inv_lmbda[interval[0] : interval[1]]
Expand All @@ -515,7 +522,7 @@ def get_biomarkers(results, outdir, num_models):
Ta=Ta,
time=time,
Ca=Ca,
lmbda=lmbda,
# lmbda=lmbda,
inv_lmbda=inv_lmbda,
u=u,
)
Expand Down

0 comments on commit eca027f

Please sign in to comment.