Franny Dean commited on
Commit
a4c401d
1 Parent(s): 7a57c2f

more attempting

Browse files
Files changed (2) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +11 -9
  2. app.py +11 -9
.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
@@ -465,7 +465,7 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
465
  point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
466
 
467
 
468
- fig.suptitle('Predicted PI-SSL LV Pressure Volume Loop', fontsize=16)
469
  #plt.rcParams['fig.suptitle'] = -2.0
470
  #ax.set_title(f'Mitral valve circuit resistance (Rm): {Rm} mmHg*s/ml \n Aortic valve circuit resistance (Ra): {Ra} mmHg*s/ml', fontsize=6)
471
  ax.set_xlabel('LV Volume (ml)')
@@ -480,14 +480,16 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
480
  x = volumes[start:end]
481
  y = pressures[start:end]
482
  ax.plot(x, y, lw=1, c='b')
483
-
484
- anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
485
- anim.save("prediction.mp4")
 
 
486
  return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
487
 
488
  def pvloop_simulator_plot_only(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
489
- plot,_,_,_,_,_,_,_ =pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v)
490
- fig.suptitle('Simulated PI-SSL LV Pressure Volume Loop', fontsize=16)
491
  return plot
492
 
493
  ## Demo
@@ -510,8 +512,8 @@ def generate_example():
510
 
511
  plot, Rm, Ra, Emax, Emin, Vd,Tc, start_v = pvloop_simulator(Rm=round(results[4].item(),2), Ra=round(results[5].item(),2), Emax=results[2].item(), Emin=round(results[3].item(),2), Vd=round(results[6].item(),2), Tc=round(results[0].item(),2), start_v=round(results[1].item(),2))
512
  video = video.replace("avi", "mp4")
513
- animated = "prediction.mp4"
514
- return video, animated, Rm, Ra, Emax, Emin, Vd, Tc, start_v
515
 
516
  title = "Physics-informed self-supervised learning for predicting cardiac digital twins with echocardiography"
517
 
 
427
 
428
  return volumes
429
 
430
+ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animation):
431
 
432
 
433
  # Define initial parameters
 
465
  point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
466
 
467
 
468
+ plt.title('Predicted PI-SSL LV Pressure Volume Loop', fontsize=16)
469
  #plt.rcParams['fig.suptitle'] = -2.0
470
  #ax.set_title(f'Mitral valve circuit resistance (Rm): {Rm} mmHg*s/ml \n Aortic valve circuit resistance (Ra): {Ra} mmHg*s/ml', fontsize=6)
471
  ax.set_xlabel('LV Volume (ml)')
 
480
  x = volumes[start:end]
481
  y = pressures[start:end]
482
  ax.plot(x, y, lw=1, c='b')
483
+
484
+ if(animation):
485
+ anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
486
+ anim.save("prediction.mp4")
487
+
488
  return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
489
 
490
  def pvloop_simulator_plot_only(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
491
+ plot,_,_,_,_,_,_,_ =pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animation=False)
492
+ plt.title('Simulated PI-SSL LV Pressure Volume Loop', fontsize=16)
493
  return plot
494
 
495
  ## Demo
 
512
 
513
  plot, Rm, Ra, Emax, Emin, Vd,Tc, start_v = pvloop_simulator(Rm=round(results[4].item(),2), Ra=round(results[5].item(),2), Emax=results[2].item(), Emin=round(results[3].item(),2), Vd=round(results[6].item(),2), Tc=round(results[0].item(),2), start_v=round(results[1].item(),2))
514
  video = video.replace("avi", "mp4")
515
+ # animated = "prediction.mp4"
516
+ return video, plot, Rm, Ra, Emax, Emin, Vd, Tc, start_v
517
 
518
  title = "Physics-informed self-supervised learning for predicting cardiac digital twins with echocardiography"
519
 
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
@@ -465,7 +465,7 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
465
  point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
466
 
467
 
468
- fig.suptitle('Predicted PI-SSL LV Pressure Volume Loop', fontsize=16)
469
  #plt.rcParams['fig.suptitle'] = -2.0
470
  #ax.set_title(f'Mitral valve circuit resistance (Rm): {Rm} mmHg*s/ml \n Aortic valve circuit resistance (Ra): {Ra} mmHg*s/ml', fontsize=6)
471
  ax.set_xlabel('LV Volume (ml)')
@@ -480,14 +480,16 @@ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
480
  x = volumes[start:end]
481
  y = pressures[start:end]
482
  ax.plot(x, y, lw=1, c='b')
483
-
484
- anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
485
- anim.save("prediction.mp4")
 
 
486
  return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
487
 
488
  def pvloop_simulator_plot_only(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
489
- plot,_,_,_,_,_,_,_ =pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v)
490
- fig.suptitle('Simulated PI-SSL LV Pressure Volume Loop', fontsize=16)
491
  return plot
492
 
493
  ## Demo
@@ -510,8 +512,8 @@ def generate_example():
510
 
511
  plot, Rm, Ra, Emax, Emin, Vd,Tc, start_v = pvloop_simulator(Rm=round(results[4].item(),2), Ra=round(results[5].item(),2), Emax=results[2].item(), Emin=round(results[3].item(),2), Vd=round(results[6].item(),2), Tc=round(results[0].item(),2), start_v=round(results[1].item(),2))
512
  video = video.replace("avi", "mp4")
513
- animated = "prediction.mp4"
514
- return video, animated, Rm, Ra, Emax, Emin, Vd, Tc, start_v
515
 
516
  title = "Physics-informed self-supervised learning for predicting cardiac digital twins with echocardiography"
517
 
 
427
 
428
  return volumes
429
 
430
+ def pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animation):
431
 
432
 
433
  # Define initial parameters
 
465
  point = ax.scatter(volumes[start:(start+1)], pressures[start:(start+1)], c="b", s=5)
466
 
467
 
468
+ plt.title('Predicted PI-SSL LV Pressure Volume Loop', fontsize=16)
469
  #plt.rcParams['fig.suptitle'] = -2.0
470
  #ax.set_title(f'Mitral valve circuit resistance (Rm): {Rm} mmHg*s/ml \n Aortic valve circuit resistance (Ra): {Ra} mmHg*s/ml', fontsize=6)
471
  ax.set_xlabel('LV Volume (ml)')
 
480
  x = volumes[start:end]
481
  y = pressures[start:end]
482
  ax.plot(x, y, lw=1, c='b')
483
+
484
+ if(animation):
485
+ anim = animation.FuncAnimation(fig, partial(update), frames=43, interval=1)
486
+ anim.save("prediction.mp4")
487
+
488
  return plt, Rm, Ra, Emax, Emin, Vd, Tc, start_v
489
 
490
  def pvloop_simulator_plot_only(Rm, Ra, Emax, Emin, Vd, Tc, start_v):
491
+ plot,_,_,_,_,_,_,_ =pvloop_simulator(Rm, Ra, Emax, Emin, Vd, Tc, start_v, animation=False)
492
+ plt.title('Simulated PI-SSL LV Pressure Volume Loop', fontsize=16)
493
  return plot
494
 
495
  ## Demo
 
512
 
513
  plot, Rm, Ra, Emax, Emin, Vd,Tc, start_v = pvloop_simulator(Rm=round(results[4].item(),2), Ra=round(results[5].item(),2), Emax=results[2].item(), Emin=round(results[3].item(),2), Vd=round(results[6].item(),2), Tc=round(results[0].item(),2), start_v=round(results[1].item(),2))
514
  video = video.replace("avi", "mp4")
515
+ # animated = "prediction.mp4"
516
+ return video, plot, Rm, Ra, Emax, Emin, Vd, Tc, start_v
517
 
518
  title = "Physics-informed self-supervised learning for predicting cardiac digital twins with echocardiography"
519