Skip to content

Commit 2e2f3da

Browse files
authored
Merge pull request #26 from irahulsonkar/master
test
2 parents a902f9e + fb31aec commit 2e2f3da

26 files changed

Lines changed: 1574 additions & 1156 deletions

.github/workflows/non-omv.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Non OMV tests
2+
3+
on:
4+
push:
5+
branches: [ master, development, experimental ]
6+
pull_request:
7+
branches: [ master, development, experimental ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [ 3.7, 3.9 ]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Test python HH
26+
run: |
27+
pip install scipy matplotlib
28+
cd Tutorial/Source
29+
python HodgkinHuxley.py

.github/workflows/omv-ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
name: Continuous build using OMV
3+
4+
on:
5+
push:
6+
branches: [ master, development, experimental ]
7+
pull_request:
8+
branches: [ master, development, experimental ]
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: [ 3.7, 3.9 ]
18+
engine: [ jNeuroML_Brian2, jNeuroML, jNeuroML_NEURON, jNeuroML_NetPyNE, jNeuroML_EDEN, jNeuroML_validate, jNeuroML_PyNN_NEURON ]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install OMV
29+
run: |
30+
pip install git+https://github.com/OpenSourceBrain/osb-model-validation
31+
pip install scipy sympy matplotlib cython pandas tables
32+
33+
- name: Run OMV tests on engine ${{ matrix.engine }}
34+
run: |
35+
omv all -V --engine=${{ matrix.engine }}
36+
37+
- name: OMV final version info
38+
run: |
39+
omv list -V # list installed engines
40+
env

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ Tutorial/Source/*json
3333
/Tutorial/Source/tests.log
3434
/tests.log
3535
/Tutorial/Source/*_brian.py
36+
*code.gen.*
37+
*_eden.py
38+
**/.ipynb_checkpoints/

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ It can be accessed on the Open Source Brain site at this location: http://www.op
2424

2525
See also http://www.opensourcebrain.org/projects/hodgkin-huxley-tutorial.
2626

27-
[![Build Status](https://travis-ci.org/openworm/hodgkin_huxley_tutorial.svg?branch=master)](https://travis-ci.org/openworm/hodgkin_huxley_tutorial)
28-
27+
[![Continuous build using OMV](https://github.com/openworm/hodgkin_huxley_tutorial/actions/workflows/main.yml/badge.svg)](https://github.com/openworm/hodgkin_huxley_tutorial/actions/workflows/main.yml) [![Non OMV tests](https://github.com/openworm/hodgkin_huxley_tutorial/actions/workflows/non-omv.yml/badge.svg)](https://github.com/openworm/hodgkin_huxley_tutorial/actions/workflows/non-omv.yml)
2928

3029
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1493456.svg)](https://doi.org/10.5281/zenodo.1493456)
3130

Tutorial/Source/HodgkinHuxley.py

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,45 @@
66
class HodgkinHuxley():
77
"""Full Hodgkin-Huxley Model implemented in Python"""
88

9-
C_m = 1.0
10-
"""membrane capacitance, in uF/cm^2"""
11-
12-
g_Na = 120.0
13-
"""Sodium (Na) maximum conductances, in mS/cm^2"""
14-
15-
g_K = 36.0
16-
"""Postassium (K) maximum conductances, in mS/cm^2"""
17-
18-
g_L = 0.3
19-
"""Leak maximum conductances, in mS/cm^2"""
20-
21-
E_Na = 50.0
22-
"""Sodium (Na) Nernst reversal potentials, in mV"""
23-
24-
E_K = -77.0
25-
"""Postassium (K) Nernst reversal potentials, in mV"""
26-
27-
E_L = -54.387
28-
"""Leak Nernst reversal potentials, in mV"""
29-
30-
t = np.arange(0.0, 450.0, 0.01)
31-
""" The time to integrate over """
9+
""" __init__ uses optional arguments """
10+
""" when no argument is passed default values are used """
11+
12+
def __init__(self, C_m=1, g_Na=120, g_K=36, g_L=0.3, E_Na=50, E_K=-77, E_L=-54.387, t_0=0, t_n=450, delta_t=0.01, I_inj_max=0, I_inj_width=0, I_inj_trans=0):
13+
14+
self.C_m = C_m
15+
""" membrane capacitance, in uF/cm^2 """
16+
17+
self.g_Na = g_Na
18+
""" Sodium (Na) maximum conductances, in mS/cm^2 """
19+
20+
self.g_K = g_K
21+
""" Postassium (K) maximum conductances, in mS/cm^2 """
22+
23+
self.g_L = g_L
24+
""" Leak maximum conductances, in mS/cm^2 """
25+
26+
self.E_Na = E_Na
27+
""" Sodium (Na) Nernst reversal potentials, in mV """
28+
29+
self.E_K = E_K
30+
""" Postassium (K) Nernst reversal potentials, in mV """
31+
32+
self.E_L = E_L
33+
""" Leak Nernst reversal potentials, in mV """
34+
35+
self.t = np.arange(t_0, t_n, delta_t)
36+
""" The time to integrate over """
37+
38+
""" Advanced input - injection current (single rectangular pulse only) """
39+
40+
self.I_inj_max = I_inj_max
41+
""" maximum value or amplitude of injection pulse """
42+
43+
self.I_inj_width = I_inj_width
44+
""" duration or width of injection pulse """
45+
46+
self.I_inj_trans = I_inj_trans
47+
""" strart time of injection pulse or tranlation about time axis """
3248

3349
def alpha_m(self, V):
3450
"""Channel gating kinetics. Functions of membrane voltage"""
@@ -98,7 +114,19 @@ def I_inj(self, t):
98114
| step up to 35 uA/cm^2 at t>300
99115
| step down to 0 uA/cm^2 at t>400
100116
"""
101-
return 10*(t>100) - 10*(t>200) + 35*(t>300) - 35*(t>400)
117+
118+
""" running standalone python script """
119+
if __name__ == '__main__':
120+
return 10*(t>100) - 10*(t>200) + 35*(t>300) - 35*(t>400)
121+
122+
#""" running jupyterLab notebook """
123+
#injection current is defined
124+
elif self.I_inj_width>0:
125+
return self.I_inj_max*(t>self.I_inj_trans) - self.I_inj_max*(t>self.I_inj_trans+self.I_inj_width)
126+
127+
#default injection current
128+
else:
129+
return 10*(t>150) - 10*(t>300)
102130

103131
@staticmethod
104132
def dALLdt(X, t, self):
@@ -130,13 +158,22 @@ def Main(self):
130158
ina = self.I_Na(V, m, h)
131159
ik = self.I_K(V, n)
132160
il = self.I_L(V)
133-
134-
plt.figure()
135-
161+
162+
#increase figure and font size for display in jupyter notebook
163+
if __name__ != '__main__':
164+
plt.rcParams['figure.figsize'] = [12, 8]
165+
plt.rcParams['font.size'] = 15
166+
plt.rcParams['legend.fontsize'] = 12
167+
plt.rcParams['legend.loc'] = "upper right"
168+
169+
fig=plt.figure()
170+
136171
ax1 = plt.subplot(4,1,1)
172+
plt.xlim([np.min(self.t),np.max(self.t)]) #for all subplots
137173
plt.title('Hodgkin-Huxley Neuron')
138-
plt.plot(self.t, V, 'k')
139-
plt.ylabel('V (mV)')
174+
i_inj_values = [self.I_inj(t) for t in self.t]
175+
plt.plot(self.t, i_inj_values, 'k')
176+
plt.ylabel('$I_{inj}$ ($\\mu{A}/cm^2$)')
140177

141178
plt.subplot(4,1,2, sharex = ax1)
142179
plt.plot(self.t, ina, 'c', label='$I_{Na}$')
@@ -153,11 +190,10 @@ def Main(self):
153190
plt.legend()
154191

155192
plt.subplot(4,1,4, sharex = ax1)
156-
i_inj_values = [self.I_inj(t) for t in self.t]
157-
plt.plot(self.t, i_inj_values, 'k')
193+
plt.plot(self.t, V, 'k')
194+
plt.ylabel('V (mV)')
158195
plt.xlabel('t (ms)')
159-
plt.ylabel('$I_{inj}$ ($\\mu{A}/cm^2$)')
160-
plt.ylim(-1, 40)
196+
#plt.ylim(-1, 40)
161197

162198
plt.tight_layout()
163199
plt.show()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2+
3+
target: ../LEMS_HH_Simulation.xml
4+
engine: jNeuroML_EDEN
5+
mep: .test.mep
6+
experiments:
7+
Current clamp:
8+
observables:
9+
spike times:
10+
file:
11+
path: ../hh_v.dat
12+
columns: [0,1]
13+
scaling: [1000, 1000]
14+
spike detection:
15+
method: threshold
16+
threshold: 0
17+
tolerance: 0.0016286644951138691
18.9 KB
Loading

Tutorial/_media/figure_1.png

5.48 KB
Loading

0 commit comments

Comments
 (0)