Spaces:
Running
Running
Franny Dean
commited on
Commit
•
c8eaa36
1
Parent(s):
97f0f9a
attempt figure animation
Browse files- .ipynb_checkpoints/app-checkpoint.py +19 -20
- app.py +19 -20
.ipynb_checkpoints/app-checkpoint.py
CHANGED
@@ -458,11 +458,11 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
|
|
458 |
fig, ax = plt.subplots()
|
459 |
plt.ylim((0,220))
|
460 |
plt.xlim((0,250))
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
|
467 |
fig.suptitle('Predicted PI-SSL LV Pressure Volume Loop', fontsize=16)
|
468 |
#plt.rcParams['fig.suptitle'] = -2.0
|
@@ -474,14 +474,13 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
|
|
474 |
# fig.subplots_adjust(left=0.25, bottom=0.25)
|
475 |
|
476 |
def update(frame):
|
477 |
-
#
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
anim = animation.FuncAnimation(fig=fig, func=update, frames=40, interval=30)
|
485 |
|
486 |
return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
|
487 |
|
@@ -551,13 +550,13 @@ with gr.Blocks() as demo:
|
|
551 |
|
552 |
|
553 |
with gr.Row():
|
554 |
-
sl1 = gr.Slider(0.005, 0.1, value
|
555 |
-
sl2 = gr.Slider(0.0001, 0.25, value
|
556 |
-
sl3 = gr.Slider(0.5, 3.5, value
|
557 |
-
sl4 = gr.Slider(0.02, 0.1, value=
|
558 |
-
sl5 = gr.Slider(4.0, 25.0, value=
|
559 |
-
sl6 = gr.Slider(0.4, 1.7, value=
|
560 |
-
sl7 = gr.Slider(0.0, 280.0, value=
|
561 |
|
562 |
|
563 |
generate_button.click(fn=generate_example, outputs = [video,plot,Rm,Ra,Emax,Emin,Vd,Tc,start_v])
|
|
|
458 |
fig, ax = plt.subplots()
|
459 |
plt.ylim((0,220))
|
460 |
plt.xlim((0,250))
|
461 |
+
start = (N-2)*60000
|
462 |
+
end = (N-2)*60000+50000
|
463 |
+
line = ax.plot(volumes[start:(start+1)], pressures[start:(start+1)], lw=1, color='b')
|
464 |
+
point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
|
465 |
+
|
466 |
|
467 |
fig.suptitle('Predicted PI-SSL LV Pressure Volume Loop', fontsize=16)
|
468 |
#plt.rcParams['fig.suptitle'] = -2.0
|
|
|
474 |
# fig.subplots_adjust(left=0.25, bottom=0.25)
|
475 |
|
476 |
def update(frame):
|
477 |
+
# update to add more of the loop
|
478 |
+
end = (N-2)*60000+1000 * frame
|
479 |
+
x = volumes[start:end]
|
480 |
+
y = pressures[start:end]
|
481 |
+
ax.plot(x, y, lw=1, c='b')
|
482 |
+
|
483 |
+
anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
|
|
|
484 |
|
485 |
return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
|
486 |
|
|
|
550 |
|
551 |
|
552 |
with gr.Row():
|
553 |
+
sl1 = gr.Slider(0.005, 0.1, value=.005, label="Rm")
|
554 |
+
sl2 = gr.Slider(0.0001, 0.25, value=.0001, label="Ra")
|
555 |
+
sl3 = gr.Slider(0.5, 3.5, value=.5, label="Emax")
|
556 |
+
sl4 = gr.Slider(0.02, 0.1, value= .02, label="Emin")
|
557 |
+
sl5 = gr.Slider(4.0, 25.0, value= 4.0, label="Vd")
|
558 |
+
sl6 = gr.Slider(0.4, 1.7, value= 0.4, label="Tc")
|
559 |
+
sl7 = gr.Slider(0.0, 280.0, value= 140., label="start_v")
|
560 |
|
561 |
|
562 |
generate_button.click(fn=generate_example, outputs = [video,plot,Rm,Ra,Emax,Emin,Vd,Tc,start_v])
|
app.py
CHANGED
@@ -458,11 +458,11 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
|
|
458 |
fig, ax = plt.subplots()
|
459 |
plt.ylim((0,220))
|
460 |
plt.xlim((0,250))
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
|
467 |
fig.suptitle('Predicted PI-SSL LV Pressure Volume Loop', fontsize=16)
|
468 |
#plt.rcParams['fig.suptitle'] = -2.0
|
@@ -474,14 +474,13 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
|
|
474 |
# fig.subplots_adjust(left=0.25, bottom=0.25)
|
475 |
|
476 |
def update(frame):
|
477 |
-
#
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
anim = animation.FuncAnimation(fig=fig, func=update, frames=40, interval=30)
|
485 |
|
486 |
return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
|
487 |
|
@@ -551,13 +550,13 @@ with gr.Blocks() as demo:
|
|
551 |
|
552 |
|
553 |
with gr.Row():
|
554 |
-
sl1 = gr.Slider(0.005, 0.1, value
|
555 |
-
sl2 = gr.Slider(0.0001, 0.25, value
|
556 |
-
sl3 = gr.Slider(0.5, 3.5, value
|
557 |
-
sl4 = gr.Slider(0.02, 0.1, value=
|
558 |
-
sl5 = gr.Slider(4.0, 25.0, value=
|
559 |
-
sl6 = gr.Slider(0.4, 1.7, value=
|
560 |
-
sl7 = gr.Slider(0.0, 280.0, value=
|
561 |
|
562 |
|
563 |
generate_button.click(fn=generate_example, outputs = [video,plot,Rm,Ra,Emax,Emin,Vd,Tc,start_v])
|
|
|
458 |
fig, ax = plt.subplots()
|
459 |
plt.ylim((0,220))
|
460 |
plt.xlim((0,250))
|
461 |
+
start = (N-2)*60000
|
462 |
+
end = (N-2)*60000+50000
|
463 |
+
line = ax.plot(volumes[start:(start+1)], pressures[start:(start+1)], lw=1, color='b')
|
464 |
+
point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
|
465 |
+
|
466 |
|
467 |
fig.suptitle('Predicted PI-SSL LV Pressure Volume Loop', fontsize=16)
|
468 |
#plt.rcParams['fig.suptitle'] = -2.0
|
|
|
474 |
# fig.subplots_adjust(left=0.25, bottom=0.25)
|
475 |
|
476 |
def update(frame):
|
477 |
+
# update to add more of the loop
|
478 |
+
end = (N-2)*60000+1000 * frame
|
479 |
+
x = volumes[start:end]
|
480 |
+
y = pressures[start:end]
|
481 |
+
ax.plot(x, y, lw=1, c='b')
|
482 |
+
|
483 |
+
anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
|
|
|
484 |
|
485 |
return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
|
486 |
|
|
|
550 |
|
551 |
|
552 |
with gr.Row():
|
553 |
+
sl1 = gr.Slider(0.005, 0.1, value=.005, label="Rm")
|
554 |
+
sl2 = gr.Slider(0.0001, 0.25, value=.0001, label="Ra")
|
555 |
+
sl3 = gr.Slider(0.5, 3.5, value=.5, label="Emax")
|
556 |
+
sl4 = gr.Slider(0.02, 0.1, value= .02, label="Emin")
|
557 |
+
sl5 = gr.Slider(4.0, 25.0, value= 4.0, label="Vd")
|
558 |
+
sl6 = gr.Slider(0.4, 1.7, value= 0.4, label="Tc")
|
559 |
+
sl7 = gr.Slider(0.0, 280.0, value= 140., label="start_v")
|
560 |
|
561 |
|
562 |
generate_button.click(fn=generate_example, outputs = [video,plot,Rm,Ra,Emax,Emin,Vd,Tc,start_v])
|