Spaces:
Running
Running
Franny Dean
commited on
Commit
•
3d2cf31
1
Parent(s):
9a02a49
animation changed to animate
Browse files- .ipynb_checkpoints/app-checkpoint.py +5 -5
- app.py +5 -5
.ipynb_checkpoints/app-checkpoint.py
CHANGED
@@ -427,7 +427,7 @@ def solve_ODE_for_volume(Rm, Ra, Emax, Emin, Vd, Tc, start_v, t):
|
|
427 |
|
428 |
return volumes
|
429 |
|
430 |
-
def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v,
|
431 |
|
432 |
|
433 |
# Define initial parameters
|
@@ -461,7 +461,7 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animation=True):
|
|
461 |
plt.xlim((0,250))
|
462 |
start = (N-2)*60000
|
463 |
end = (N-2)*60000+50000
|
464 |
-
if
|
465 |
line = ax.plot(volumes[start:(start+1)], pressures[start:(start+1)], lw=1, color='b')
|
466 |
point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
|
467 |
else:
|
@@ -483,14 +483,14 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animation=True):
|
|
483 |
y = pressures[start:end]
|
484 |
ax.plot(x, y, lw=1, c='b')
|
485 |
|
486 |
-
if
|
487 |
anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
|
488 |
anim.save("prediction.mp4")
|
489 |
|
490 |
return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
|
491 |
|
492 |
def pvloop_simulator_plot_only(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
|
493 |
-
plot,_,_,_,_,_,_,_ =pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v,
|
494 |
plt.title('Simulated PI-SSL LV Pressure Volume Loop', fontsize=16)
|
495 |
return plot
|
496 |
|
@@ -506,7 +506,7 @@ def generate_example():
|
|
506 |
val_seq = val_data[0]
|
507 |
|
508 |
val_tensor = torch.tensor(val_seq, dtype=torch.float32)
|
509 |
-
n=random.randint(0,
|
510 |
results = model(val_tensor)[n]
|
511 |
|
512 |
filename = val_data[1][0][n]
|
|
|
427 |
|
428 |
return volumes
|
429 |
|
430 |
+
def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animate=True):
|
431 |
|
432 |
|
433 |
# Define initial parameters
|
|
|
461 |
plt.xlim((0,250))
|
462 |
start = (N-2)*60000
|
463 |
end = (N-2)*60000+50000
|
464 |
+
if animate:
|
465 |
line = ax.plot(volumes[start:(start+1)], pressures[start:(start+1)], lw=1, color='b')
|
466 |
point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
|
467 |
else:
|
|
|
483 |
y = pressures[start:end]
|
484 |
ax.plot(x, y, lw=1, c='b')
|
485 |
|
486 |
+
if animate:
|
487 |
anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
|
488 |
anim.save("prediction.mp4")
|
489 |
|
490 |
return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
|
491 |
|
492 |
def pvloop_simulator_plot_only(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
|
493 |
+
plot,_,_,_,_,_,_,_ =pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animate=False)
|
494 |
plt.title('Simulated PI-SSL LV Pressure Volume Loop', fontsize=16)
|
495 |
return plot
|
496 |
|
|
|
506 |
val_seq = val_data[0]
|
507 |
|
508 |
val_tensor = torch.tensor(val_seq, dtype=torch.float32)
|
509 |
+
n=random.randint(0, 27)
|
510 |
results = model(val_tensor)[n]
|
511 |
|
512 |
filename = val_data[1][0][n]
|
app.py
CHANGED
@@ -427,7 +427,7 @@ def solve_ODE_for_volume(Rm, Ra, Emax, Emin, Vd, Tc, start_v, t):
|
|
427 |
|
428 |
return volumes
|
429 |
|
430 |
-
def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v,
|
431 |
|
432 |
|
433 |
# Define initial parameters
|
@@ -461,7 +461,7 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animation=True):
|
|
461 |
plt.xlim((0,250))
|
462 |
start = (N-2)*60000
|
463 |
end = (N-2)*60000+50000
|
464 |
-
if
|
465 |
line = ax.plot(volumes[start:(start+1)], pressures[start:(start+1)], lw=1, color='b')
|
466 |
point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
|
467 |
else:
|
@@ -483,14 +483,14 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animation=True):
|
|
483 |
y = pressures[start:end]
|
484 |
ax.plot(x, y, lw=1, c='b')
|
485 |
|
486 |
-
if
|
487 |
anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
|
488 |
anim.save("prediction.mp4")
|
489 |
|
490 |
return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
|
491 |
|
492 |
def pvloop_simulator_plot_only(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
|
493 |
-
plot,_,_,_,_,_,_,_ =pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v,
|
494 |
plt.title('Simulated PI-SSL LV Pressure Volume Loop', fontsize=16)
|
495 |
return plot
|
496 |
|
@@ -506,7 +506,7 @@ def generate_example():
|
|
506 |
val_seq = val_data[0]
|
507 |
|
508 |
val_tensor = torch.tensor(val_seq, dtype=torch.float32)
|
509 |
-
n=random.randint(0,
|
510 |
results = model(val_tensor)[n]
|
511 |
|
512 |
filename = val_data[1][0][n]
|
|
|
427 |
|
428 |
return volumes
|
429 |
|
430 |
+
def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animate=True):
|
431 |
|
432 |
|
433 |
# Define initial parameters
|
|
|
461 |
plt.xlim((0,250))
|
462 |
start = (N-2)*60000
|
463 |
end = (N-2)*60000+50000
|
464 |
+
if animate:
|
465 |
line = ax.plot(volumes[start:(start+1)], pressures[start:(start+1)], lw=1, color='b')
|
466 |
point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
|
467 |
else:
|
|
|
483 |
y = pressures[start:end]
|
484 |
ax.plot(x, y, lw=1, c='b')
|
485 |
|
486 |
+
if animate:
|
487 |
anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
|
488 |
anim.save("prediction.mp4")
|
489 |
|
490 |
return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
|
491 |
|
492 |
def pvloop_simulator_plot_only(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
|
493 |
+
plot,_,_,_,_,_,_,_ =pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animate=False)
|
494 |
plt.title('Simulated PI-SSL LV Pressure Volume Loop', fontsize=16)
|
495 |
return plot
|
496 |
|
|
|
506 |
val_seq = val_data[0]
|
507 |
|
508 |
val_tensor = torch.tensor(val_seq, dtype=torch.float32)
|
509 |
+
n=random.randint(0, 27)
|
510 |
results = model(val_tensor)[n]
|
511 |
|
512 |
filename = val_data[1][0][n]
|