Skip to content

Commit f806b44

Browse files
committed
Update hh.py to show plots of driving force and m3h etc.
1 parent 1cc93f6 commit f806b44

3 files changed

Lines changed: 58 additions & 14 deletions

File tree

Tutorial/Source/HodgkinHuxley.py

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def __init__(self, C_m=1, gmax_Na=120, gmax_K=36, gmax_L=0.3, E_Na=50,
1515
I_inj_amplitude=0, I_inj_duration=0, I_inj_delay=0,
1616
vc_delay=10, vc_duration=30, vc_condVoltage=-65,
1717
vc_testVoltage=10, vc_returnVoltage=-65, runMode='iclamp',
18-
injected_current_plot=True, gating_plot=True, cond_dens_plot=True,
18+
injected_current_plot=True, gating_plot=True, scaling_plot=True,
19+
cond_dens_plot=True, driving_force_plot=True,
1920
current_plot=True, memb_pot_plot=True):
2021

2122
self.C_m = C_m
@@ -78,12 +79,15 @@ def __init__(self, C_m=1, gmax_Na=120, gmax_K=36, gmax_L=0.3, E_Na=50,
7879
# plotting conditionals
7980
self.injected_current_plot = injected_current_plot
8081
self.gating_plot = gating_plot
82+
self.scaling_plot = scaling_plot
8183
self.cond_dens_plot = cond_dens_plot
84+
self.driving_force_plot = driving_force_plot
8285
self.current_plot = current_plot
8386
self.memb_pot_plot = memb_pot_plot
8487

8588
self.num_plots = (int(self.injected_current_plot) +
86-
int(self.gating_plot) + int(self.cond_dens_plot) +
89+
int(self.gating_plot)+ int(self.scaling_plot) +
90+
int(self.cond_dens_plot) + int(self.driving_force_plot) +
8791
int(self.current_plot) + int(self.memb_pot_plot))
8892

8993
self.plot_count = 0
@@ -310,10 +314,24 @@ def Main(self, init_values=[-64.99584, 0.05296, 0.59590, 0.31773]):
310314
except NameError:
311315
ax1 = plt.subplot(self.num_plots,1,self.plot_count + 1)
312316
plt.title('Simulation of Hodgkin Huxley model neuron')
313-
plt.plot(self.t, m, 'r', label='m')
314-
plt.plot(self.t, h, 'g', label='h')
315-
plt.plot(self.t, n, 'b', label='n')
316-
plt.ylabel('Gating Variable')
317+
plt.plot(self.t, m, 'r', label='$m$')
318+
plt.plot(self.t, h, 'g', label='$h$')
319+
plt.plot(self.t, n, 'b', label='$n$')
320+
plt.ylabel('Gating variable')
321+
plt.legend()
322+
self.plot_count += 1
323+
324+
if self.scaling_plot:
325+
try:
326+
plt.subplot(self.num_plots,1,self.plot_count+1, sharex = ax1)
327+
except NameError:
328+
ax1 = plt.subplot(self.num_plots,1,self.plot_count + 1)
329+
plt.title('Simulation of Hodgkin Huxley model neuron')
330+
scale_na = m*m*m*h
331+
scale_k = n*n*n*n
332+
plt.plot(self.t, scale_na, 'c', label='$m^{3}h$')
333+
plt.plot(self.t, scale_k, 'y', label='$n^{4}$')
334+
plt.ylabel('Cond scaling')
317335
plt.legend()
318336
self.plot_count += 1
319337

@@ -325,8 +343,34 @@ def Main(self, init_values=[-64.99584, 0.05296, 0.59590, 0.31773]):
325343
plt.title('Simulation of Hodgkin Huxley model neuron')
326344
plt.plot(self.t, gna, 'c', label='$g_{Na}$')
327345
plt.plot(self.t, gk, 'y', label='$g_{K}$')
328-
plt.ylabel('Cond. dens ($mS/cm^2$)')
346+
plt.ylabel('Cond dens ($mS/cm^2$)')
347+
plt.legend()
348+
self.plot_count += 1
349+
350+
351+
if self.driving_force_plot:
352+
try:
353+
ax_here = plt.subplot(self.num_plots,1,self.plot_count+1, sharex = ax1)
354+
except NameError:
355+
ax1 = plt.subplot(self.num_plots,1,self.plot_count + 1)
356+
plt.title('Simulation of Hodgkin Huxley model neuron')
357+
ax_here = ax1
358+
359+
dna = V - self.E_Na
360+
dk = V - self.E_K
361+
zero = [0 for v in V]
362+
363+
#plt.plot(self.t, dna, 'c', label='$V - E_{Na}$')
364+
ax_here.fill_between(self.t, dna, color='c', alpha=0.5)
365+
ax_here.fill_between(self.t, dk, color='y', alpha=0.5)
366+
367+
plt.plot(self.t, dna, 'c', label='$V - E_{Na}$', linewidth=0.8)
368+
plt.plot(self.t, dk, 'y', label='$V - E_{K}$', linewidth=0.8)
369+
plt.plot(self.t, zero, 'k', linestyle='dashed', linewidth=0.5)
370+
plt.ylabel('Driving force (mV)')
329371
plt.legend()
372+
#if not self.is_vclamp(): plt.ylim(-85,60)
373+
#plt.ylim(-1, 40)
330374
self.plot_count += 1
331375

332376
if self.current_plot:
@@ -338,7 +382,7 @@ def Main(self, init_values=[-64.99584, 0.05296, 0.59590, 0.31773]):
338382
plt.plot(self.t, ina, 'c', label='$I_{Na}$')
339383
plt.plot(self.t, ik, 'y', label='$I_{K}$')
340384
plt.plot(self.t, il, 'm', label='$I_{L}$')
341-
plt.ylabel('Current ($\\mu{A}/cm^2$)')
385+
plt.ylabel('Curr dens ($\\mu{A}/cm^2$)')
342386
plt.legend()
343387
self.plot_count += 1
344388

@@ -350,7 +394,7 @@ def Main(self, init_values=[-64.99584, 0.05296, 0.59590, 0.31773]):
350394
plt.title('Simulation of Hodgkin Huxley model neuron')
351395
plt.plot(self.t, V, 'k')
352396
plt.ylabel('$V_{m}$ (mV)')
353-
plt.xlabel('t (ms)')
397+
plt.xlabel('Time (ms)')
354398
if not self.is_vclamp(): plt.ylim(-85,60)
355399
#plt.ylim(-1, 40)
356400
self.plot_count += 1

Tutorial/Source/hhcell.cell.nml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2"
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.githubusercontent.com/NeuroML/NeuroML2/master/Schemas/NeuroML2/NeuroML_v2beta3.xsd"
5+
xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.githubusercontent.com/NeuroML/NeuroML2/master/Schemas/NeuroML2/NeuroML_v2.2.xsd"
66
id="hhcell">
77

88
<include href="passiveChan.channel.nml"/> <!-- Include the channel definitions -->
99
<include href="naChan.channel.nml"/>
1010
<include href="kChan.channel.nml"/>
1111

1212
<cell id="hhcell">
13-
13+
1414
<notes>Conductance based cell model NeuroML2 format: standard Hodgkin Huxley model cell with Na, K and passive conductances</notes>
1515

1616
<morphology id="morphology">
@@ -28,7 +28,7 @@
2828
<biophysicalProperties id="bioPhys1">
2929

3030
<membraneProperties>
31-
31+
3232
<channelDensity id="leak" ionChannel="passiveChan" condDensity="0.3 mS_per_cm2" erev="-54.387mV" ion="non_specific"/>
3333
<channelDensity id="naChans" ionChannel="naChan" condDensity="120.0 mS_per_cm2" erev="50.0 mV" ion="na"/>
3434
<channelDensity id="kChans" ionChannel="kChan" condDensity="36 mS_per_cm2" erev="-77mV" ion="k"/>
@@ -49,4 +49,3 @@
4949

5050

5151
</neuroml>
52-

notebooks/Python_HH_version/ui_widget.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ def highlight_slider():
171171
#define toggle button for default values and connect to fucntion call
172172
showValue_togglebtn = ipywidgets.ToggleButton(value=False,description='Default Values',disabled=False,button_style='info',tooltip='Show/Hide default value below') # 'success', 'info', 'warning', 'danger' or ''
173173
showValue_togglebtn.observe(showDefault)
174-
defalultValues = ipywidgets.HTMLMath(value=r"\(C = 1.0\)<br>\(G_{Na} = 120, G_{K} = 36, G_{L} = 0.3\)<br>\(V_{Na} = 50, V_{K} = -77, G_{L} = -54.387\)")
174+
defalultValues = ipywidgets.HTMLMath(value=r"\(C = %s\)<br>\(G_{Na} = %s, G_{K} = %s, G_{L} = %s\)<br>\(E_{Na} = %s, E_{K} = %s, E_{L} = %s\)" % \
175+
(default_capacitance, default_cond_Na, default_cond_K, default_cond_L, default_E_Na, default_E_K, default_E_L))
175176
defalultValues.layout.display = 'none'
176177

177178
#define toggle buttons for iclamp/vclamp run mode

0 commit comments

Comments
 (0)