@@ -26,6 +26,13 @@ def setup_subtraction_grid(fig, nsweeps):
26
26
# Long axis for protocol on the bottom (full width)
27
27
long_protocol_ax = fig .add_subplot (gs [5 , :])
28
28
29
+ for ax , cap in zip (list (protocol_axs ) + list (before_axs )
30
+ + list (after_axs ) + list (corrected_axs )
31
+ + [subtracted_ax ] + [long_protocol_ax ],
32
+ 'abcdefghijklm' ):
33
+ ax .spines [['top' , 'right' ]].set_visible (False )
34
+ ax .set_title (cap , loc = 'left' , fontweight = 'bold' )
35
+
29
36
return protocol_axs , before_axs , after_axs , corrected_axs , subtracted_ax , long_protocol_ax
30
37
31
38
@@ -40,9 +47,9 @@ def do_subtraction_plot(fig, times, sweeps, before_currents, after_currents,
40
47
subtracted_ax , long_protocol_ax = axs
41
48
42
49
for ax in protocol_axs :
43
- ax .plot (times , voltages , color = 'black' )
50
+ ax .plot (times * 1e-3 , voltages , color = 'black' )
44
51
ax .set_xlabel ('time (s)' )
45
- ax .set_ylabel (r'$V_\mathrm{command }$ (mV)' )
52
+ ax .set_ylabel (r'$V_\mathrm{cmd }$ (mV)' )
46
53
47
54
all_leak_params_before = []
48
55
all_leak_params_after = []
@@ -62,17 +69,22 @@ def do_subtraction_plot(fig, times, sweeps, before_currents, after_currents,
62
69
np .nan )
63
70
for i , sweep in enumerate (sweeps ):
64
71
65
- gleak , Eleak = all_leak_params_before [i ]
72
+ b0 , b1 = all_leak_params_before [i ]
73
+ gleak = b1
74
+ Eleak = - b1 / b0
66
75
before_leak_currents [i , :] = gleak * (voltages - Eleak )
67
76
68
- gleak , Eleak = all_leak_params_after [i ]
77
+ b0 , b1 = all_leak_params_after [i ]
78
+ gleak = b1
79
+ Eleak = - b1 / b0
80
+
69
81
after_leak_currents [i , :] = gleak * (voltages - Eleak )
70
82
71
83
for i , (sweep , ax ) in enumerate (zip (sweeps , before_axs )):
72
84
gleak , Eleak = all_leak_params_before [i ]
73
- ax .plot (times , before_currents [i , :], label = f"pre-drug raw, sweep { sweep } " )
74
- ax .plot (times , before_leak_currents [i , :],
75
- label = r'$I_\mathrm{leak }$.' f"g={ gleak :1E} , E={ Eleak :.1e} " )
85
+ ax .plot (times * 1e-3 , before_currents [i , :], label = f"pre-drug raw, sweep { sweep } " )
86
+ ax .plot (times * 1e-3 , before_leak_currents [i , :],
87
+ label = r'$I_\mathrm{L }$.' f"g={ gleak :1E} , E={ Eleak :.1e} " )
76
88
# ax.legend()
77
89
78
90
if ax .get_legend ():
@@ -84,9 +96,9 @@ def do_subtraction_plot(fig, times, sweeps, before_currents, after_currents,
84
96
85
97
for i , (sweep , ax ) in enumerate (zip (sweeps , after_axs )):
86
98
gleak , Eleak = all_leak_params_before [i ]
87
- ax .plot (times , after_currents [i , :], label = f"post-drug raw, sweep { sweep } " )
88
- ax .plot (times , after_leak_currents [i , :],
89
- label = r"$I_\mathrm{leak }$." f"g={ gleak :1E} , E={ Eleak :.1e} " )
99
+ ax .plot (times * 1e-3 , after_currents [i , :], label = f"post-drug raw, sweep { sweep } " )
100
+ ax .plot (times * 1e-3 , after_leak_currents [i , :],
101
+ label = r"$I_\mathrm{L }$." f"g={ gleak :1E} , E={ Eleak :.1e} " )
90
102
# ax.legend()
91
103
if ax .get_legend ():
92
104
ax .get_legend ().remove ()
@@ -98,12 +110,12 @@ def do_subtraction_plot(fig, times, sweeps, before_currents, after_currents,
98
110
for i , (sweep , ax ) in enumerate (zip (sweeps , corrected_axs )):
99
111
corrected_before_currents = before_currents [i , :] - before_leak_currents [i , :]
100
112
corrected_after_currents = after_currents [i , :] - after_leak_currents [i , :]
101
- ax .plot (times , corrected_before_currents ,
102
- label = f"leak corrected before drug trace, sweep { sweep } " )
103
- ax .plot (times , corrected_after_currents ,
104
- label = f"leak corrected after drug trace, sweep { sweep } " )
113
+ ax .plot (times * 1e-3 , corrected_before_currents ,
114
+ label = f"leak- corrected pre- drug trace, sweep { sweep } " )
115
+ ax .plot (times * 1e-3 , corrected_after_currents ,
116
+ label = f"leak- corrected post- drug trace, sweep { sweep } " )
105
117
ax .set_xlabel (r'$t$ (s)' )
106
- ax .set_ylabel (r'leak corrected traces' )
118
+ ax .set_ylabel (r'leak- corrected traces' )
107
119
# ax.tick_params(axis='y', rotation=90)
108
120
# ax.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.1e'))
109
121
@@ -118,13 +130,16 @@ def do_subtraction_plot(fig, times, sweeps, before_currents, after_currents,
118
130
119
131
subtracted_currents = before_currents [i , :] - before_leak_currents [i , :] - \
120
132
(after_currents [i , :] - after_leak_currents [i , :])
121
- ax .plot (times , subtracted_currents , label = f"sweep { sweep } " )
133
+ ax .plot (times * 1e-3 , subtracted_currents , label = f"sweep { sweep } " , alpha = .5 )
134
+
135
+ # Cycle to next colour
136
+ ax .plot ([np .nan ], [np .nan ], label = f"sweep { sweep } " , alpha = .5 )
122
137
123
- ax .set_ylabel (r'$I_\mathrm{obs} - I_\mathrm{l }$ (mV)' )
138
+ ax .set_ylabel (r'$I_\mathrm{obs} - I_\mathrm{L }$ (mV)' )
124
139
ax .set_xlabel ('$t$ (s)' )
125
140
126
- long_protocol_ax .plot (times , voltages , color = 'black' )
141
+ long_protocol_ax .plot (times * 1e-3 , voltages , color = 'black' )
127
142
long_protocol_ax .set_xlabel ('time (s)' )
128
- long_protocol_ax .set_ylabel (r'$V_\mathrm{command }$ (mV)' )
143
+ long_protocol_ax .set_ylabel (r'$V_\mathrm{cmd }$ (mV)' )
129
144
long_protocol_ax .tick_params (axis = 'y' , rotation = 90 )
130
145
0 commit comments