-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtentusscher-2006-dynamic.mmt
86 lines (68 loc) · 2.08 KB
/
tentusscher-2006-dynamic.mmt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
[[protocol]]
# Level Start Length Period Multiplier
1 100 0.5 1000 0
[[script]]
import myokit
import matplotlib.pyplot as pl
### Ten-Tusscher Dynamic Restitution Protocol- Figure 5F/J ###
### ------------------------------------------------------ ###
# Get the model
m = myokit.load_model('tentusscher-2006.mmt')
step_size = 30
apd_duration = []
di = []
period = []
pcl_list = []
pcl = 350
while pcl < 950:
print pcl
#Initialising protocol with new pacing
p = myokit.pacing.blocktrain(pcl, 0.5, offset=0, level=1.0, limit=0)
s = myokit.Simulation(m, p,apd_var='membrane.V')
#Pre pacing for 48 beats, trying to settle to steady-state
s.pre(pcl * 48)
vt = 0.9 * s.state()[m.get('membrane.V').indice()]
# Running for 2 cycles
d, apds = s.run(2*pcl, apd_threshold=vt)
# Calulating APD for penultimate beat
duration0 = apds['duration'][0]
# APD for final beat
duration1 = apds['duration'][1]
apd_duration.append(duration1)
#DI equal to the pcl - APD of penultimate beat
DI = pcl - duration0
di.append(DI)
# Pacing cycle length
period.append(pcl)
# Resetting simulation to previous pre-beat
s.reset()
pcl += step_size
# Plotting APD vs DI for dynamic protocol
pl.figure()
pl.xlabel('Diastole interval (ms)')
pl.ylabel('APD 90 (ms)')
pl.title('Ten-Tusscher (2006)- Dynamic restitution curve (Fig. 5F)')
pl.xlim(0,600)
pl.plot(di, apd_duration)
pl.plot(di, apd_duration, 'x')
# Plotting APD vs Period for dynamic protocol
pl.figure()
pl.xlabel('Period (ms)')
pl.ylabel('APD 90 (ms)')
pl.title('Ten-Tusscher (2006)- Dynamic restitution curve (Fig. 5J)')
pl.xlim(0,800)
pl.ylim(100,325)
pl.plot(period, apd_duration)
pl.plot(period, apd_duration, 'x')
pl.show()
# Calculating gradients
grad_list = []
max_grad = 0
for i in range(1, len(apd_duration)):
y_dif = apd_duration[i]- apd_duration[i-1]
x_dif = di[i] - di[i-1]
grad = float(y_dif / x_dif)
grad_list.append(grad)
if grad > max_grad:
max_grad = grad
print('Max slope- dynamic', max_grad)