├── NEURON
├── mosinit.py
├── izh2003.gif
├── izhi2003.png
├── izhi2004.gif
├── izhi2007Comparison.pdf
├── .test.2007.jnmlnrn.omt
├── izhi2003b.mod
├── simple.py
├── test.py
├── izhi2003a.mod
├── izhi2007Wrapper.py
├── izhi2007Figs.py
├── izhi2007bS.mod
├── izhi2007b.mod
├── izhi2004a.hoc
├── README.md
├── README
├── izhi2007a.mod
└── izhiGUI.py
├── _osb.yml
├── PyNN
├── results
│ └── README.md
├── README
├── .test.pynnbrian.omt_
├── .test.pynnnest.omt
├── .test.pynnnrn.omt
├── old
│ ├── test_IF_cond_exp.py
│ └── test_Izhikevich.py
└── izhikevich2004.py
├── MATLAB
├── results
│ ├── README.md
│ ├── .test.2007.mep
│ └── .test.2003.mep
├── .test.2007.octave.omt
├── .test.2003.octave.omt
└── izhi2007.m
├── NeuroML2
├── results
│ ├── README.md
│ └── .test.five.mep
├── .test.net.jnml.omt
├── .test.2007cells.mep
├── .test.validate.omt
├── .test.2003.mep
├── .test.five.jnml.omt
├── .test.2007cells.jnmlnrn.omt
├── .test.2007.jnml.omt
├── .test.2007cells.jnml.omt
├── .test.five.pylemsnml2.omt
├── .test.2007.pylemsnml2.omt
├── .test.2007.jnmlbrian2.omt
├── .test.2007.jnmleden.omt
├── .test.2007.jnmlnrn.omt
├── .test.which.jnml.omt
├── .test.which.pylemsnml2.omt
├── LEMS_SmallNetwork.xml
├── LEMS_2007One.xml
├── Izh2007One.net.nml
├── izhikevichCell_to_izhikevich2007Cell.py
├── SmallNetwork.nml
├── LEMS_2007Cells.xml
├── nmllite
│ └── OneCell.py
├── LEMS_FiveCells.xml
├── FiveCells.nml
├── Izh2007Cells.net.nml
├── GeneralizedIzhikevichCell.xml
├── WhichModel.nml
└── LEMS_WhichModel.xml
├── CITATION.md
├── README.md
├── .gitignore
├── .travis.yml
├── .github
└── workflows
│ └── omv-ci.yml
├── LICENSE.txt
└── numba
├── travis_run_numba_model.py
└── izhikevich.py
/NEURON/mosinit.py:
--------------------------------------------------------------------------------
1 | execfile('izhiGUI.py')
2 |
--------------------------------------------------------------------------------
/_osb.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mainModel: NeuroML2/Izh2007Cells.net.nml
3 |
--------------------------------------------------------------------------------
/PyNN/results/README.md:
--------------------------------------------------------------------------------
1 | Folder for PyNN generated result files
2 |
--------------------------------------------------------------------------------
/MATLAB/results/README.md:
--------------------------------------------------------------------------------
1 | Results of simulations on MATLAB/OCTAVE will be generated here
2 |
--------------------------------------------------------------------------------
/NeuroML2/results/README.md:
--------------------------------------------------------------------------------
1 | Results of some of the NML2/LEMS simulations will be saved here
2 |
--------------------------------------------------------------------------------
/NEURON/izh2003.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceBrain/IzhikevichModel/HEAD/NEURON/izh2003.gif
--------------------------------------------------------------------------------
/NEURON/izhi2003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceBrain/IzhikevichModel/HEAD/NEURON/izhi2003.png
--------------------------------------------------------------------------------
/NEURON/izhi2004.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceBrain/IzhikevichModel/HEAD/NEURON/izhi2004.gif
--------------------------------------------------------------------------------
/NEURON/izhi2007Comparison.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceBrain/IzhikevichModel/HEAD/NEURON/izhi2007Comparison.pdf
--------------------------------------------------------------------------------
/NeuroML2/results/.test.five.mep:
--------------------------------------------------------------------------------
1 | system: Test Five
2 |
3 | experiments:
4 | popA:
5 | expected:
6 | spike times: [12.52, 16.03, 28.88, 55.9, 82.67]
7 |
--------------------------------------------------------------------------------
/NeuroML2/.test.net.jnml.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_SmallNetwork.xml
4 | engine: jNeuroML
5 |
--------------------------------------------------------------------------------
/NeuroML2/.test.2007cells.mep:
--------------------------------------------------------------------------------
1 | system: Test 2007 cells
2 |
3 | experiments:
4 |
5 | rs:
6 | expected:
7 | spike times: [47.04, 120.46, 196.55, 272.54, 348.55, 424.53999999999996, 500.53999999999996]
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/MATLAB/results/.test.2007.mep:
--------------------------------------------------------------------------------
1 | system: Test 2007
2 |
3 | experiments:
4 | RS2007_100:
5 | expected:
6 | spike times: [47.0325, 120.4975, 196.6175, 272.6525, 348.6875, 424.7225, 500.76] # Values here worked out with tau=0.0025 in izhi2007.m
7 |
8 |
--------------------------------------------------------------------------------
/PyNN/README:
--------------------------------------------------------------------------------
1 | Contains examples in PyNN using Izhikevich model:
2 | http://neuralensemble.org/docs/PyNN/reference/neuronmodels.html#pyNN.standardmodels.cells.Izhikevich
3 |
4 | See http://www.opensourcebrain.org/projects/izhikevichmodel/wiki for info on issues with present implementation!
5 |
--------------------------------------------------------------------------------
/NeuroML2/.test.validate.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | # This test will validate all of the NeuroML 2 files in the current directory using: jnml -validate *.nml
4 | target: "*.net.nml"
5 | engine: jNeuroML_validate
6 |
--------------------------------------------------------------------------------
/NeuroML2/.test.2003.mep:
--------------------------------------------------------------------------------
1 | system: Test 2003
2 |
3 | experiments:
4 |
5 | A_tonic:
6 | expected:
7 | spike times: [12.52, 16.03, 28.88, 55.9, 82.67]
8 | C_tonicbursting:
9 | expected:
10 | spike times: [24.39, 25.54, 26.78, 28.1, 29.52, 31.07, 32.78, 34.7, 36.93, 39.7, 43.99, 77.95, 79.69, 81.66, 83.96, 86.88, 92.15, 125.97, 127.71, 129.68, 131.98, 134.9, 140.17, 173.98, 175.72, 177.69, 179.99, 182.91, 188.18]
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/NeuroML2/.test.five.jnml.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_FiveCells.xml
4 | engine: jNeuroML
5 | mep: results/.test.five.mep
6 | experiments:
7 | popA:
8 | observables:
9 | spike times:
10 | file:
11 | path: results/izfive_v.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 0.00
--------------------------------------------------------------------------------
/NeuroML2/.test.2007cells.jnmlnrn.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_2007Cells.xml
4 | engine: jNeuroML_NEURON
5 | mep: .test.2007cells.mep
6 | experiments:
7 | rs:
8 | observables:
9 | spike times:
10 | file:
11 | path: results/iz2007_RS.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 0.00
--------------------------------------------------------------------------------
/MATLAB/.test.2007.octave.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: izhi2007.m
4 | engine: Octave
5 |
6 | mep: results/.test.2007.mep
7 | experiments:
8 | RS2007_100:
9 | observables:
10 | spike times:
11 | file:
12 | path: results/RS2007_100.dat
13 | spike detection:
14 | method: threshold
15 | tolerance: 0.009939935151225241 # High tolerance due to tau=0.25. Actual values in mep worked out with tau=0.0025
16 |
--------------------------------------------------------------------------------
/NEURON/.test.2007.jnmlnrn.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: test.py
4 | engine: PyNEURON
5 | mep: ../MATLAB/results/.test.2007.mep
6 | experiments:
7 | RS2007_100:
8 | observables:
9 | spike times:
10 | file:
11 | path: RS_One.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 0.00015946420028704162
--------------------------------------------------------------------------------
/NeuroML2/.test.2007.jnml.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_2007One.xml
4 | engine: jNeuroML
5 | mep: ../MATLAB/results/.test.2007.mep
6 | experiments:
7 | RS2007_100:
8 | observables:
9 | spike times:
10 | file:
11 | path: results/RS_One.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 0.000
--------------------------------------------------------------------------------
/NeuroML2/.test.2007cells.jnml.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_2007Cells.xml
4 | engine: jNeuroML
5 | mep: .test.2007cells.mep
6 | experiments:
7 | rs:
8 | observables:
9 | spike times:
10 | file:
11 | path: results/iz2007_RS.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 0.000439525312662
--------------------------------------------------------------------------------
/NeuroML2/.test.five.pylemsnml2.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_FiveCells.xml
4 | engine: PyLEMS_NeuroML2
5 | mep: results/.test.five.mep
6 | experiments:
7 | popA:
8 | observables:
9 | spike times:
10 | file:
11 | path: results/izfive_v.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 0.00
18 |
--------------------------------------------------------------------------------
/NeuroML2/.test.2007.pylemsnml2.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_2007One.xml
4 | engine: PyLEMS_NeuroML2
5 | mep: ../MATLAB/results/.test.2007.mep
6 | experiments:
7 | RS2007_100:
8 | observables:
9 | spike times:
10 | file:
11 | path: results/RS_One.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 5.315473317727283e-05
--------------------------------------------------------------------------------
/NeuroML2/.test.2007.jnmlbrian2.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_2007One.xml
4 | engine: jNeuroML_Brian2
5 | mep: ../MATLAB/results/.test.2007.mep
6 | experiments:
7 | RS2007_100:
8 | observables:
9 | spike times:
10 | file:
11 | path: results/RS_One.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 2.08483028253e-16
18 |
--------------------------------------------------------------------------------
/NeuroML2/.test.2007.jnmleden.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_2007One.xml
4 | engine: jNeuroML_EDEN
5 | mep: ../MATLAB/results/.test.2007.mep
6 | experiments:
7 | RS2007_100:
8 | observables:
9 | spike times:
10 | file:
11 | path: results/RS_One.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 5.317599532243251e-05
18 |
--------------------------------------------------------------------------------
/NeuroML2/.test.2007.jnmlnrn.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_2007One.xml
4 | engine: jNeuroML_NEURON
5 | mep: ../MATLAB/results/.test.2007.mep
6 | experiments:
7 | RS2007_100:
8 | observables:
9 | spike times:
10 | file:
11 | path: results/RS_One.dat
12 | columns: [0,1]
13 | scaling: [1000, 1000]
14 | spike detection:
15 | method: threshold
16 | threshold: 0
17 | tolerance: 0.0001191993471544449
18 |
--------------------------------------------------------------------------------
/NeuroML2/.test.which.jnml.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_WhichModel.xml
4 | engine: jNeuroML
5 |
6 | mep: .test.2003.mep
7 | experiments:
8 |
9 | A_tonic:
10 | observables:
11 | spike times:
12 | file:
13 | path: results/A.dat
14 | scaling: [1000, 1000]
15 | spike detection:
16 | method: threshold
17 | tolerance: 0
18 | C_tonicbursting:
19 | observables:
20 | spike times:
21 | file:
22 | path: results/C.dat
23 | scaling: [1000, 1000]
24 | spike detection:
25 | method: threshold
26 | tolerance: 0
--------------------------------------------------------------------------------
/NeuroML2/.test.which.pylemsnml2.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: LEMS_WhichModel.xml
4 | engine: PyLEMS_NeuroML2
5 |
6 | mep: .test.2003.mep
7 | experiments:
8 |
9 | A_tonic:
10 | observables:
11 | spike times:
12 | file:
13 | path: results/A.dat
14 | scaling: [1000, 1000]
15 | spike detection:
16 | method: threshold
17 | tolerance: 0
18 | C_tonicbursting:
19 | observables:
20 | spike times:
21 | file:
22 | path: results/C.dat
23 | scaling: [1000, 1000]
24 | spike detection:
25 | method: threshold
26 | tolerance: 0
--------------------------------------------------------------------------------
/PyNN/.test.pynnbrian.omt_:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: izhikevich2004.py
4 | engine: PyNN_Brian1
5 |
6 | mep: ../NeuroML2/.test.2003.mep
7 | experiments:
8 |
9 | A_tonic:
10 | observables:
11 | spike times:
12 | file:
13 | path: results/A_Tonic_spiking_brian.dat
14 | scaling: [1, 1]
15 | spike detection:
16 | method: threshold
17 | tolerance: 0.0038089
18 | C_tonicbursting:
19 | observables:
20 | spike times:
21 | file:
22 | path: results/C_Tonic_bursting_brian.dat
23 | scaling: [1, 1]
24 | spike detection:
25 | method: threshold
26 | tolerance: 0.082001
27 |
--------------------------------------------------------------------------------
/PyNN/.test.pynnnest.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: izhikevich2004.py
4 | engine: PyNN_Nest
5 |
6 | mep: ../NeuroML2/.test.2003.mep
7 | experiments:
8 |
9 | A_tonic:
10 | observables:
11 | spike times:
12 | file:
13 | path: results/A_Tonic_spiking_nest.dat
14 | scaling: [1, 1]
15 | spike detection:
16 | method: threshold
17 | tolerance: 0.0038089
18 | C_tonicbursting:
19 | observables:
20 | spike times:
21 | file:
22 | path: results/C_Tonic_bursting_nest.dat
23 | scaling: [1, 1]
24 | spike detection:
25 | method: threshold
26 | tolerance: 0.08200082000820008
27 |
28 |
--------------------------------------------------------------------------------
/PyNN/.test.pynnnrn.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: izhikevich2004.py
4 | engine: PyNN_NEURON
5 |
6 | mep: ../NeuroML2/.test.2003.mep
7 | experiments:
8 |
9 | A_tonic:
10 | observables:
11 | spike times:
12 | file:
13 | path: results/A_Tonic_spiking_neuron.dat
14 | scaling: [1, 1]
15 | spike detection:
16 | method: threshold
17 | tolerance: 0.0038088642659279584
18 | C_tonicbursting:
19 | observables:
20 | spike times:
21 | file:
22 | path: results/C_Tonic_bursting_neuron.dat
23 | scaling: [1, 1]
24 | spike detection:
25 | method: threshold
26 | tolerance: 0.08323083230832312
--------------------------------------------------------------------------------
/CITATION.md:
--------------------------------------------------------------------------------
1 | ## Citing this model
2 |
3 | The software in this repository is provided under the terms of the [software license](LICENSE) included with it.
4 |
5 | If you use this model in your research, we respectfully ask you to cite:
6 |
7 | **The original publication upon which this model is based**
8 |
9 | - Simple model of spiking neurons, EM Izhikevich, 2003, IEEE Transactions on neural networks 14 (6), 1569-1572
10 |
11 | **The ModelDB entry for this model**
12 |
13 | - https://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=39948
14 |
15 | **The latest release of this Open Source Brain repository**
16 |
17 | - This link should provide a DOI/citation for the latest version released: https://www.zenodo.org/badge/latestdoi/4956319. If you would like us to make a new release, please [open an issue](../../issues).
18 |
--------------------------------------------------------------------------------
/NeuroML2/LEMS_SmallNetwork.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Izhikevich spiking neuron model
2 |
3 | Implementation of the model from: http://izhikevich.org/publications/whichmod.htm
4 |
5 | 
6 |
7 | See the [Wiki](http://www.opensourcebrain.org/projects/izhikevichmodel/wiki/Wiki) for more details about current implementations.
8 |
9 | [](https://github.com/OpenSourceBrain/IzhikevichModel/actions/workflows/omv-ci.yml)
10 | [](https://www.zenodo.org/badge/latestdoi/4956319)
11 |
12 | ### Reusing this model
13 |
14 | The code in this repository is provided under the terms of the [software license](LICENSE) included with it. If you use this model in your research, we respectfully ask you to cite the references outlined in the [CITATION](CITATION.md) file.
15 |
16 |
--------------------------------------------------------------------------------
/NEURON/izhi2003b.mod:
--------------------------------------------------------------------------------
1 | NEURON {
2 | POINT_PROCESS Izhi2003b
3 | RANGE a,b,c,d,f,g,Iin,fflag,thresh
4 | NONSPECIFIC_CURRENT i
5 | }
6 |
7 | UNITS {
8 | (mV) = (millivolt)
9 | (nA) = (nanoamp)
10 | (nF) = (nanofarad)
11 | }
12 |
13 | INITIAL {
14 | v=-65
15 | u=0.2*v
16 | net_send(0,1)
17 | }
18 |
19 | PARAMETER {
20 | a = 0.02 (/ms)
21 | b = 0.2 (/ms)
22 | c = -65 (mV) : reset potential after a spike
23 | d = 2 (mV/ms)
24 | f = 5
25 | g = 140
26 | Iin = 10
27 | thresh = 30 (mV) : spike threshold
28 | fflag = 1
29 | }
30 |
31 | ASSIGNED {
32 | v (mV)
33 | i (nA)
34 | }
35 |
36 | STATE {
37 | u (mV/ms)
38 | }
39 |
40 | BREAKPOINT {
41 | SOLVE states METHOD derivimplicit : cnexp # either method works
42 | i = -0.001*(0.04*v*v + f*v + g - u + Iin)
43 | }
44 |
45 | DERIVATIVE states {
46 | u' = a*(b*v - u)
47 | }
48 |
49 | NET_RECEIVE (w) {
50 | if (flag == 1) {
51 | WATCH (v > thresh) 2
52 | } else if (flag == 2) {
53 | net_event(t)
54 | v = c
55 | u = u + d
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/NeuroML2/LEMS_2007One.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /NEURON/RS_One.dat
2 | /NeuroML2/results/RS_One.dat.lems
3 | *~
4 | NeuroML2/*.gv
5 | NeuroML2/*nrn.py
6 | NeuroML2/*.ode
7 | NeuroML2/*.9ml
8 | NeuroML2/*.png
9 | NeuroML2/*.dat
10 | NeuroML2/*.mod
11 | NeuroML2/*.m
12 | NeuroML2/*.json
13 | *.pyc
14 | *i686
15 | *x86_64
16 | arm64
17 | generatedNEURON
18 | generatedGENESIS
19 | generatedNeuroML
20 | generatedMOOSE
21 | generatedPSICS
22 | simulations
23 | *.bak
24 | *py.class
25 | izhikevich15jun19
26 | MATLAB/results/*.dat
27 | NeuroML2/results/*.dat
28 |
29 | PyNN/results/
30 | nnn/
31 | /NeuroML2/LEMS_2007One_brian2.py
32 | /NeuroML2/LEMS_2007One_netpyne.py
33 | /NeuroML2/*.pov
34 | /NeuroML2/*.svg
35 | /NeuroML2/LEMS_2007One_brian.py
36 | /tests.log
37 | /NeuroML2/LEMS_iv_RS.xml
38 | /NeuroML2/iv_RS.net.nml
39 | /NeuroML2/nmllite/izhPop_0.u.dat
40 | /NeuroML2/nmllite/*.dat
41 | /NeuroML2/nmllite/*.png
42 | /NeuroML2/nmllite/*.gv*
43 | /NeuroML2/nmllite/report*txt
44 | /NeuroML2/nmllite/IzhikevichTest.json
45 | /NeuroML2/nmllite/IzhikevichTest.net.nml
46 | /NeuroML2/nmllite/LEMS_SimIzhikevichTest.xml
47 | /NeuroML2/nmllite/SimIzhikevichTest.json
48 | *code.gen.*
49 | *_eden.py
50 | /NeuroML2/nmllite/*_nrn.py
51 | /NeuroML2/nmllite/*.mod
52 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # Framework for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | sudo: false
4 |
5 | addons:
6 | apt:
7 | packages:
8 | # Requirements for Brian & NEST
9 | - python-numpy
10 | - python-scipy
11 | - python-matplotlib
12 | - python-sympy
13 | - python-tables
14 | - libreadline6-dev
15 | - libncurses5-dev
16 | - libgsl0-dev
17 | - cython
18 | # Requirements for Octave
19 | - octave
20 | - gnuplot
21 | # Requirements for numba jit
22 | - build-essential
23 |
24 | language: python
25 |
26 | python: 2.7
27 | python: 3.5
28 |
29 | virtualenv:
30 | system_site_packages: true
31 |
32 | env:
33 | - OMV_ENGINE=jNeuroML
34 | - OMV_ENGINE=jNeuroML_NEURON
35 | #- OMV_ENGINE=jNeuroML_Brian2
36 | - OMV_ENGINE=jNeuroML_validate
37 | - OMV_ENGINE=PyLEMS_NeuroML2
38 | - OMV_ENGINE=Octave
39 | - OMV_ENGINE=PyNN_Brian1
40 | - OMV_ENGINE=PyNN_NEURON
41 | - OMV_ENGINE=PyNN_Nest
42 | - OMV_ENGINE=PyNEURON
43 | - OMV_ENGINE=Numba
44 |
45 | install:
46 | # Requirements for numba jit
47 | - conda install numba
48 | - pip install git+https://github.com/russelljjarvis/osb-model-validation
49 |
50 | script:
51 | # quick test.
52 | - omv all -V
53 | -- python numba/travis_run_numba_model.py
54 |
--------------------------------------------------------------------------------
/MATLAB/results/.test.2003.mep:
--------------------------------------------------------------------------------
1 | system: Test 2003
2 |
3 | experiments:
4 |
5 | A_tonic:
6 | expected:
7 | spike times: [13.0, 17.0, 31.25, 59.0, 86.75]
8 | C_tonicbursting:
9 | expected:
10 | spike times: [24.75, 26.5, 28.0, 29.75, 31.75, 34.0, 36.0, 38.75, 41.5, 45.5, 79.75, 82.0, 84.5, 87.5, 91.25, 98.5, 132.75, 134.75, 137.25, 140.25, 144.0, 151.0, 185.25, 187.5, 190.0, 193.0, 196.75, 204.25]
11 |
12 |
13 | RS:
14 | expected:
15 | spike times: [18.25, 24.0, 54.25, 87.5, 120.75]
16 | IB:
17 | expected:
18 | spike times: [18.5, 21.0, 24.75, 58.25, 87.5, 117.25, 146.75]
19 | CH:
20 | expected:
21 | spike times: [18.75, 20.75, 22.5, 24.75, 27.25, 30.25, 34.25, 81.75, 84.25, 87.0, 90.5, 137.25, 139.75, 142.5, 146.0]
22 | FS:
23 | expected:
24 | spike times: [18.75, 23.75, 31.25, 40.25, 48.75, 58.0, 67.25, 77.0, 86.25, 95.5, 105.0, 114.0, 123.25, 131.75, 141.0]
25 | TC:
26 | expected:
27 | spike times: [39.25, 53.25, 82.75, 120.25]
28 | TCb:
29 | expected:
30 | spike times: [51.0, 55.75, 61.75, 68.75, 79.5]
31 | RZ:
32 | expected:
33 | spike times: [62.75, 67.25]
34 | LTS:
35 | expected:
36 | spike times: [27.75, 31.25, 35.5, 41.25, 50.0, 63.5, 77.75, 92.75, 107.5, 122.25, 136.5, 151.5, 166.25, 180.5, 195.5, 210.5, 225.25, 240.25]
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/NeuroML2/Izh2007One.net.nml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
12 | Regular spiking cell
13 |
14 |
15 |
16 |
17 |
18 |
19 | A single Izhikevich spiking cell
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/.github/workflows/omv-ci.yml:
--------------------------------------------------------------------------------
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-22.04 # for eden & nest...
14 | strategy:
15 | fail-fast: false
16 | matrix:
17 | python-version: [ "3.11" ]
18 | engine:
19 | - jNeuroML
20 | - jNeuroML_NEURON
21 | - jNeuroML_EDEN
22 | - jNeuroML_validate
23 | - jNeuroML_Brian2
24 | - PyLEMS_NeuroML2
25 | - PyNN_NEURON
26 | - PyNN_Nest
27 | - PyNEURON
28 |
29 | steps:
30 | - uses: actions/checkout@v4
31 |
32 | - name: Set up Python ${{ matrix.python-version }}
33 | uses: actions/setup-python@v5
34 | with:
35 | python-version: ${{ matrix.python-version }}
36 |
37 | - name: Install OMV
38 | run: |
39 | pip install git+https://github.com/OpenSourceBrain/osb-model-validation
40 | pip install scipy sympy matplotlib cython pandas tables
41 |
42 | pip install setuptools --upgrade # needed for eden on Python 3.12
43 |
44 | - name: Run OMV tests on engine ${{ matrix.engine }}
45 | run: |
46 | omv all -V --engine=${{ matrix.engine }}
47 |
48 | - name: OMV final version info
49 | run: |
50 | omv list -V # list installed engines
51 | env
52 |
--------------------------------------------------------------------------------
/NeuroML2/izhikevichCell_to_izhikevich2007Cell.py:
--------------------------------------------------------------------------------
1 | '''
2 |
3 | NOT YET COMPLETE...
4 |
5 | '''
6 | from neuroml.loaders import read_neuroml2_file
7 |
8 | nml_doc = read_neuroml2_file('FiveCells.net.nml')
9 |
10 | for iz in nml_doc.izhikevich_cells:
11 | print('Found: %s'%(iz.id))
12 |
13 | '''
14 |
15 |
16 |
17 | 0.04 * v^2 + 5 * v + 140.0
18 |
19 | = 0.04 * (v^2 + 125 * v + 3500)
20 |
21 | = 0.04 * (v - (-42.3443)) * (v - (-82.6556))
22 |
23 |
24 | \nNOT YET COMPLETE...'%(a,b,c,d,k,C)
49 |
50 | print(iz2007)
51 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013-2019, Vitor Chaud, Andrew Davison, Salvador Dura-Bernal, Cliff Kerr, Bill Lytton and Padraig Gleeson
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 | Neither the names of the copyright holders nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 |
11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 |
--------------------------------------------------------------------------------
/NeuroML2/SmallNetwork.nml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
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 |
--------------------------------------------------------------------------------
/NeuroML2/LEMS_2007Cells.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/MATLAB/.test.2003.octave.omt:
--------------------------------------------------------------------------------
1 | # Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation
2 |
3 | target: izhi2003.m
4 | engine: Octave
5 |
6 | mep: results/.test.2003.mep
7 | experiments:
8 |
9 | A_tonic:
10 | observables:
11 | spike times:
12 | file:
13 | path: results/A_tonic.dat
14 | spike detection:
15 | method: threshold
16 | tolerance: 0
17 | C_tonicbursting:
18 | observables:
19 | spike times:
20 | file:
21 | path: results/C_tonicbursting.dat
22 | spike detection:
23 | method: threshold
24 | tolerance: 0
25 |
26 | RS:
27 | observables:
28 | spike times:
29 | file:
30 | path: results/RS.dat
31 | spike detection:
32 | method: threshold
33 | tolerance: 0
34 | IB:
35 | observables:
36 | spike times:
37 | file:
38 | path: results/IB.dat
39 | spike detection:
40 | method: threshold
41 | tolerance: 0
42 | CH:
43 | observables:
44 | spike times:
45 | file:
46 | path: results/CH.dat
47 | spike detection:
48 | method: threshold
49 | tolerance: 0
50 | FS:
51 | observables:
52 | spike times:
53 | file:
54 | path: results/FS.dat
55 | spike detection:
56 | method: threshold
57 | tolerance: 0
58 | TC:
59 | observables:
60 | spike times:
61 | file:
62 | path: results/TC.dat
63 | spike detection:
64 | method: threshold
65 | tolerance: 0
66 | TCb:
67 | observables:
68 | spike times:
69 | file:
70 | path: results/TCb.dat
71 | spike detection:
72 | method: threshold
73 | tolerance: 0
74 | RZ:
75 | observables:
76 | spike times:
77 | file:
78 | path: results/RZ.dat
79 | spike detection:
80 | method: threshold
81 | tolerance: 0
82 | LTS:
83 | observables:
84 | spike times:
85 | file:
86 | path: results/LTS.dat
87 | spike detection:
88 | method: threshold
89 | tolerance: 0
--------------------------------------------------------------------------------
/NeuroML2/nmllite/OneCell.py:
--------------------------------------------------------------------------------
1 |
2 | from neuromllite import Network, Cell, InputSource, Population, Synapse
3 | from neuromllite import Projection, RandomConnectivity, Input, Simulation
4 | import sys
5 |
6 | ################################################################################
7 | ### Build new network
8 |
9 | net = Network(id='IzhikevichTest')
10 | net.notes = 'Example Izhikevich'
11 | net.parameters = { 'N': 1}
12 |
13 | cell = Cell(id='izhCell',
14 | neuroml2_cell='izhikevich2007Cell')
15 | cell.parameters = {}
16 |
17 | params = {'v0':'-60mV', 'C':'100 pF', 'k':'0.7 nS_per_mV', \
18 | 'vr':'-60 mV', 'vt':'-40 mV', 'vpeak':'35 mV', \
19 | 'a':'0.03 per_ms', 'b':'-2 nS', 'c':'-50 mV', 'd':'100 pA'}
20 |
21 | for p in params:
22 | cell.parameters[p]=p
23 | net.parameters[p]=params[p]
24 |
25 | net.cells.append(cell)
26 |
27 |
28 | pop = Population(id='izhPop', size='1', component=cell.id, properties={'color':'.7 0 0'})
29 | net.populations.append(pop)
30 |
31 | net.parameters['delay'] = '100ms'
32 | net.parameters['stim_amp'] = '100pA'
33 | net.parameters['duration'] = '500ms'
34 | input_source = InputSource(id='iclamp_0',
35 | neuroml2_input='PulseGenerator',
36 | parameters={'amplitude':'stim_amp', 'delay':'delay', 'duration':'duration'})
37 | net.input_sources.append(input_source)
38 |
39 | net.inputs.append(Input(id='stim',
40 | input_source=input_source.id,
41 | population=pop.id,
42 | percentage=100))
43 |
44 | print(net)
45 | print(net.to_json())
46 | new_file = net.to_json_file('%s.json'%net.id)
47 |
48 |
49 | ################################################################################
50 | ### Build Simulation object & save as JSON
51 |
52 | sim = Simulation(id='Sim%s'%net.id,
53 | network=new_file,
54 | duration='700',
55 | dt='0.025',
56 | record_variables={'v':{'all':'*'},
57 | 'u':{'all':'*'}},
58 | plots2D={'vu':{'x_axis':'izhPop[0]/v',
59 | 'y_axis':'izhPop[0]/u'}},
60 | plots3D={'X-Y-Z':{'x_axis':'t',
61 | 'y_axis':'izhPop[0]/u',
62 | 'z_axis':'izhPop[0]/v'}})
63 |
64 | sim.to_json_file()
65 |
66 |
67 |
68 | ################################################################################
69 | ### Run in some simulators
70 |
71 | from neuromllite.NetworkGenerator import check_to_generate_or_run
72 | import sys
73 |
74 | check_to_generate_or_run(sys.argv, sim)
75 |
--------------------------------------------------------------------------------
/NEURON/simple.py:
--------------------------------------------------------------------------------
1 | '''Usage:
2 | import simple
3 | h.run()
4 | simple.show()
5 |
6 | Sets up 5 models using default parameters in the .mod files
7 | 2 versions of 2003/2004 parameterization: freestanding (3a); in section (3b)
8 | 3 versions of 2007/2008 parameterization: freestanding (7a); in section (7b); in sec using wrapper class (7bw)
9 | can graph u, v for any model
10 | simple.show('v3a','v3b') # compare voltage output for the 2 versions of the 2003/2004 parameterization; will NOT be identical
11 | simple.show('v7a','v7b','v7bw') # compare voltage output for 3 versions of the 2007 parameterization
12 | '''
13 |
14 | from neuron import h, gui
15 | import numpy as np
16 | import izhi2007Wrapper as izh07
17 | import pylab as plt
18 | import pprint as pp
19 | plt.ion()
20 | fih = []
21 | dummy=h.Section()
22 |
23 | # make a 2003a STATE {u,vv} cell (used for 2003, 2004)
24 | iz03a = h.Izhi2003a(0.5,sec=dummy)
25 | iz03a.Iin = 4
26 |
27 | # make a 2003b (Section v) cell
28 | sec03b = h.Section() # this section will actually be used
29 | sec03b.L, sec03b.diam = 5, 6.3 # empirically tuned
30 | iz03b = h.Izhi2003b(0.5,sec=sec03b)
31 | iz03b.Iin = 4
32 | def iz03b_init (): sec03b(0.5).v, iz03b.u = -65, -65*iz03b.b
33 | fih.append(h.FInitializeHandler(iz03b_init))
34 |
35 | # make a 2007a (NMODL) cell
36 | iz07a = h.Izhi2007a(0.5,sec=dummy)
37 | iz07a.Iin = 70
38 |
39 | # make a 2007b (section) cell
40 | sec07b = h.Section()
41 | sec07b.L, sec07b.diam = 5, 6.3
42 | iz07b = h.Izhi2007b(0.5,sec=sec07b)
43 | iz07b.Iin = 70
44 | def iz07b_init(): sec07b.v=-60
45 | fih.append(h.FInitializeHandler(iz07b_init))
46 |
47 | # make a 2007b (section) cell using the Wrapper
48 | iz07bw = izh07.IzhiCell() # defaults to RS
49 | iz07bw.izh.Iin = 70
50 | fih.append(h.FInitializeHandler(iz07bw.init))
51 |
52 | # vectors and plot
53 | h.tstop=1250
54 | recd = {'u3a':[iz03a._ref_u], 'v3a':[iz03a._ref_V], 'u3b':[iz03b._ref_u], 'v3b':[sec03b(0.5)._ref_v],
55 | 'u7a':[iz07a._ref_u], 'v7a':[iz07a._ref_V], 'u7b':[iz07b._ref_u], 'v7b':[sec07b(0.5)._ref_v],
56 | 'u7bw':[iz07bw.izh._ref_u], 'v7bw':[iz07bw.sec(0.5)._ref_v]}
57 | [(v.append(h.Vector(h.tstop/h.dt+100)),v[1].record(v[0])) for x,v in recd.iteritems()]
58 | def vtvec(vv): return np.linspace(0, len(vv)*h.dt, len(vv), endpoint=True)
59 |
60 | # run and plot
61 | fig = None
62 | def show (*vars):
63 | pp.pprint(recd.keys())
64 | global fig,tvec
65 | if fig is None: fig = plt.figure(figsize=(10,6), tight_layout=True)
66 | if len(vars)==0: vars=recd.keys()
67 | tvec=vtvec(recd['v7a'][1])
68 | plt.clf()
69 | [plt.plot(tvec,v[1]) for x,v in recd.iteritems() if x in vars]
70 | pp.pprint([v[1].as_numpy()[-5:] for x,v in recd.iteritems() if x in vars])
71 | plt.xlim(0,h.tstop)
72 |
73 | # h.run()
74 | # show()
75 |
--------------------------------------------------------------------------------
/NeuroML2/LEMS_FiveCells.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/NEURON/test.py:
--------------------------------------------------------------------------------
1 |
2 | import sys
3 |
4 | from neuron import h, gui
5 |
6 | plot = not '-nogui' in sys.argv
7 |
8 | fih = []
9 |
10 | # make a 2007b (section) cell
11 | sec07b = h.Section('soma')
12 | sec07b.L, sec07b.diam, sec07b.cm = 5, 6.3, 1
13 | sec07b.L, sec07b.diam, sec07b.cm = 10, 10, 31.831 * 1
14 | iz07b = h.Izhi2007b(0.5,sec=sec07b)
15 | iz07b.Iin = 0
16 | iz07b.C = 1
17 |
18 |
19 | h("objref stim")
20 | h(" stim = new IClamp(0.500000) ")
21 | h(" stim.del = 0 ")
22 | h(" stim.dur = 10000 ")
23 | h(" stim.amp = 0.1 ")
24 |
25 | def iz07b_init(): sec07b.v=-60
26 | fih.append(h.FInitializeHandler(iz07b_init))
27 |
28 | h('forall psection()')
29 |
30 | # vectors and plot
31 | h.tstop=520
32 |
33 |
34 | trec = h.Vector()
35 | trec.record(h._ref_t)
36 |
37 | h.dt = 0.0025
38 |
39 | h.steps_per_ms = 1/h.dt
40 |
41 | if plot:
42 | # Display: display_d1
43 | display_d1 = h.Graph(0)
44 | display_d1.size(0,h.tstop,-80.0,50.0)
45 | display_d1.view(0, -80.0, h.tstop, 130.0, 80, 330, 330, 250)
46 | h.graphList[0].append(display_d1)
47 | # Line, plotting: RS_pop[0]/v
48 | display_d1.addexpr("v(0.5)", "v(0.5)", 1, 1, 0.8, 0.9, 2)
49 |
50 | # Display: display_d2
51 | display_d2 = h.Graph(0)
52 | display_d2.size(0,h.tstop,-80.0,50.0)
53 | display_d2.view(0, -80.0, h.tstop, 130.0, 80, 330, 330, 250)
54 | h.graphList[0].append(display_d2)
55 | display_d2.addexpr("Izhi2007b[0].u", "Izhi2007b[0].u", 1, 1, 0.8, 0.9, 2)
56 |
57 |
58 | # File to save: time
59 | # Column: time
60 | h(' objectvar v_time ')
61 | h(' { v_time = new Vector() } ')
62 | h(' v_time.record(&t) ')
63 | h.v_time.resize((h.tstop * h.steps_per_ms) + 1)
64 |
65 | # File to save: of0
66 | # Column: RS_pop[0]/v
67 | h(' objectvar v_v_of0 ')
68 | h(' { v_v_of0 = new Vector() } ')
69 | h(' v_v_of0.record(&v(0.5)) ')
70 | h.v_v_of0.resize((h.tstop * h.steps_per_ms) + 1)
71 | # Column: RS_pop[0]/u
72 | h(' objectvar v_u_of0 ')
73 | h(' { v_u_of0 = new Vector() } ')
74 | h(' v_u_of0.record(&Izhi2007b[0].u) ')
75 | h.v_u_of0.resize((h.tstop * h.steps_per_ms) + 1)
76 |
77 |
78 | if plot:
79 | h.nrncontrolmenu()
80 |
81 | h.run()
82 |
83 |
84 | if plot:
85 | display_d1.exec_menu("View = plot")
86 | display_d2.exec_menu("View = plot")
87 |
88 | py_v_time = [ t/1000 for t in h.v_time.to_python() ] # Convert to Python list for speed...
89 |
90 |
91 | # File to save: of0
92 | py_v_v_of0 = [ float(x / 1000.0) for x in h.v_v_of0.to_python() ] # Convert to Python list for speed, variable has dim: voltage
93 | py_v_u_of0 = [ float(x / 1.0E9) for x in h.v_u_of0.to_python() ] # Convert to Python list for speed, variable has dim: current
94 |
95 | f_of0_f2 = open('RS_One.dat', 'w')
96 | for i in range(int(h.tstop * h.steps_per_ms) + 1):
97 | f_of0_f2.write('%e\t'% py_v_time[i] + '%e\t'%(py_v_v_of0[i]) + '%e\t'%(py_v_u_of0[i]) + '\n')
98 | f_of0_f2.close()
99 | print("Saved data to: RS_One.dat")
--------------------------------------------------------------------------------
/NEURON/izhi2003a.mod:
--------------------------------------------------------------------------------
1 | : Izhikevich artificial neuron model from
2 | : EM Izhikevich "Simple Model of Spiking Neurons"
3 | : IEEE Transactions On Neural Networks, Vol. 14, No. 6, November 2003 pp 1569-1572
4 | : V is the voltage analog, u controls
5 | : see COMMENT below or izh.hoc for typical parameter values
6 | : uncomment lines with dvv,du to graph derivatives
7 |
8 | NEURON {
9 | POINT_PROCESS Izhi2003a
10 | RANGE a,b,c,d,f,g,Iin,fflag,thresh,erev,taug
11 | }
12 |
13 | INITIAL {
14 | V=-65
15 | u=0.2*V
16 | gsyn=0
17 | net_send(0,1)
18 | }
19 |
20 | PARAMETER {
21 | a = 0.02
22 | b = 0.2
23 | c = -65
24 | d = 2
25 | f = 5
26 | g = 140
27 | Iin = 10
28 | taug = 1
29 | thresh=30
30 | erev = 0
31 | fflag = 1
32 | }
33 |
34 | STATE { u V gsyn } : use V for voltage so don't interfere with built-in v of cell
35 |
36 | ASSIGNED {
37 | }
38 |
39 | BREAKPOINT {
40 | SOLVE states METHOD derivimplicit
41 | }
42 |
43 | DERIVATIVE states {
44 | V' = 0.04*V*V + f*V + g - u + Iin - gsyn*(V-erev)
45 | u' = a*(b*V-u)
46 | gsyn' = -gsyn/taug
47 | }
48 |
49 | NET_RECEIVE (w) {
50 | if (flag == 1) {
51 | WATCH (V>thresh) 2
52 | } else if (flag == 2) {
53 | net_event(t)
54 | V = c
55 | u = u+d
56 | } else { : synaptic activation
57 | gsyn = gsyn+w
58 | }
59 | }
60 |
61 | :** vers gives version
62 | PROCEDURE version () {
63 |
64 | }
65 |
66 | COMMENT
67 | a b c d Iin
68 | ================================================================================
69 | 0.02 0.2 -65 6 14 % tonic spiking
70 | 0.02 0.25 -65 6 0.5 % phasic spiking
71 | 0.02 0.2 -50 2 15 % tonic bursting
72 | 0.02 0.25 -55 0.05 0.6 % phasic bursting
73 | 0.02 0.2 -55 4 10 % mixed mode
74 | 0.01 0.2 -65 8 30 % spike frequency adaptation
75 | 0.02 -0.1 -55 6 0 % Class 1
76 | 0.2 0.26 -65 0 0 % Class 2
77 | 0.02 0.2 -65 6 7 % spike latency
78 | 0.05 0.26 -60 0 0 % subthreshold oscillations
79 | 0.1 0.26 -60 -1 0 % resonator
80 | 0.02 -0.1 -55 6 0 % integrator
81 | 0.03 0.25 -60 4 0 % rebound spike
82 | 0.03 0.25 -52 0 0 % rebound burst
83 | 0.03 0.25 -60 4 0 % threshold variability
84 | 1 1.5 -60 0 -65 % bistability
85 | 1 0.2 -60 -21 0 % DAP
86 | 0.02 1 -55 4 0 % accomodation
87 | -0.02 -1 -60 8 80 % inhibition-induced spiking
88 | -0.026 -1 -45 0 80 % inhibition-induced bursting
89 | ENDCOMMENT
90 |
--------------------------------------------------------------------------------
/PyNN/old/test_IF_cond_exp.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | from pyNN.random import RandomDistribution, NumpyRNG
4 | from pyNN.neuron import *
5 | from pyNN.utility import get_script_args, Timer, ProgressBar, init_logging, normalized_filename
6 | import matplotlib.pyplot as plt
7 | import numpy as np
8 |
9 |
10 | timeStep = 0.01
11 |
12 | setup(timestep=timeStep, min_delay=0.5)
13 |
14 |
15 |
16 |
17 | tau_m = 20.0 # [ms]
18 | cm = 0.2 # [nF]
19 | v_rest = -60.0 # [mV]
20 | v_thresh = -50.0 # [mV]
21 | tau_syn_E = 5.0 # [ms]
22 | tau_syn_I = 10.0 # [ms]
23 | e_rev_E = 0.0 # [mV]
24 | e_rev_I = -80.0 # [mV]
25 | v_reset = -60.0 # [mV]
26 | tau_refrac = 5.0 # [ms]
27 | i_offset = 0.0 # [nA]
28 |
29 |
30 | neuronParameters = {
31 | 'tau_m': tau_m,
32 | 'cm': cm,
33 | 'v_rest': v_rest,
34 | 'v_thresh': v_thresh,
35 | 'tau_syn_E': tau_syn_E,
36 | 'tau_syn_I': tau_syn_I,
37 | 'e_rev_E': e_rev_E,
38 | 'e_rev_I': e_rev_I,
39 | 'v_reset': v_reset,
40 | 'tau_refrac': tau_refrac,
41 | 'i_offset': i_offset
42 | }
43 |
44 | cell_type = IF_cond_exp(**neuronParameters)
45 |
46 | rand_distr = RandomDistribution('uniform', (v_reset, v_thresh), rng=NumpyRNG(seed=85524))
47 |
48 |
49 | neuron = create(cell_type)
50 |
51 | neuron.initialize(neuron=rand_distr)
52 |
53 | neuron.record('v')
54 |
55 |
56 | totalTimes = np.zeros(0)
57 | totalAmps = np.zeros(0)
58 |
59 | times = np.linspace(0.0, 30.0, int(1 + (30.0 - 0.0) / timeStep))
60 | amps = np.linspace(0.0, 0.0, int(1 + (30.0 - 0.0) / timeStep))
61 | totalTimes = np.append(totalTimes, times)
62 | totalAmps = np.append(totalAmps, amps)
63 |
64 | times = np.linspace(30 + timeStep, 300, int((300 - 30) / timeStep))
65 | amps = np.linspace(0.005 * timeStep, 0.005 * (300 - 30), int((300 - 30) / timeStep))
66 | totalTimes = np.append(totalTimes, times)
67 | totalAmps = np.append(totalAmps, amps)
68 |
69 | injectedCurrent = StepCurrentSource(times=totalTimes, amplitudes=totalAmps)
70 | injectedCurrent.inject_into(neuron)
71 |
72 |
73 |
74 | run(300)
75 |
76 |
77 |
78 | data = neuron.get_data().segments[0]
79 |
80 |
81 | plt.ion()
82 | fig = plt.figure(1, facecolor='white')
83 | ax1 = fig.add_subplot(5, 4, 7)
84 | ax1.get_xaxis().set_visible(False)
85 | ax1.get_yaxis().set_visible(False)
86 | ax1.spines['left'].set_color('None')
87 | ax1.spines['right'].set_color('None')
88 | ax1.spines['bottom'].set_color('None')
89 | ax1.spines['top'].set_color('None')
90 |
91 | ax1.set_title('(G) Class 1 excitable')
92 |
93 | vm = data.filter(name='v')[0]
94 | plt.plot(vm.times, vm, [0, 30, 300, 300],[-90, -90, -70, -90])
95 |
96 | plt.show(block=False)
97 | fig.canvas.draw()
98 |
99 |
100 |
101 |
102 |
103 | raw_input("Simulation finished... Press enter to exit...")
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/numba/travis_run_numba_model.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding: utf-8
3 |
4 | # # This is a reproduction of the MATLAB script 2007.m
5 | #
6 | # The code is implemented in pure python. Performance of the model is atypically good as the model utilizes numba Just In Time compilation.
7 |
8 |
9 |
10 | import matplotlib.pyplot as plt
11 | import collections
12 | import quantities as pq
13 | import izhikevich as izhi
14 | import numpy as np
15 | #get_ipython().run_line_magic('matplotlib', 'inline')
16 | from utils import reduced_cells, transform_input, plot_model
17 | DELAY = 0*pq.ms
18 | DURATION = 250 *pq.ms
19 |
20 |
21 | # # The JIT model is compiled.
22 | # The first model evaluation compiles the model to C code implicitly, from that point onwards evaluation speeds are fractions of ms. This is fast for python as you can see below.
23 |
24 | # In[2]:
25 |
26 |
27 | IinRange = [60,70,85,100];
28 | params = {}
29 | params['amplitude'] = 500*pq.pA
30 | params['delay'] = DELAY
31 | params['duration'] = 600*pq.ms
32 | fig_title = 'Layer 5 regular spiking (RS) pyramidal cell (fig 8.12)'
33 | plot_model(IinRange,reduced_cells,params,cell_key='RS',title=fig_title,timed=True)
34 |
35 |
36 | # In[3]:
37 |
38 |
39 | IinRange = [290,370,500,550];
40 | params = {}
41 | params['delay'] = DELAY
42 | params['duration'] = 600*pq.ms
43 | fig_title = 'Layer 5 intrinsic bursting (IB) pyramidal cell (fig 8.19)'
44 | plot_model(IinRange,reduced_cells,params,cell_key='IB',title=fig_title)
45 |
46 |
47 | # In[4]:
48 |
49 |
50 | IinRange = [200,300,400,600];
51 | params = {}
52 | params['delay'] = DELAY
53 | params['duration'] = 210*pq.ms
54 | figtitle='Cortical chattering (CH) cell (fig 8.23)'
55 | plot_model(IinRange,reduced_cells,params,cell_key='CH',title=figtitle)
56 |
57 |
58 | # In[5]:
59 |
60 |
61 | IinRange = [100,125,200,300];
62 | params = {}
63 | params['delay'] = DELAY
64 | T=320;
65 | figtitle = 'Low-threshold spiking (LTS) interneuron (fig 8.25)';
66 | params['duration'] = T*pq.ms
67 | plot_model(IinRange,reduced_cells,params,cell_key='LTS',title=figtitle)
68 |
69 |
70 | # In[6]:
71 |
72 |
73 | T=100;
74 | params['duration'] = T*pq.ms
75 | IinRange = [73.2,100,200,400];
76 | figtitle = 'Fast-spiking (FS) interneuron (fig 8.27) ';
77 | plot_model(IinRange,reduced_cells,params,cell_key='FS',title=figtitle)
78 |
79 |
80 |
81 | # # Bursting
82 |
83 | # In[7]:
84 |
85 |
86 | figtitle = 'Thalamocortical (TC) cell (fig 8.31) ';
87 | Iin0 = -1200; #% required to lower Vrmp to -80mV for 120 ms
88 | IinRange = [0,50,100];
89 | T=650;
90 | params['duration'] = T*pq.ms
91 | IinRange = transform_input(T,IinRange,Iin0,burstMode=True)
92 | plot_model(IinRange,reduced_cells,params,cell_key='TC',title=figtitle,direct=True)
93 |
94 |
95 | # In[8]:
96 |
97 |
98 | Iin0 = -350;
99 | IinRange = [30,50,90];
100 | IinRange = transform_input(T,IinRange,Iin0,burstMode=True)
101 | T=650;
102 | figtitle = 'Reticular thalamic nucleus (RTN) cell (fig 8.32)';
103 | plot_model(IinRange,reduced_cells,params,cell_key='RTN',title=figtitle,direct=True)
104 |
--------------------------------------------------------------------------------
/NEURON/izhi2007Wrapper.py:
--------------------------------------------------------------------------------
1 | """
2 | IZHI
3 |
4 | Python wrappers for the different celltypes of Izhikevich neuron.
5 | Equations and parameter values taken from
6 | Izhikevich EM (2007). "Dynamical systems in neuroscience", MIT Press
7 | Equation for synaptic inputs taken from
8 | Izhikevich EM, Edelman GM (2008). "Large-scale model of mammalian thalamocortical systems." PNAS 105(9) 3593-3598.
9 |
10 | Cell types available are based on Izhikevich, 2007 book:
11 | 1. RS - Layer 5 regular spiking pyramidal cell (fig 8.12 from 2007 book)
12 | 2. IB - Layer 5 intrinsically bursting cell (fig 8.19 from 2007 book)
13 | 3. CH - Cat primary visual cortex chattering cell (fig8.23 from 2007 book)
14 | 4. LTS - Rat barrel cortex Low-threshold spiking interneuron (fig8.25 from 2007 book)
15 | 5. FS - Rat visual cortex layer 5 fast-spiking interneuron (fig8.27 from 2007 book)
16 | 6. TC - Cat dorsal LGN thalamocortical (TC) cell (fig8.31 from 2007 book)
17 | 7. RTN - Rat reticular thalamic nucleus (RTN) cell (fig8.32 from 2007 book)
18 | """
19 |
20 | import collections
21 | from neuron import h
22 | dummy = h.Section()
23 | type2007 = collections.OrderedDict([
24 | # C k vr vt vpeak a b c d celltype
25 | ('RS', (100, 0.7, -60, -40, 35, 0.03, -2, -50, 100, 1)),
26 | ('IB', (150, 1.2, -75, -45, 50, 0.01, 5, -56, 130, 2)),
27 | ('CH', (50, 1.5, -60, -40, 25, 0.03, 1, -40, 150, 3)),
28 | ('LTS', (100, 1.0, -56, -42, 40, 0.03, 8, -53, 20, 4)),
29 | ('FS', (20, 1.0, -55, -40, 25, 0.2, -2, -45, -55, 5)),
30 | ('TC', (200, 1.6, -60, -50, 35, 0.01, 15, -60, 10, 6)),
31 | ('TC_burst', (200, 1.6, -60, -50, 35, 0.01, 15, -60, 10, 6)),
32 | ('RTN', (40, 0.25, -65, -45, 0, 0.015, 10, -55, 50, 7)),
33 | ('RTN_burst', (40, 0.25, -65, -45, 0, 0.015, 10, -55, 50, 7))])
34 |
35 | # class of basic Izhikevich neuron based on parameters in type2007
36 | class IzhiCell ():
37 | '''Create an izhikevich cell based on 2007 parameterization using either izhi2007.mod (no hosting section) or izhi2007b.mod (v in created section)
38 | If host is omitted or None, this will be a section-based version that uses Izhi2007b with state vars v, u where v is the section voltage
39 | If host is given then this will be a shared unused section that simply houses an Izhi2007 using state vars V and u
40 | Note: Capacitance 'C' differs from sec.cm which will be 1; vr is RMP; vt is threshold; vpeak is peak voltage
41 | '''
42 |
43 | def __init__ (self, type='RS', host=None, cellid=-1):
44 | self.type=type
45 | if host is None: # need to set up a sec for this
46 | self.sec=h.Section(name='izhi2007'+type+str(cellid))
47 | self.sec.L, self.sec.diam = 6.3, 5 # empirically tuned
48 | self.izh = h.Izhi2007b(0.5, sec=self.sec)
49 | self.vinit = -60
50 | else:
51 | self.sec = host
52 | self.izh = h.Izhi2007a(0.5, sec=host) # Create a new u,V 2007 neuron at location 0.5 (doesn't matter where)
53 |
54 | self.izh.C,self.izh.k,self.izh.vr,self.izh.vt,self.izh.vpeak,self.izh.a,self.izh.b,self.izh.c,self.izh.d,self.izh.celltype = type2007[type]
55 | self.izh.cellid = cellid # Cell ID for keeping track which cell this is
56 |
57 | def init (self): self.sec(0.5).v = self.vinit
58 |
59 | def reparam (self, type='RS', cellid=-1):
60 | self.type=type
61 | self.izh.C,self.izh.k,self.izh.vr,self.izh.vt,self.izh.vpeak,self.izh.a,self.izh.b,self.izh.c,self.izh.d,self.izh.celltype = type2007[type]
62 | self.izh.cellid = cellid # Cell ID for keeping track which cell this is
63 |
--------------------------------------------------------------------------------
/NeuroML2/FiveCells.nml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
78 |
79 |
--------------------------------------------------------------------------------
/NeuroML2/Izh2007Cells.net.nml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
12 | Regular spiking cell
13 |
14 |
15 |
16 |
19 | Weakly adapting cell
20 |
21 |
22 |
23 |
24 |
27 | Strongly adapting cell
28 |
29 |
30 |
31 |
34 | Low threshold spiking cell
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | A number of different Izhikevich spiking cells
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 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/NeuroML2/GeneralizedIzhikevichCell.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
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 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/NEURON/izhi2007Figs.py:
--------------------------------------------------------------------------------
1 | ''' izhitest.py
2 | Script to test izhikevich cell model from Izhikevich (2007) "Neural Dynamical Systems" MIT Press
3 |
4 | Cell parameters taken from figures of Izhikevich, 2007 book and implemented using the general eqns (8.5) and (8,6)
5 |
6 | Python wrappers and parameters of each cell type defined in izhi.py
7 |
8 | Model implemented using NEURON simulator NMDOL in izhi2007.mod
9 |
10 | Cell types available are based on Izhikevich, 2007 book:
11 | 1. RS - Layer 5 regular spiking pyramidal cell (fig 8.12 from 2007 book)
12 | 2. IB - Layer 5 intrinsically bursting cell (fig 8.19 from 2007 book)
13 | 3. CH - Cat primary visual cortex chattering cell (fig 8.23 from 2007 book)
14 | 4. LTS - Rat barrel cortex Low-threshold spiking interneuron (fig 8.25 from 2007 book)
15 | 5. FS - Rat visual cortex layer 5 fast-spiking interneuron (fig 8.27 from 2007 book)
16 | 6. TC and TC_burst - Cat dorsal LGN thalamocortical (TC) cell (fig 8.31 from 2007 book)
17 | 7. RTN and RTN_burst - Rat reticular thalamic nucleus (RTN) cell (fig 8.32 from 2007 book)
18 |
19 | Usage:
20 | nrniv -python izhi2007Figs.py
21 | test1(name of cell) eg. test1('RS') or test1('TC_burst')
22 | '''
23 |
24 | from neuron import h,gui
25 | import pylab as plt
26 | plt.ion()
27 | import izhi2007Wrapper as izh07
28 | from izhiGUI import choices, izhtype, izh, cell07 # need to make sure can also access everything that will be seen from within 'choices'
29 |
30 | ## Code to reproduce figs from Izhikevich, 2007 (book)
31 | testModel = 'RS' # cell type to reproduce (RS, IB, CH, LTS, FS, TC, RTN)
32 | burstMode = 0 # tests bursting mode for TC and RTN cells
33 | save = False # whether to save
34 | IinRange = []
35 | IinHyper = 0
36 | title = ''
37 | fig1 = None
38 |
39 | def test1 (ce, name, izhtype):
40 | global testModel, burstMode, IinRange, IinHyper, legendLabels, title
41 | testModel = name
42 | burstMode = 0
43 | C, izhm = ce, ce.izh
44 |
45 | if C.type is not testModel:
46 | C.reparam(testModel)
47 |
48 | legendLabels = ['%s'%(izhtype)]
49 | # RS
50 | if testModel == 'RS':
51 | h.tstop = 520
52 | IinRange = [60,70,85,100]
53 | title = 'Layer 5 regular spiking (RS) pyramidal cell (fig 8.12)'
54 |
55 | # IB
56 | elif testModel == 'IB':
57 | h.tstop = 600
58 | IinRange = [290,370,500,550]
59 | title = 'Layer 5 intrinsic bursting (IB) pyramidal cell (fig 8.19)'
60 |
61 | # CH
62 | elif testModel == 'CH':
63 | h.tstop = 210
64 | IinRange = [200,300,400,600]
65 | title = 'Cortical chattering (CH) cell (fig 8.23)'
66 |
67 | # LTS
68 | elif testModel == 'LTS':
69 | h.tstop = 320
70 | IinRange = [100,125,200,300]
71 | title = 'Low-threshold spiking (LTS) interneuron (fig 8.25) '
72 |
73 | # FS
74 | elif testModel == 'FS':
75 | h.tstop = 100
76 | IinRange = [73.2,100,200,400]
77 | title = 'Fast-spiking (FS) interneuron (fig 8.27) '
78 |
79 | # TC
80 | elif testModel == 'TC':
81 | h.tstop = 650
82 | IinRange = [50,100,150]
83 | title = 'Thalamocortical (TC) cell (fig 8.31) '
84 |
85 | # TC burst
86 | elif testModel == 'TC_burst':
87 | burstMode = 1
88 | h.tstop = 650
89 | IinHyper = -1200
90 | IinRange = [0,50,100]
91 | title = 'Thalamocortical (TC) cell burst mode (fig 8.31) '
92 |
93 | # RTN
94 | elif testModel == 'RTN':
95 | IinRange = [50,70,110]
96 | h.tstop=650
97 | title = 'Reticular thalamic nucleus (RTN) cell (fig 8.32) '
98 |
99 | # RTN burst
100 | elif testModel == 'RTN_burst':
101 | burstMode = 1
102 | IinHyper = -350
103 | IinRange = [30,50,90]
104 | h.tstop=720
105 | title = 'Reticular thalamic nucleus (RTN) cell (fig 8.32) '
106 | runsim(izhm)
107 |
108 | nquantities=4
109 | spikevec = h.Vector()
110 | recvecs = [h.Vector() for q in range(nquantities)] # Initialize vectors
111 | def recorder (ce, vloc):
112 | izhm = ce.izh
113 | #record spikes
114 | spikerecorder = h.NetCon(izhm, None)
115 | spikerecorder.record(spikevec)
116 | # record V,u,Iin
117 | recvecs[0].record(h._ref_t) # Record simulation time
118 | recvecs[1].record(vloc) # Record cell voltage
119 | recvecs[2].record(izhm._ref_u) # Record cell recovery variable
120 | recvecs[3].record(izhm._ref_Iin) # input
121 |
122 | ## Run sim
123 | def runsim (izhm):
124 | global Iin, ax1, recvecs
125 | h.dt = 0.025
126 | f1 = []
127 | ax1=None
128 | if fig1 is not None: plt.clf()
129 | for Iin in IinRange:
130 | izhm.Iin=Iin
131 | h.init()
132 |
133 | if burstMode:
134 | izhm.Iin=IinHyper
135 | h.init()
136 | h.continuerun(120)
137 | izhm.Iin=Iin
138 | h.run()
139 | else:
140 | h.run()
141 | plotall()
142 |
143 | ax1=None
144 | def plotall ():
145 | global fig1, Iin, ax1, legend
146 | if fig1 is None: fig1 = plt.figure(figsize=(6,10), tight_layout=True)
147 | ax = fig1.add_subplot(len(IinRange),1,len(IinRange)-IinRange.index(Iin),sharex=ax1)
148 | if not ax1: ax1=ax
149 | ax.plot(recvecs[0], recvecs[1])
150 | ax.set_xlabel('t (ms) (for Iin=%d pA)'%int(Iin))
151 | ax.set_xlim([0,h.tstop])
152 | ax.set_ylabel('V (mV)')
153 | if IinRange.index(Iin)==0:
154 | plt.legend(legendLabels)
155 | if IinRange.index(Iin)==len(IinRange)-1:
156 | ax.set_title(title)
157 | plt.draw()
158 | if save:
159 | burstText=['', '_burstMode']
160 | fig1.savefig('%s%s.png'%(testModel,burstText[burstMode]))
161 | plt.show()
162 |
163 | def closeFig():
164 | global fig1
165 | plt.close('all')
166 | fig1 = None
167 |
--------------------------------------------------------------------------------
/NEURON/izhi2007bS.mod:
--------------------------------------------------------------------------------
1 | COMMENT
2 |
3 | A "simple" implementation of the Izhikevich neuron with AMPA, NMDA,
4 | GABA_A, and GABA_B receptor dynamics. Equations and parameter values are taken from
5 | Izhikevich EM (2007).
6 | "Dynamical systems in neuroscience"
7 | MIT Press
8 |
9 | Equation for synaptic inputs taken from
10 | Izhikevich EM, Edelman GM (2008).
11 | "Large-scale model of mammalian thalamocortical systems."
12 | PNAS 105(9) 3593-3598.
13 |
14 | Example usage (in Python):
15 | from neuron import h
16 | sec = h.Section(name=sec) # section will be used to calculate v
17 | izh = h.Izhi2007b(0.5)
18 | def initiz () : sec.v=-60
19 | fih=h.FInitializeHandler(initz)
20 | izh.Iin = 70 # current clamp
21 |
22 | Cell types available are based on Izhikevich, 2007 book:
23 | 1. RS - Layer 5 regular spiking pyramidal cell (fig 8.12 from 2007 book)
24 | 2. IB - Layer 5 intrinsically bursting cell (fig 8.19 from 2007 book)
25 | 3. CH - Cat primary visual cortex chattering cell (fig 8.23 from 2007 book)
26 | 4. LTS - Rat barrel cortex Low-threshold spiking interneuron (fig 8.25 from 2007 book)
27 | 5. FS - Rat visual cortex layer 5 fast-spiking interneuron (fig 8.27 from 2007 book)
28 | 6. TC - Cat dorsal LGN thalamocortical (TC) cell (fig 8.31 from 2007 book)
29 | 7. RTN - Rat reticular thalamic nucleus (RTN) cell (fig 8.32 from 2007 book)
30 |
31 | ENDCOMMENT
32 |
33 | : Declare name of object and variables
34 | NEURON {
35 | POINT_PROCESS Izhi2007bS
36 | RANGE C, k, vr, vt, vpeak, a, b, c, d, Iin, celltype, alive, cellid, verbose, derivtype
37 | NONSPECIFIC_CURRENT i
38 | }
39 |
40 | : Specify units that have physiological interpretations (NB: ms is already declared)
41 | UNITS {
42 | (mV) = (millivolt)
43 | (uM) = (micrometer)
44 | }
45 |
46 | : Parameters from Izhikevich 2007, MIT Press for regular spiking pyramidal cell
47 | PARAMETER {
48 | C = 100 : Capacitance
49 | k = 0.7
50 | vr = -60 (mV) : Resting membrane potential
51 | vt = -40 (mV) : Membrane threhsold
52 | vpeak = 35 (mV) : Peak voltage
53 | a = 0.03
54 | b = -2
55 | c = -50
56 | d = 100
57 | Iin = 0
58 | celltype = 1 : A flag for indicating what kind of cell it is, used for changing the dynamics slightly (see list of cell types in initial comment).
59 | alive = 1 : A flag for deciding whether or not the cell is alive -- if it's dead, acts normally except it doesn't fire spikes
60 | cellid = -1 : A parameter for storing the cell ID, if required (useful for diagnostic information)
61 | }
62 |
63 | : Variables used for internal calculations
64 | ASSIGNED {
65 | v (mV)
66 | i (nA)
67 | derivtype
68 | }
69 |
70 | : State variables
71 | STATE {
72 | u (mV) : Slow current/recovery variable
73 | }
74 |
75 |
76 | : Initial conditions
77 | INITIAL {
78 | u = 0.2*vr
79 | derivtype=2
80 | net_send(0,1) : Required for the WATCH statement to be active; v=vr initialization done there
81 | }
82 |
83 | : Define neuron dynamics
84 | BREAKPOINT {
85 | SOLVE states METHOD derivimplicit : cnexp
86 | i = -(k*(v-vr)*(v-vt) - u + Iin)/C/1000
87 | }
88 |
89 | FUNCTION derivfunc () {
90 | if (celltype==5 && derivtype==2) { : For FS neurons, include nonlinear U(v): U(v) = 0 when v=vb (d=vb=-55)
91 | derivfunc = a*(0-u)
92 | } else if (celltype==5 && derivtype==1) { : For FS neurons, include nonlinear U(v): U(v) = 0 when v=vb (d=vb=-55)
93 | derivfunc = a*((0.025*(v-d)*(v-d)*(v-d))-u)
94 | } else if (celltype==5) {
95 | VERBATIM
96 | hoc_execerror("izhi2007b.mod ERRA: derivtype not set",0);
97 | ENDVERBATIM
98 | } else {
99 | derivfunc = a*(b*(v-vr)-u) : Calculate recovery variable
100 | }
101 | }
102 |
103 | DERIVATIVE states {
104 | LOCAL f
105 | f = derivfunc()
106 | u' = f
107 | }
108 |
109 | : Input received
110 | NET_RECEIVE (w) {
111 | : Check if spike occurred
112 | if (flag == 1) { : Fake event from INITIAL block
113 | if (celltype == 4) { : LTS cell
114 | WATCH (v>(vpeak-0.1*u)) 2 : Check if threshold has been crossed, and if so, set flag=2
115 | } else if (celltype == 6) { : TC cell
116 | WATCH (v>(vpeak+0.1*u)) 2
117 | } else { : default for all other types
118 | WATCH (v>vpeak) 2
119 | }
120 | : additional WATCHfulness
121 | if (celltype==6 || celltype==7) {
122 | WATCH (v> -65) 3 : change b param
123 | WATCH (v< -65) 4 : change b param
124 | }
125 | if (celltype==5) {
126 | WATCH (v> d) 3 : going up
127 | WATCH (v< d) 4 : coming down
128 | }
129 | v = vr : initialization can be done here
130 | : FLAG 2 Event created by WATCH statement -- threshold crossed for spiking
131 | } else if (flag == 2) {
132 | if (alive) {net_event(t)} : Send spike event if the cell is alive
133 | : For LTS neurons
134 | if (celltype == 4) {
135 | v = c+0.04*u : Reset voltage
136 | if ((u+d)<670) {u=u+d} : Reset recovery variable
137 | else {u=670}
138 | }
139 | : For FS neurons (only update v)
140 | else if (celltype == 5) {
141 | v = c : Reset voltage
142 | }
143 | : For TC neurons (only update v)
144 | else if (celltype == 6) {
145 | v = c-0.1*u : Reset voltage
146 | u = u+d : Reset recovery variable
147 | } else {: For RS, IB and CH neurons, and RTN
148 | v = c : Reset voltage
149 | u = u+d : Reset recovery variable
150 | }
151 | : FLAG 3 Event created by WATCH statement -- v exceeding set point for param reset
152 | } else if (flag == 3) {
153 | : For TC neurons
154 | if (celltype == 5) { derivtype = 1 : if (v>d) u'=a*((0.025*(v-d)*(v-d)*(v-d))-u)
155 | } else if (celltype == 6) { b=0
156 | } else if (celltype == 7) { b=2
157 | }
158 | : FLAG 4 Event created by WATCH statement -- v dropping below a setpoint for param reset
159 | } else if (flag == 4) {
160 | if (celltype == 5) { derivtype = 2 : if (v=vb (d=vb=-55)
103 | if (v(i+1) < d)
104 | u(i+1) = u(i) + tau*a*(0-u(i));
105 | else
106 | u(i+1) = u(i) + tau*a*((0.025*(v(i)-d).^3)-u(i));
107 | end
108 | elseif (celltype == 6) % For TC neurons, reset b
109 | if (v(i+1) > -65)
110 | b=0;
111 | else
112 | b=15;
113 | end
114 | u(i+1)=u(i)+tau*a*(b*(v(i)-vr)-u(i));
115 | elseif (celltype==7) %For TRN neurons, reset b
116 | if (v(i+1) > -65)
117 | b=2;
118 | else
119 | b=10;
120 | end
121 | u(i+1)=u(i)+tau*a*(b*(v(i)-vr)-u(i));
122 | end
123 | end
124 |
125 | % Check if spike occurred and need to reset
126 | if (celltype < 4 || celltype == 5 || celltype == 7) % default
127 | if v(i+1)>=vpeak
128 | v(i)=vpeak;
129 | v(i+1)=c;
130 | if celltype ~= 5, u(i+1)=u(i+1)+d; end % reset u, except for FS cells
131 | end
132 | elseif (celltype == 4) % LTS cell
133 | if v(i+1) > (vpeak - 0.1*u(i+1))
134 | v(i)=vpeak - 0.1*u(i+1);
135 | v(i+1) = c+0.04*u(i+1); % Reset voltage
136 | if ((u+d)<670)
137 | u(i+1)=u(i+1)+d; % Reset recovery variable
138 | else
139 | u(i+1) = 670;
140 | end
141 | end
142 | elseif (celltype == 6) % TC cell
143 | if v(i+1) > (vpeak + 0.1*u(i+1))
144 | v(i)=vpeak + 0.1*u(i+1);
145 | v(i+1) = c-0.1*u(i+1); % Reset voltage
146 | u(i+1)=u(i+1)+d;
147 | end
148 | end
149 | end
150 |
151 | % plot V
152 | subplot(length(IinRange),1,length(IinRange)-index+1); % plot
153 | plot(tau*(1:n), v);
154 | xlabel(['t (ms) (Iin=', num2str(round(I(i))),' pA)']);
155 | xlim([0,n*tau])
156 | ylabel('V (mV)')
157 |
158 | fileName = strcat('results/',testModel,'2007_',num2str(Iinput),'.dat');
159 | fileID = fopen(fileName,'w'); A = [times; v; u];fprintf(fileID,'%f\t%f\t%f\n',A);fclose(fileID);
160 |
161 | if index == length(IinRange), title(figtitle); end
162 | end
163 |
--------------------------------------------------------------------------------
/NEURON/izhi2007b.mod:
--------------------------------------------------------------------------------
1 | COMMENT
2 |
3 | A "simple" implementation of the Izhikevich neuron.
4 | Equations and parameter values are taken from
5 | Izhikevich EM (2007).
6 | "Dynamical systems in neuroscience"
7 | MIT Press
8 |
9 | Equation for synaptic inputs taken from
10 | Izhikevich EM, Edelman GM (2008).
11 | "Large-scale model of mammalian thalamocortical systems."
12 | PNAS 105(9) 3593-3598.
13 |
14 | Example usage (in Python):
15 | from neuron import h
16 | sec = h.Section(name=sec) # section will be used to calculate v
17 | izh = h.Izhi2007b(0.5)
18 | def initiz () : sec.v=-60
19 | fih=h.FInitializeHandler(initz)
20 | izh.Iin = 70 # current clamp
21 |
22 | Cell types available are based on Izhikevich, 2007 book:
23 | 1. RS - Layer 5 regular spiking pyramidal cell (fig 8.12 from 2007 book)
24 | 2. IB - Layer 5 intrinsically bursting cell (fig 8.19 from 2007 book)
25 | 3. CH - Cat primary visual cortex chattering cell (fig 8.23 from 2007 book)
26 | 4. LTS - Rat barrel cortex Low-threshold spiking interneuron (fig 8.25 from 2007 book)
27 | 5. FS - Rat visual cortex layer 5 fast-spiking interneuron (fig 8.27 from 2007 book)
28 | 6. TC - Cat dorsal LGN thalamocortical (TC) cell (fig 8.31 from 2007 book)
29 | 7. RTN - Rat reticular thalamic nucleus (RTN) cell (fig 8.32 from 2007 book)
30 |
31 | ENDCOMMENT
32 |
33 | : Declare name of object and variables
34 | NEURON {
35 | POINT_PROCESS Izhi2007b
36 | RANGE C, k, vr, vt, vpeak, u, a, b, c, d, Iin, celltype, alive, cellid, verbose, derivtype, delta, t0
37 | NONSPECIFIC_CURRENT i
38 | }
39 |
40 | : Specify units that have physiological interpretations (NB: ms is already declared)
41 | UNITS {
42 | (mV) = (millivolt)
43 | (uM) = (micrometer)
44 | }
45 |
46 | : Parameters from Izhikevich 2007, MIT Press for regular spiking pyramidal cell
47 | PARAMETER {
48 | C = 100 : Capacitance
49 | k = 0.7
50 | vr = -60 (mV) : Resting membrane potential
51 | vt = -40 (mV) : Membrane threhsold
52 | vpeak = 35 (mV) : Peak voltage
53 | a = 0.03
54 | b = -2
55 | c = -50
56 | d = 100
57 | Iin = 0
58 | celltype = 1 : A flag for indicating what kind of cell it is, used for changing the dynamics slightly (see list of cell types in initial comment).
59 | alive = 1 : A flag for deciding whether or not the cell is alive -- if it's dead, acts normally except it doesn't fire spikes
60 | cellid = -1 : A parameter for storing the cell ID, if required (useful for diagnostic information)
61 | }
62 |
63 | : Variables used for internal calculations
64 | ASSIGNED {
65 | v (mV)
66 | i (nA)
67 | u (mV) : Slow current/recovery variable
68 | delta
69 | t0
70 | derivtype
71 | }
72 |
73 | : Initial conditions
74 | INITIAL {
75 | u = 0
76 | derivtype=2
77 | net_send(0,1) : Required for the WATCH statement to be active; v=vr initialization done there
78 | }
79 |
80 | : Define neuron dynamics
81 | BREAKPOINT {
82 | delta = t-t0 : Find time difference
83 | if (celltype<5) {
84 | u = u + delta*a*(b*(v-vr)-u) : Calculate recovery variable
85 | }
86 | else {
87 | : For FS neurons, include nonlinear U(v): U(v) = 0 when v=vb (d=vb=-55)
88 | if (celltype==5) {
89 | if (v-65) {b=0}
100 | else {b=15}
101 | u = u + delta*a*(b*(v-vr)-u) : Calculate recovery variable
102 | }
103 |
104 | : For TRN neurons, reset b
105 | if (celltype==7) {
106 | if (v>-65) {b=2}
107 | else {b=10}
108 | u = u + delta*a*(b*(v-vr)-u) : Calculate recovery variable
109 | }
110 | }
111 |
112 | t0=t : Reset last time so delta can be calculated in the next time step
113 | i = -(k*(v-vr)*(v-vt) - u + Iin)/C/1000
114 | }
115 |
116 | FUNCTION derivfunc () {
117 | if (celltype==5 && derivtype==2) { : For FS neurons, include nonlinear U(v): U(v) = 0 when v=vb (d=vb=-55)
118 | derivfunc = a*(0-u)
119 | } else if (celltype==5 && derivtype==1) { : For FS neurons, include nonlinear U(v): U(v) = 0 when v=vb (d=vb=-55)
120 | derivfunc = a*((0.025*(v-d)*(v-d)*(v-d))-u)
121 | } else if (celltype==5) {
122 | VERBATIM
123 | hoc_execerror("izhi2007b.mod ERRA: derivtype not set",0);
124 | ENDVERBATIM
125 | } else {
126 | derivfunc = a*(b*(v-vr)-u) : Calculate recovery variable
127 | }
128 | }
129 |
130 | : Input received
131 | NET_RECEIVE (w) {
132 | : Check if spike occurred
133 | if (flag == 1) { : Fake event from INITIAL block
134 | if (celltype == 4) { : LTS cell
135 | WATCH (v>(vpeak-0.1*u)) 2 : Check if threshold has been crossed, and if so, set flag=2
136 | } else if (celltype == 6) { : TC cell
137 | WATCH (v>(vpeak+0.1*u)) 2
138 | } else { : default for all other types
139 | WATCH (v>vpeak) 2
140 | }
141 | : additional WATCHfulness
142 | if (celltype==6 || celltype==7) {
143 | WATCH (v> -65) 3 : change b param
144 | WATCH (v< -65) 4 : change b param
145 | }
146 | if (celltype==5) {
147 | WATCH (v> d) 3 : going up
148 | WATCH (v< d) 4 : coming down
149 | }
150 | v = vr : initialization can be done here
151 | : FLAG 2 Event created by WATCH statement -- threshold crossed for spiking
152 | } else if (flag == 2) {
153 | if (alive) {net_event(t)} : Send spike event if the cell is alive
154 | : For LTS neurons
155 | if (celltype == 4) {
156 | v = c+0.04*u : Reset voltage
157 | if ((u+d)<670) {u=u+d} : Reset recovery variable
158 | else {u=670}
159 | }
160 | : For FS neurons (only update v)
161 | else if (celltype == 5) {
162 | v = c : Reset voltage
163 | }
164 | : For TC neurons (only update v)
165 | else if (celltype == 6) {
166 | v = c-0.1*u : Reset voltage
167 | u = u+d : Reset recovery variable
168 | } else {: For RS, IB and CH neurons, and RTN
169 | v = c : Reset voltage
170 | u = u+d : Reset recovery variable
171 | }
172 | : FLAG 3 Event created by WATCH statement -- v exceeding set point for param reset
173 | } else if (flag == 3) {
174 | : For TC neurons
175 | if (celltype == 5) { derivtype = 1 : if (v>d) u'=a*((0.025*(v-d)*(v-d)*(v-d))-u)
176 | } else if (celltype == 6) { b=0
177 | } else if (celltype == 7) { b=2
178 | }
179 | : FLAG 4 Event created by WATCH statement -- v dropping below a setpoint for param reset
180 | } else if (flag == 4) {
181 | if (celltype == 5) { derivtype = 2 : if (v30) V=c [reset]")
94 | xlabel(" u' = a*(b*V-u); if (V>30) u=u+d [reset]")
95 | xpanel()
96 | hbox.intercept(1)
97 | for ii=0,$o1.count-1 {
98 | jj=transpose(ii)
99 | if (ii%rows==0) xpanel("")
100 | sprint(tstr,"p(%d)",jj)
101 | xbutton($o1.object(jj).s,tstr)
102 | if (ii%rows==rows-1) xpanel()
103 | }
104 | hbox.intercept(0)
105 | hbox.map("")
106 | vbox.intercept(0)
107 | vbox.map("Spike patterns")
108 | label=""
109 | }
110 |
111 | func transpose () { return int($1/rows) + $1%rows*cols }
112 | endtemplate bubox
113 |
114 | //* plotting & printing
115 | newPlotV()
116 | g=graphItem
117 | g.erase_all
118 | g.addvar("izh.V",2,2)
119 | // g.addvar("izh.u",3,1)
120 | // g.addvar("izh.Iin",4,2) // will show false ramps
121 | nrnpointmenu(izh)
122 | bub = new bubox(butnl)
123 |
124 | //* initialization
125 | fih=new FInitializeHandler("uvvset()")
126 | fih[1]=new FInitializeHandler(0,"Isend()")
127 | // initialization routines
128 | proc uvvset () {
129 | izh.V=vviv.x[rnum]
130 | izh.u=izh.V*izh.b
131 | if (rnum==17) izh.u=-16 // example 17 also requires different mod file
132 | }
133 |
134 | // current injections for specific models
135 | proc Isend () { local T1,T2,T3,T4
136 | T1=tstop/10
137 | izh.Iin=0
138 | if (rnum==0) { // (A) tonic spiking
139 | Isend1(T1,14)
140 | } else if (rnum==1) { // (B) phasic spiking
141 | T1=20
142 | Isend1(T1,0.5)
143 | } else if (rnum==2) { // (C) tonic bursting
144 | T1=22
145 | Isend1(T1,15)
146 | } else if (rnum==3) { // (D) phasic bursting
147 | T1=20
148 | Isend1(T1,0.6)
149 | } else if (rnum==4) { // (E) mixed mode
150 | Isend1(T1,10)
151 | } else if (rnum==5) { // (F) spike freq. adapt
152 | Isend1(T1,30)
153 | } else if (rnum==6) { // (G) Class 1 exc. -- playvec
154 | } else if (rnum==7) { // (H) Class 2 exc. -- playvec
155 | } else if (rnum==8) { // (izh.Iin) spike latency
156 | Isend1(T1,7.04)
157 | Isend1(T1+3,0.0)
158 | } else if (rnum==9) { // (J) subthresh. osc.
159 | Isend1(T1,2)
160 | Isend1(T1+5,0)
161 | } else if (rnum==10) { // (K) resonator
162 | T2=T1+20 T3 = 0.7*tstop T4 = T3+40
163 | Isend1(T1,0.65) Isend1(T2,0.65) Isend1(T3,0.65) Isend1(T4,0.65)
164 | Isend1(T1+4,0.) Isend1(T2+4,0.) Isend1(T3+4,0.) Isend1(T4+4,0.)
165 | } else if (rnum==11) { // (L) integrator
166 | T1=tstop/11 T2=T1+5 T3 = 0.7*tstop T4 = T3+10
167 | Isend1(T1,9) Isend1(T2,9) Isend1(T3,9) Isend1(T4,9)
168 | Isend1(T1+2,0.) Isend1(T2+2,0.) Isend1(T3+2,0.) Isend1(T4+4,0.)
169 | } else if (rnum==12) { // (M) rebound spike
170 | T1=20
171 | Isend1(T1,-15)
172 | Isend1(T1+5,0)
173 | } else if (rnum==13) { // (N) rebound burst
174 | T1=20
175 | Isend1(T1,-15)
176 | Isend1(T1+5,0)
177 | } else if (rnum==14) { // (O) thresh. variability
178 | T1=10 T2=70 T3=80
179 | Isend1(T1,1) Isend1(T2,-6) Isend1(T3,1)
180 | Isend1(T1+5,0.) Isend1(T2+5,0.) Isend1(T3+5,0.)
181 | } else if (rnum==15) { // (P) bistability
182 | T1=tstop/8 T2=216
183 | izh.Iin=0.24
184 | Isend1(T1,1.24) Isend1(T2,1.24)
185 | Isend1(T1+5,0.24) Isend1(T2+5,0.24)
186 | } else if (rnum==16) { // (Q) DAP depolarizing afterpotential
187 | T1 = 10
188 | Isend1(T1-1,20)
189 | Isend1(T1+1,0)
190 | } else if (rnum==17) { // (R) accomodation -- playvec
191 | } else if (rnum==18) { // (S) inhibition induced spiking
192 | izh.Iin=80
193 | Isend1(50,75)
194 | Isend1(250,80)
195 | } else if (rnum==19) { // (T) inhibition induced bursting
196 | izh.Iin=80
197 | Isend1(50,80) // Isend1(50,75) -- will crash simulator
198 | Isend1(250,80)
199 | }
200 | }
201 |
202 | proc Isend1 () {
203 | sprint(tstr,"izh.Iin=%g cvode.re_init()",$2)
204 | cvode.event($1,tstr)
205 | }
206 |
207 | // izhstim() sets up a single stim into izh cell
208 | // effect easily seen by running "Class 1" -- p(6)
209 | proc izhstim () {
210 | stim=new NetStim(0.5)
211 | stim.number = stim.start = 1
212 | nc = new NetCon(stim,izh)
213 | nc.delay = 2
214 | nc.weight = 0.1
215 | izh.erev = -5
216 | }
217 |
--------------------------------------------------------------------------------
/NEURON/README.md:
--------------------------------------------------------------------------------
1 | ## Izhikevich artificial neuron model from 2 different publications: 1) Izhikevich et al, 2003; and 2) Izhikevich, 2007.
2 |
3 | ### Files
4 |
5 | File | Information |
6 | -----|-----------
7 | [izhi2003a.mod](izhi2003a.mod) | Integrates STATE {u, vv}; firing patterns in 2003, 2004 papers; POINT_PROCESS Izhi2003a
8 | [izhi2003b.mod](izhi2003b.mod) | Integrates STATE {u}; v calculated in a Section; firing patterns in 2003, 2004 papers; POINT_PROCESS Izhi2003b
9 | [izhi2007a.mod](izhi2007a.mod) | No STATE -- uses Euler explicit integration update rule, includes synapses; cell types in 2007 book+syns; POINT_PROCESS Izhi2007a
10 | [izhi2007b.mod](izhi2007b.mod) | Integrates STATE {u}; v calculated in a Section; firing patterns in 2007 book; POINT_PROCESS Izhi2007b
11 | [izhi2003.m](../MATLAB/izhi2003.m) | MATLAB code to replicate firing patterns in 2003 paper
12 | [izhi2007.m](../MATLAB/izhi2007.m) | MATLAB code to replicate firing patterns in 2007 book
13 | [simple.py](simple.py) | Much brief example to just create 1 of each of the types + 1 additional example using izhi2007Wrapper
14 | [izhiGUI.py](izhiGUI.py) | Runs interactive demo of 6 Izhikevich cell models (3 parameter sets, 2 implementations of each)
15 | [izhi2007Figs.py](izhi2007Figs.py) | Uses python graphicss to graph firing patterns of 7 cell types in 2007 book
16 | [izhi2007Wrapper.py](izhi2007Wrapper.py) | Instantiates the 7 cell types in 2007 book
17 | [izhi2003.png](izhi2003.png) | Illustration of firing patterns in 2003 paper
18 | [izhi2004.gif](izhi2004.gif) | Illustration of firing patterns in 2004 paper
19 | [izhi2007Comparison.pdf](izhi2007Comparison.pdf) | Illustration of firing patterns in 2007 book (and comparison to model)
20 | [izhi2004a.hoc](izhi2004a.hoc) | hoc file retained for archaeological interest
21 | [README](README) | Original README file (can be read as an org-mode file in emacs)
22 |
23 | ### 2003-2004 Models
24 |
25 | EM Izhikevich "Simple Model of Spiking Neurons" IEEE Transactions On Neural Networks, Vol. 14, No. 6, November 2003 pp 1569-1572
26 |
27 | EM Izhikevich "Which model to use for cortical spiking neurons?" IEEE Transactions On Neural Networks, Vol. 15, No. 5, 2004 pp 1063-1070
28 |
29 | This single parameterization was used in these 2 papers with different cell-sets being represented, although with some overlap. We have separately replicated the cell-sets from each paper.
30 |
31 | **Solves the following equations:**
32 |
33 | v' = e*v^2 + f*v + g - u + I; RESET if (v>30) v=c
34 | u' = a*(b*v-u); RESET if (v>30) u=u+d
35 |
36 | (note that vv is used in for voltage in izhi2003a.mod so doesn't
37 | interfere with built-in v of cell -- the built-in v is used for
38 | izhi2003b.mod)
39 |
40 | a,b,c,d,I are the major parameters; f,g are reset for 2 simulations (G-"Class 1" and L-"integrator")
41 |
42 | 3 of the simulations shown in izhi2004.gif are not properly replicated:
43 | Q: depolarizing afterpotential does not repolarize properly
44 | R: accomodation requires an alteration of the functional forms to replicate
45 | (alternate functional form given on line 52 of izh.mod)
46 | T: too unstable for Neuron integrators to handle
47 | (changing izh.hoc line 203 to Isend1(50,75) will crash simulator)
48 |
49 | ### 2007 Models description
50 |
51 | Equations and parameter values taken from: Izhikevich EM (2007). "Dynamical systems in neuroscience" MIT Press
52 | Equation for synaptic inputs built-in for izhi2007.mod were taken from: Izhikevich EM, Edelman GM (2008). "Large-scale model of mammalian thalamocortical systems" PNAS 105 3593-3598.
53 | (Note that this 2008 model is a multicompartmental model that we do not replicate here so we are using 2007 model with 2008 synapses.)
54 |
55 | **Solves the following equations:**
56 |
57 | v' = v + (k*(v-vr)*(v-vt) - u - I)/C;
58 | u' = u + (a*(b*(v-vr)-u);
59 | RESET if v > vpeak: v = c ; u = u + d
60 |
61 | (note that additional resets are used for particular models -- ie the
62 | simulation is displaced in the phase plane to produce interruption and
63 | create next stage of dynamics; see below)
64 |
65 | The following parameters specific to each cell type: C, k, vr, vt, vpeak, a, b, c, d and celltype
66 |
67 | Cell types available are based on Izhikevich, 2007 book (chapter
68 | 8). Here we include a description of each cell type, the model
69 | parameters required to implement it, and the conditions to replicate
70 | the 2007 book figures:
71 |
72 | 1. RS - Layer 5 regular spiking pyramidal cell (fig 8.12 from 2007
73 | book) Parameters: C=100; k=0.7; vr=-60; vt=-40; vpeak=35;
74 | a=0.03; b=-2; c=-50; d=100; celltype=1 Book fig: T = 520 ms;
75 | IinRange = [60,70,85,100] pA
76 |
77 | 2. IB - Layer 5 intrinsically bursting cell (fig 8.19 from 2007
78 | book) Parameters: C=150; k=1.2; vr=-75; vt=-45; vpeak=50;
79 | a=0.01; b=5; c=-56; d=130; celltype=2 Book fig: T = 600 ms;
80 | IinRange = [290,370,500,550] pA
81 |
82 | 3. CH - Cat primary visual cortex chattering cell (fig 8.23 from
83 | 2007 book) Parameters: C=50; k=1.5; vr=-60; vt=-40; vpeak=25;
84 | a=0.03; b=1; c=-40; d=150; celltype=3 Book fig: T = 210 ms;
85 | IinRange = [200,300,400,600] pA
86 |
87 | 4. LTS - Rat barrel cortex Low-threshold spiking interneuron (fig
88 | 8.25 from 2007 book) Parameters: C=100; k=1; vr=-56; vt=-42;
89 | vpeak=40; a=0.03; b=8; c=-53; d=20; celltype=4 Book fig: T =
90 | 100 ms; IinRange = [100,125,200,300] pA
91 |
92 | 5. FS - Rat visual cortex layer 5 fast-spiking interneuron (fig
93 | 8.27 from 2007 book) Parameters: C=20; k=1; vr=-55; vt=-40;
94 | vpeak=25; a=0.2; b=-2; c=-45; d=-55; celltype=5; Book fig: T =
95 | 100 ms; IinRange = [73.2,100,200,400] pA
96 |
97 | 6. TC - Cat dorsal LGN thalamocortical (TC) cell (fig 8.31 from
98 | 2007 book) C=200; k=1.6; vr=-60; vt=-50; vpeak=35; a=0.01;
99 | b=15; c=-60; d=10; celltype=6 Book fig: T = 650 ms; IinRange =
100 | [50,100,150] pA Book fig (burst mode): T0 = 120 ms; Iin0 =
101 | -1200 pA; T = 650 ms; IinRange = [0,50,100] pA
102 |
103 | 7. RTN - Rat reticular thalamic nucleus (RTN) cell (fig 8.32 from
104 | 2007 book) Parameters: C=40; k=0.25; vr=-65; vt=-45;
105 | vpeak=0; a=0.015; b=10; c=-55; d=50; celltype=7 Book
106 | fig: T = 650 ms; IinRange = [50,70,110] pA Book fig
107 | (burst mode): T0 = 120 ms; Iin0 = -350 pA; T = 720 ms;
108 | IinRange = [30,50,90] pA
109 |
110 |
111 | Note: The LTS, FS, TC and RTN cells require modifications to the
112 | general equations -- additional resets on phase plane.
113 | See the matlab (izhi2007.m) or the Python/Neuron (izhi2007.mod) for
114 | details. For a full description see chapter 8 of Izhikevich, 2007.
115 |
116 | ### Compiling with nrnivmodl
117 |
118 | nrnivmodl izhi2003a izhi2003b izhi2007a izhi2007b
119 |
120 | ### GUI for exploring parameters
121 |
122 | python -i izhiGUI.py
123 |
124 | Sets up menu to choose among 6 models using 2 different
125 | parameterizations (2003/4 vs 2007) with 3 parameter sets illustrating
126 | different cell dynamics (2003, 2004, 2007) and different
127 | implementation types (voltage in a section vs both u,v calculated in
128 | the mod file).
129 |
130 | Each choice brings up a menu of all parameter settings as well as a
131 | menu of standard choices based on cell types.
132 |
133 | Simple simulation -- default parameter implementations in simple.py
134 |
135 | python
136 | import simple
137 | h.run()
138 | simple.show()
139 |
140 | Sets up 5 models using default parameters in the .mod files:
141 |
142 | 2 versions of 2003/2004 parameterization: freestanding (3a); in section (3b)
143 | 3 versions of 2007/2008 parameterization: freestanding (7a); in section (7b); in sec using wrapper class (7bw) can graph u, v for any model
144 |
145 | simple.show('v3a','v3b') # compare voltage output for the 2 versions of the 2003/2004 parameterization; will NOT be identical
146 |
147 | simple.show('v7a','v7b','v7bw') # compare voltage output for 3 versions of the 2007 parameterization
148 |
149 | ### MATLAB/Octave versions
150 |
151 | See [izhi2003.m](../MATLAB/izhi2003.m) and [izhi2007.m](../MATLAB/izhi2007.m):
152 |
153 | matlab izhi2003.m
154 | octave --persist izhi2003.m
155 |
156 | ### Old hoc version for 2004
157 |
158 | nrnivmodl izhi2003a
159 | nrngui izhi2004a.hoc
160 |
161 | ### Implementation
162 |
163 | Please ask any general questions on NEURON Forum
164 |
165 | Salvador Dura-Bernal salvadordura@gmail.com
166 | Cliff Kerr cliffk@neurosim.downstate.edu
167 | Bill Lytton billl@neurosim.downstate.edu
168 |
169 |
170 | ### graphics of simulations -- names indicates which parameterization was used
171 |
172 | [izh2003.gif](izh2003.gif) # figure taken from original paper
173 |
174 | [izhi2003.png](izhi2003.png) # sim results
175 |
176 | [izhi2004.gif](izhi2004.gif) # figure taken from original paper
177 |
178 | [izhi2007Comparison.pdf](izhi2007Comparison.pdf) # side by side comparison of figures from paper
179 | with these sims
180 |
181 |
--------------------------------------------------------------------------------
/NEURON/README:
--------------------------------------------------------------------------------
1 | * Izhikevich artificial neuron model from 2 different publications: 1)
2 | Izhikevich et al, 2003; and 2) Izhikevich, 2007.
3 |
4 | Files:
5 |
6 | izhi2003a.mod // integrates STATE {u, vv}; firing patterns in 2003,
7 | 2004 papers; POINT_PROCESS Izhi2003a
8 |
9 | izhi2003b.mod // integrates STATE {u}; v calculated in a Section;
10 | firing patterns in 2003, 2004 papers; POINT_PROCESS Izhi2003b
11 |
12 | izhi2007a.mod // no STATE -- uses Euler explicit integration update
13 | rule, includes synapses; cell types in 2007 book+syns; POINT_PROCESS
14 | Izhi2007a
15 |
16 | izhi2007b.mod // no STATE -- uses Euler explicit integration update
17 | rule; v calculated in a Section; firing patterns in 2007 book;
18 | POINT_PROCESS Izhi2007b
19 |
20 | izhi2007bS.mod // integrates STATE {u}; v calculated in a Section;
21 | firing patterns in 2007 book; POINT_PROCESS Izhi2007bS
22 |
23 | izhi2003.m // Matlab code to replicate firing patterns in 2003 paper
24 | izhi2007.m // Matlab code to replicate firing patterns in 2007 book
25 |
26 | simple.py // much brief example to just create 1 of each of the types
27 | + 1 additional example using izhi2007Wrapper
28 | izhiGUI.py // runs interactive demo of 6 Izhikevich cell models (3
29 | parameter sets, 2 implementations of each)
30 | izhi2007Figs.py // uses python graphicss to graph firing patterns of 7
31 | cell types in 2007 book
32 | izhi2007Wrapper.py // instantiates the 7 cell types in 2007 book
33 |
34 |
35 | izhi2003.png // Illustration of firing patterns in 2003 paper
36 | izhi2004.gif // Illustration of firing patterns in 2004 paper
37 | izhi2007Comparison.pdf // Illustration of firing patterns in 2007 book
38 | (and comparison to model)
39 |
40 | izhi2004a.hoc // hoc file retained for archaeological interest
41 |
42 | README // this file (can be read as an org-mode file in emacs)
43 |
44 | * 2003-2004 Models:
45 |
46 | EM Izhikevich "Simple Model of Spiking Neurons" IEEE Transactions On
47 | Neural Networks, Vol. 14, No. 6, November 2003 pp 1569-1572
48 |
49 | EM Izhikevich "Which model to use for cortical spiking neurons?" IEEE
50 | Transactions On Neural Networks, Vol. 15, No. 5, 2004 pp 1063-1070
51 |
52 | This single parameterization was used in these 2 papers with different
53 | cell-sets being represented, although with some overlap. We have
54 | separately replicated the cell-sets from each paper.
55 |
56 | ** solves the following equations:
57 |
58 | v' = e*v^2 + f*v + g - u + I; RESET if (v>30) v=c
59 | u' = a*(b*v-u); RESET if (v>30) u=u+d
60 | (note that vv is used in for voltage in izhi2003a.mod so doesn't
61 | interfere with built-in v of cell -- the built-in v is used for
62 | izhi2003b.mod)
63 |
64 |
65 | ** a,b,c,d,I are the major parameters;
66 | f,g are reset for 2 simulations (G-"Class 1" and L-"integrator")
67 |
68 | 3 of the simulations shown in izhi2004.gif are not properly replicated:
69 | Q: depolarizing afterpotential does not repolarize properly
70 | R: accomodation requires an alteration of the functional forms to replicate
71 | (alternate functional form given on line 52 of izh.mod)
72 | T: too unstable for Neuron integrators to handle
73 | (changing izh.hoc line 203 to Isend1(50,75) will crash simulator)
74 |
75 | * 2007 Models description:
76 |
77 | Equations and parameter values taken from: Izhikevich EM
78 | (2007). "Dynamical systems in neuroscience" MIT Press
79 | Equation for synaptic inputs built-in for izhi2007.mod were taken
80 | from: Izhikevich EM, Edelman GM (2008). "Large-scale model of
81 | mammalian thalamocortical systems" PNAS 105 3593-3598.
82 | (Note that this 2008 model is a multicompartmental model that we do
83 | not replicate here so we are using 2007 model with 2008 synapses.)
84 |
85 | ** solves the following equations:
86 | v' = v + (k*(v-vr)*(v-vt) - u - I)/C;
87 | u' = u + (a*(b*(v-vr)-u);
88 |
89 | RESET if v > vpeak: v = c ; u = u + d
90 | (note that additional resets are used for particular models -- ie the
91 | simulation is displaced in the phase plane to produce interruption and
92 | create next stage of dynamics; see below)
93 |
94 | ** The following parameters specific to each cell type: C, k, vr, vt,
95 | vpeak, a, b, c, d and celltype
96 |
97 | Cell types available are based on Izhikevich, 2007 book (chapter
98 | 8). Here we include a description of each cell type, the model
99 | parameters required to implement it, and the conditions to replicate
100 | the 2007 book figures:
101 |
102 | 1. RS - Layer 5 regular spiking pyramidal cell (fig 8.12 from 2007
103 | book) Parameters: C=100; k=0.7; vr=-60; vt=-40; vpeak=35;
104 | a=0.03; b=-2; c=-50; d=100; celltype=1 Book fig: T = 520 ms;
105 | IinRange = [60,70,85,100] pA
106 |
107 | 2. IB - Layer 5 intrinsically bursting cell (fig 8.19 from 2007
108 | book) Parameters: C=150; k=1.2; vr=-75; vt=-45; vpeak=50;
109 | a=0.01; b=5; c=-56; d=130; celltype=2 Book fig: T = 600 ms;
110 | IinRange = [290,370,500,550] pA
111 |
112 | 3. CH - Cat primary visual cortex chattering cell (fig 8.23 from
113 | 2007 book) Parameters: C=50; k=1.5; vr=-60; vt=-40; vpeak=25;
114 | a=0.03; b=1; c=-40; d=150; celltype=3 Book fig: T = 210 ms;
115 | IinRange = [200,300,400,600] pA
116 |
117 | 4. LTS - Rat barrel cortex Low-threshold spiking interneuron (fig
118 | 8.25 from 2007 book) Parameters: C=100; k=1; vr=-56; vt=-42;
119 | vpeak=40; a=0.03; b=8; c=-53; d=20; celltype=4 Book fig: T =
120 | 100 ms; IinRange = [100,125,200,300] pA
121 |
122 | 5. FS - Rat visual cortex layer 5 fast-spiking interneuron (fig
123 | 8.27 from 2007 book) Parameters: C=20; k=1; vr=-55; vt=-40;
124 | vpeak=25; a=0.2; b=-2; c=-45; d=-55; celltype=5; Book fig: T =
125 | 100 ms; IinRange = [73.2,100,200,400] pA
126 |
127 | 6. TC - Cat dorsal LGN thalamocortical (TC) cell (fig 8.31 from
128 | 2007 book) C=200; k=1.6; vr=-60; vt=-50; vpeak=35; a=0.01;
129 | b=15; c=-60; d=10; celltype=6 Book fig: T = 650 ms; IinRange =
130 | [50,100,150] pA Book fig (burst mode): T0 = 120 ms; Iin0 =
131 | -1200 pA; T = 650 ms; IinRange = [0,50,100] pA
132 |
133 | 7. RTN - Rat reticular thalamic nucleus (RTN) cell (fig 8.32 from
134 | 2007 book) Parameters: C=40; k=0.25; vr=-65; vt=-45;
135 | vpeak=0; a=0.015; b=10; c=-55; d=50; celltype=7 Book
136 | fig: T = 650 ms; IinRange = [50,70,110] pA Book fig
137 | (burst mode): T0 = 120 ms; Iin0 = -350 pA; T = 720 ms;
138 | IinRange = [30,50,90] pA
139 |
140 |
141 | Note: The LTS, FS, TC and RTN cells require modifications to the
142 | general equations -- additional resets on phase plane.
143 | See the matlab (izhi2007.m) or the Python/Neuron (izhi2007.mod) for
144 | details. For a full description see chapter 8 of Izhikevich, 2007.
145 |
146 | * compiling with nrnivmodl
147 | nrnivmodl izhi2003a izhi2003b izhi2007a izhi2007b
148 |
149 | * GUI for exploring parameters
150 | python -i izhiGUI.py
151 | Sets up menu to choose among 6 models using 2 different
152 | parameterizations (2003/4 vs 2007) with 3 parameter sets illustrating
153 | different cell dynamics (2003, 2004, 2007) and different
154 | implementation types (voltage in a section vs both u,v calculated in
155 | the mod file).
156 |
157 | Each choice brings up a menu of all parameter settings as well as a
158 | menu of standard choices based on cell types.
159 |
160 | * simple simulation -- default parameter implementations in simple.py
161 | python
162 | from neuron import h,gui
163 | import simple
164 | h.run()
165 | simple.show()
166 |
167 | Sets up 5 models using default parameters in the .mod files
168 |
169 | 2 versions of 2003/2004 parameterization: freestanding (3a); in
170 | section (3b)
171 | 3 versions of 2007/2008 parameterization: freestanding (7a); in
172 | section (7b); in sec using wrapper class (7bw) can graph u, v for any
173 | model
174 | simple.show('v3a','v3b') # compare voltage output for the 2 versions
175 | of the 2003/2004 parameterization; will NOT be identical
176 | simple.show('v7a','v7b','v7bw') # compare voltage output for 3
177 | versions of the 2007 parameterization
178 |
179 | * matlab/octave versions
180 | matlab izhi2003.m
181 | octave --persist izhi2003.m
182 |
183 | * old hoc version for 2004
184 | nrnivmodl izhi2003a
185 | nrngui izhi2004a.hoc
186 |
187 | * implementation -- please ask any general questions on NEURON Forum
188 | Salvador Dura-Bernal salvadordura@gmail.com
189 | Cliff Kerr cliffk@neurosim.downstate.edu
190 | Bill Lytton billl@neurosim.downstate.edu
191 |
192 |
193 | * graphics of simulations -- names indicates which parameterization was used
194 | izh2003.gif # figure taken from original paper
195 | izhi2003.png # sim results
196 | izhi2004.gif # figure taken from original paper
197 | izhi2007Comparison.pdf # side by side comparison of figures from paper
198 | with these sims
199 |
200 | 20151006 Revisision: A command "from neuron import h,gui" was added
201 | above to the simple simulation demo.
202 |
203 | 20160303 Updated integration method of the izhi2007b cell model from
204 | Salva Dura. Addition of izhi2007bS.mod and replacement of
205 | izhi2007b.mod and revision of this readme's documentation of
206 | izhi2007b.mod and addition of izhi2007bS.mod documentation.
207 |
--------------------------------------------------------------------------------
/NEURON/izhi2007a.mod:
--------------------------------------------------------------------------------
1 | COMMENT
2 | A "simple" implementation of the Izhikevich neuron with AMPA, NMDA,
3 | GABA_A, and GABA_B receptor dynamics. Equations and parameter values are taken from
4 | Izhikevich EM (2007).
5 | "Dynamical systems in neuroscience"
6 | MIT Press
7 |
8 | Equation for synaptic inputs taken from
9 | Izhikevich EM, Edelman GM (2008).
10 | "Large-scale model of mammalian thalamocortical systems."
11 | PNAS 105(9) 3593-3598.
12 |
13 | Example usage (in Python):
14 | from neuron import h
15 | dummycell = h.Section() # Since Izhi is a point process, it needs to be in a section
16 | izhl = [h.Izhi2007(0.5) for i in range(2)] # Create two new Izhikevich cells
17 | connection = h.NetCon(izhl[0], izhl[1]) # Connect them
18 | izhl[0].Iin = 70 # activate 1 cell
19 |
20 | Cell types available are based on Izhikevich, 2007 book:
21 | 1. RS - Layer 5 regular spiking pyramidal cell (fig 8.12 from 2007 book)
22 | 2. IB - Layer 5 intrinsically bursting cell (fig 8.19 from 2007 book)
23 | 3. CH - Cat primary visual cortex chattering cell (fig8.23 from 2007 book)
24 | 4. LTS - Rat barrel cortex Low-threshold spiking interneuron (fig 8.25 from 2007 book)
25 | 5. FS - Rat visual cortex layer 5 fast-spiking interneuron (fig 8.27 from 2007 book)
26 | 6. TC - Cat dorsal LGN thalamocortical (TC) cell (fig 8.31 from 2007 book)
27 | 7. RTN - Rat reticular thalamic nucleus (RTN) cell (fig 8.32 from 2007 book)
28 | ENDCOMMENT
29 |
30 | : Declare name of object and variables
31 | NEURON {
32 | POINT_PROCESS Izhi2007a
33 | RANGE C, k, vr, vt, vpeak, a, b, c, d, Iin, tauAMPA, tauNMDA, tauGABAA, tauGABAB, tauOpsin, celltype, alive, cellid, verbose
34 | RANGE V, u, gAMPA, gNMDA, gGABAA, gGABAB, gOpsin, I
35 | RANGE factor, eventflag, delta, t0
36 | }
37 |
38 | : Specify units that have physiological interpretations (NB: ms is already declared)
39 | UNITS {
40 | (mV) = (millivolt)
41 | (uM) = (micrometer)
42 | }
43 |
44 | : Parameters from Izhikevich 2007, MIT Press for regular spiking pyramidal cell
45 | PARAMETER {
46 | C = 100 : Capacitance
47 | k = 0.7
48 | vr = -60 (mV) : Resting membrane potential
49 | vt = -40 (mV) : Membrane threhsold
50 | vpeak = 35 (mV) : Peak voltage
51 | a = 0.03
52 | b = -2
53 | c = -50
54 | d = 100
55 | Iin = 0
56 | Vpre = 0
57 | tauAMPA = 5 (ms) : Receptor time constant, AMPA
58 | tauNMDA = 150 (ms) : Receptor time constant, NMDA
59 | tauGABAA = 6 (ms) : Receptor time constant, GABAA
60 | tauGABAB = 150 (ms) : Receptor time constant, GABAB
61 | tauOpsin = 50 (ms) : Receptor time constant, opsin, from Mattis et al. (2011)
62 | celltype = 1 : A flag for indicating what kind of cell it is, used for changing the dynamics slightly (see list of cell types in initial comment).
63 | alive = 1 : A flag for deciding whether or not the cell is alive -- if it's dead, acts normally except it doesn't fire spikes
64 | cellid = -1 : A parameter for storing the cell ID, if required (useful for diagnostic information)
65 | verbose = 0 : Whether or not to print diagnostic information to file -- WARNING, do not modify this manually -- it's set by useverbose()
66 | }
67 |
68 | : Variables used for internal calculations
69 | ASSIGNED {
70 | factor : Voltage factor used for calculating the current
71 | eventflag : For diagnostic information
72 | V (mV) : Membrane voltage
73 | u (mV) : Slow current/recovery variable
74 | gAMPA : AMPA conductance
75 | gNMDA : NMDA conductance
76 | gGABAA : GABAA conductance
77 | gGABAB : GABAB conductance
78 | gOpsin : Opsin conductance
79 | I : Total current
80 | delta : Time step
81 | t0 : Previous time
82 | }
83 |
84 | : Initial conditions
85 | INITIAL {
86 | V = vr
87 | u = 0.2*vr
88 | t0 = t
89 | gAMPA = 0
90 | gNMDA = 0
91 | gGABAA = 0
92 | gGABAB = 0
93 | gOpsin = 0
94 | I = 0
95 | delta = 0
96 | net_send(0,1) : Required for the WATCH statement to be active
97 | }
98 |
99 |
100 | : Function for printing diagnostic information to a file -- usage example: cell.useverbose(2,"logfile.txt")
101 | VERBATIM
102 | char filename[1000]; // Allocate some memory for the filename
103 | ENDVERBATIM
104 | PROCEDURE useverbose() { : Create user-accessible function
105 | VERBATIM
106 | #include // Basic input-output
107 | verbose = (float) *getarg(1); // Set verbosity -- 0 = none, 1 = events, 2 = events + timesteps
108 | strcpy(filename, gargstr(2)); // Copy input filename into memory
109 | ENDVERBATIM
110 | }
111 |
112 | : Define neuron dynamics
113 | BREAKPOINT {
114 | delta = t-t0 : Find time difference
115 |
116 | : Receptor dynamics -- the correct form is gAMPA = gAMPA*exp(-delta/tauAMPA), but this is 30% slower and, in the end, not really any more physiologically realistic
117 | gAMPA = gAMPA - delta*gAMPA/tauAMPA : "Exponential" decays -- fast excitatory (AMPA)
118 | gNMDA = gNMDA - delta*gNMDA/tauNMDA : Slow excitatory (NMDA)
119 | gGABAA = gGABAA - delta*gGABAA/tauGABAA : Fast inhibitory (GABA_A)
120 | gGABAB = gGABAB - delta*gGABAB/tauGABAB : Slow inhibitory (GABA_B)
121 | gOpsin = gOpsin - delta*gOpsin/tauOpsin : Optogenetic (opsin)
122 |
123 | : Calculate current
124 | factor = ((V+80)/60)*((V+80)/60)
125 | I = gAMPA*(V-0) + gNMDA*factor/(1+factor)*(V-0) + gGABAA*(V+70) + gGABAB*(V+90) + gOpsin*(V-0) : Treat the opsin channel like an AMPA channel
126 |
127 | : Calculate neuronal dynamics; -I since I = -I_{syn}, which is really what I is as I've defined it above
128 | Vpre = V
129 | V = V + delta*(k*(V-vr)*(V-vt) - u - I + Iin)/C : Calculate voltage
130 |
131 | if (Vpre<=c && V>vpeak) {V=c+1} : if just spiked, wait at least 1 timestep before increasing V>vpeak again, so V reset value takes effect; WATCH statement requires V to cross the vpeak threshod)
132 |
133 | : Cell-type specific dynamics
134 | if (celltype<5) {
135 | u = u + delta*a*(b*(V-vr)-u) : Calculate recovery variable
136 | }
137 | else {
138 | : For FS neurons, include nonlinear U(v): U(v) = 0 when v=vb (d=vb=-55)
139 | if (celltype==5) {
140 | if (V-65) {b=0}
151 | else {b=15}
152 | u = u + delta*a*(b*(V-vr)-u) : Calculate recovery variable
153 | }
154 |
155 | : For TRN neurons, reset b
156 | if (celltype==7) {
157 | if (V>-65) {b=2}
158 | else {b=10}
159 | u = u + delta*a*(b*(V-vr)-u) : Calculate recovery variable
160 | }
161 | }
162 |
163 | t0=t : Reset last time so delta can be calculated in the next time step
164 |
165 | : Print diagnostic inormation to a file
166 | if (verbose>1) { : Verbose turned on?
167 | VERBATIM
168 | FILE *outfile; // Declare file object
169 | outfile=fopen(filename,"a"); // Open file for appending
170 | fprintf(outfile,"%8.2f cell=%6.0f delta=%8.2f gAMPA=%8.2f gNMDA=%8.2f gGABAA=%8.2f gGABAB=%8.2f gOpsin=%8.2f factor=%8.2f I=%8.2f V=%8.2f u=%8.2f (timestep)\n",t,cellid,delta,gAMPA,gNMDA,gGABAA,gGABAB,gOpsin,factor,I,V,u);
171 | fclose(outfile); // Close file
172 | ENDVERBATIM
173 | }
174 | }
175 |
176 | : Input received
177 | NET_RECEIVE (wAMPA, wNMDA, wGABAA, wGABAB, wOpsin) {
178 | INITIAL { wAMPA=wAMPA wNMDA=wNMDA wGABAA=wGABAA wGABAB=wGABAB wOpsin=wOpsin} : Insanely stupid but required, otherwise reset to 0,
179 |
180 | : Check if spike occurred
181 | if (flag == 1) { : Fake event from INITIAL block
182 | if (celltype < 4 || celltype == 5 || celltype == 7) { : default
183 | WATCH (V>vpeak) 2 : Check if threshold has been crossed, and if so, set flag=2
184 | }
185 | else if (celltype == 4) { : LTS cell
186 | WATCH (V>(vpeak-0.1*u)) 2 : Check if threshold has been crossed, and if so, set flag=2
187 | }
188 | else if (celltype == 6) { : TC cell
189 | WATCH (V>(vpeak+0.1*u)) 2 : Check if threshold has been crossed, and if so, set flag=2
190 | }
191 | }
192 |
193 | : Event created by WATCH statement -- i.e. threshold crossed
194 | else if (flag == 2) {
195 | if (alive) {net_event(t)} : Send spike event if the cell is alive
196 |
197 | : For RS, IB and CH neurons, and RTN
198 | if (celltype < 4 || celltype == 7) {
199 | V = c : Reset voltage
200 | u = u+d : Reset recovery variable
201 | }
202 | : For LTS neurons
203 | else if (celltype == 4) {
204 | V = c+0.04*u : Reset voltage
205 | if ((u+d)<670) {u=u+d} : Reset recovery variable
206 | else {u=670}
207 | }
208 | : For FS neurons (only update v)
209 | else if (celltype == 5) {
210 | V = c : Reset voltage
211 | }
212 | : For TC neurons (only update v)
213 | else if (celltype == 6) {
214 | V = c-0.1*u : Reset voltage
215 | u = u+d : Reset recovery variable
216 | }
217 |
218 | gAMPA = 0 : Reset conductances -- not mentioned in Izhikevich's paper but necessary to stop things from exploding!
219 | gNMDA = 0
220 | gGABAA = 0
221 | gGABAB = 0
222 | gOpsin = 0
223 | }
224 |
225 | : Actual input, calculate receptor dynamics
226 | else {
227 | gAMPA = gAMPA + wAMPA
228 | gNMDA = gNMDA + wNMDA
229 | gGABAA = gGABAA + wGABAA
230 | gGABAB = gGABAB + wGABAB
231 | gOpsin = gOpsin + wOpsin
232 | }
233 |
234 | : Print diagnostic information to a file
235 | if (verbose>0) { : Verbose turned on?
236 | eventflag = flag
237 | VERBATIM
238 | FILE *outfile; // Declare file object
239 | //if(cellid>=0 && cellid < 300) {
240 | outfile=fopen(filename,"a"); // Open file for appending
241 | fprintf(outfile,"t=%8.2f cell=%6.0f flag=%1.0f gAMPA=%8.2f gNMDA=%8.2f gGABAA=%8.2f gGABAB=%8.2f gOpsin=%8.2f V=%8.2f u=%8.2f (event)\n",t, cellid,eventflag,gAMPA,gNMDA,gGABAA,gGABAB,gOpsin,V,u);
242 | fclose(outfile); // Close file
243 | //}
244 | ENDVERBATIM
245 | }
246 |
247 |
248 | }
249 |
--------------------------------------------------------------------------------
/NeuroML2/WhichModel.nml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
193 |
194 |
--------------------------------------------------------------------------------
/NeuroML2/LEMS_WhichModel.xml:
--------------------------------------------------------------------------------
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 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
--------------------------------------------------------------------------------
/numba/izhikevich.py:
--------------------------------------------------------------------------------
1 |
2 | from quantities import mV, ms, s, V
3 | from neo import AnalogSignal
4 | import neuronunit.capabilities as cap
5 | import numpy as np
6 | import quantities as pq
7 | import numpy
8 | voltage_units = mV
9 | import copy
10 | from elephant.spike_train_generation import threshold_detection
11 |
12 | from numba import jit#, autojit
13 | import cython
14 | import time
15 | def timer(func):
16 | def inner(*args, **kwargs):
17 | t1 = time.time()
18 | f = func(*args, **kwargs)
19 | t2 = time.time()
20 | print('time taken on block {0} '.format(t2-t1))
21 | return f
22 | return inner
23 |
24 | @jit(nopython=True)
25 | def get_vm_four(C=89.7960714285714,
26 | a=0.01, b=15, c=-60, d=10, k=1.6,
27 | vPeak=(86.364525297619-65.2261863636364),
28 | vr=-65.2261863636364, vt=-50,I=[]):
29 | #celltype=1, N=0,start=0,stop=0,amp=0,ramp=None):
30 | tau = dt = 0.25
31 | N = len(I)
32 |
33 | v = vr*np.ones(N)
34 | u = np.zeros(N)
35 |
36 | v[0] = vr
37 | for i in range(N-1):
38 | # forward Euler method
39 | v[i+1] = v[i] + tau * (k * (v[i] - vr) * (v[i] - vt) - u[i] + I[i]) / C
40 | u[i+1] = u[i]+tau*a*(b*(v[i]-vr)-u[i]); # Calculate recovery variable
41 | if v[i+1] > (vPeak - 0.1*u[i+1]):
42 | v[i] = vPeak - 0.1*u[i+1]
43 | v[i+1] = c + 0.04*u[i+1]; # Reset voltage
44 | if (u[i]+d)<670:
45 | u[i+1] = u[i+1]+d; # Reset recovery variable
46 | else:
47 | u[i+1] = 670;
48 |
49 | return v
50 |
51 | @jit#(nopython=True)
52 | def get_vm_five(C=89.7960714285714,
53 | a=0.01, b=15, c=-60, d=10, k=1.6,
54 | vPeak=(86.364525297619-65.2261863636364),
55 | vr=-65.2261863636364, vt=-50,I=[]):#celltype=1,
56 | #N=0,start=0,stop=0,amp=0,ramp=None,pulse=None):
57 | N = len(I)
58 |
59 | tau= dt = 0.25; #dt
60 | v = vr*np.ones(N)
61 | u = np.zeros(N)
62 | v[0] = vr
63 | for i in range(N-1):
64 | # forward Euler method
65 | v[i+1] = v[i] + tau * (k * (v[i] - vr) * (v[i] - vt) - u[i] + I[i]) / C
66 |
67 | #u[i+1]=u[i]+tau*a*(b*(v[i]-vr)-u[i]); # Calculate recovery variable
68 | if v[i+1] < d:
69 | u[i+1] = u[i] + tau*a*(0-u[i])
70 | else:
71 | u[i+1] = u[i] + tau*a*((0.025*(v[i]-d)**3)-u[i])
72 |
73 |
74 | if v[i+1]>=vPeak:
75 | v[i]=vPeak;
76 | v[i+1]=c;
77 |
78 | return v
79 |
80 |
81 |
82 | @jit#(nopython=True)
83 | def get_vm_six(I,C=89.7960714285714,
84 | a=0.01, b=15, c=-60, d=10, k=1.6,
85 | vPeak=(86.364525297619-65.2261863636364),
86 | vr=-65.2261863636364, vt=-50):
87 | tau= dt = 0.25; #dt
88 | N = len(I)
89 |
90 | v = vr*np.ones(N)
91 | u = np.zeros(N)
92 | v[0] = vr
93 | for i in range(N-1):
94 | # forward Euler method
95 | v[i+1] = v[i] + tau * (k * (v[i] - vr) * (v[i] - vt) - u[i] + I[i]) / C
96 |
97 |
98 | if v[i+1] > -65:
99 | b=0;
100 | else:
101 | b=15;
102 | u[i+1]=u[i]+tau*a*(b*(v[i]-vr)-u[i]);
103 |
104 | if v[i+1] > (vPeak + 0.1*u[i+1]):
105 | v[i]= vPeak + 0.1*u[i+1];
106 | v[i+1] = c-0.1*u[i+1]; # Reset voltage
107 | u[i+1]=u[i+1]+d;
108 |
109 | return v
110 |
111 | @jit#(nopython=True)
112 | def get_vm_seven(C=89.7960714285714,
113 | a=0.01, b=15, c=-60, d=10, k=1.6,
114 | vPeak=(86.364525297619-65.2261863636364),
115 | vr=-65.2261863636364, vt=-50,I=np.array([0])):
116 | tau= dt = 0.25; #dt
117 | N = len(I)
118 |
119 | v = vr*np.ones(N)
120 | u = np.zeros(N)
121 | for i in range(N-1):
122 |
123 | # forward Euler method
124 | v[i+1] = v[i] + tau * (k * (v[i] - vr) * (v[i] - vt) - u[i] + I[i]) / C
125 |
126 |
127 | if v[i+1] > -65:
128 | b=2;
129 | else:
130 | b=10;
131 |
132 | u[i+1]=u[i]+tau*a*(b*(v[i]-vr)-u[i]);
133 | if v[i+1]>=vPeak:
134 | v[i]=vPeak;
135 | v[i+1]=c;
136 | u[i+1]=u[i+1]+d; # reset u, except for FS cells
137 |
138 |
139 | return v
140 |
141 |
142 | @jit(nopython=True)
143 | def get_vm_one_two_three(C=89.7960714285714,
144 | a=0.01, b=15, c=-60, d=10, k=1.6,
145 | vPeak=(86.364525297619-65.2261863636364),
146 | vr=-65.2261863636364, vt=-50,I=np.array([0])):
147 | tau= dt = 0.25; #dt
148 | N = len(I)
149 | v = vr*np.ones(N)
150 | u = np.zeros(N)
151 | for i in range(N-1):
152 | # forward Euler method
153 | v[i+1] = v[i] + tau * (k * (v[i] - vr) * (v[i] - vt) - u[i] + I[i]) / C
154 | u[i+1] = u[i]+tau*a*(b*(v[i]-vr)-u[i]); # Calculate recovery variable
155 |
156 | if v[i+1]>=vPeak:
157 | v[i]=vPeak
158 | v[i+1]=c
159 | u[i+1]=u[i+1]+d # reset u, except for FS cells
160 | return v
161 |
162 | @jit(nopython=True)
163 | def get_2003_vm(I,times,a=0.01, b=15, c=-60, d=10,vr = -70):
164 | u=b*vr
165 | V = vr
166 | tau = dt = 0.25
167 | N = len(I)
168 | vv = np.zeros(N)
169 | UU = np.zeros(N)
170 |
171 | for i in range(N):
172 | V = V + tau*(0.04*V**2+5*V+140-u+I[i]);
173 | u = u + tau*a*(b*V-u);
174 | if V > 30:
175 | vv[i] = 30;
176 | V = c;
177 | u = u + d;
178 | else:
179 | vv[i]=V;
180 | UU[i]=u;
181 | return vv
182 |
183 |
184 | class IZHIModel():
185 |
186 | name = 'IZHI'
187 |
188 | def __init__(self, attrs=None):
189 | self.vM = None
190 | self.attrs = attrs
191 | self.temp_attrs = None
192 | self.default_attrs = {'C':89.7960714285714,
193 | 'a':0.01, 'b':15, 'c':-60, 'd':10, 'k':1.6,
194 | 'vPeak':(86.364525297619-65.2261863636364),
195 | 'vr':-65.2261863636364, 'vt':-50, 'celltype':3}
196 |
197 | if type(attrs) is not type(None):
198 | self.attrs = attrs
199 | if self.attrs is None:
200 | self.attrs = self.default_attrs
201 |
202 |
203 | def get_spike_count(self):
204 | thresh = threshold_detection(self.vM,0*qt.mV)
205 | return len(thresh)
206 |
207 | def set_stop_time(self, stop_time = 650*pq.ms):
208 | """Sets the simulation duration
209 | stopTimeMs: duration in milliseconds
210 | """
211 | self.tstop = float(stop_time.rescale(pq.ms))
212 |
213 |
214 | def get_membrane_potential(self):
215 | """Must return a neo.core.AnalogSignal.
216 | """
217 | if type(self.vM) is not type(None):
218 | return self.vM
219 |
220 |
221 | if type(self.vM) is type(None):
222 |
223 | everything = copy.copy(self.attrs)
224 | if hasattr(self,'Iext'):
225 | everything.update({'Iext':self.Iext})
226 |
227 | if 'current_inj' in everything.keys():
228 | everything.pop('current_inj',None)
229 | everything = copy.copy(self.attrs)
230 |
231 | self.attrs['celltype'] = int(round(self.attrs['celltype']))
232 | assert type(self.attrs['celltype']) is type(int())
233 | if self.attrs['celltype'] <= 3:
234 | everything.pop('celltype',None)
235 | v = get_vm_one_two_three(**everything)
236 | else:
237 | if self.attrs['celltype'] == 4:
238 | v = get_vm_four(**everything)
239 | if self.attrs['celltype'] == 5:
240 | v = get_vm_five(**everything)
241 | if self.attrs['celltype'] == 6:
242 | v = get_vm_six(**everything)
243 | if self.attrs['celltype'] == 7:
244 |
245 |
246 | v = get_vm_seven(**everything)
247 |
248 | self.vM = AnalogSignal(v,
249 | units=pq.mV,
250 | sampling_period=0.25*pq.ms)
251 |
252 |
253 | return self.vM
254 |
255 | def set_attrs(self, attrs):
256 | self.attrs = attrs
257 |
258 |
259 | def wrap_known_i(self,i,times):
260 | everything = self.attrs
261 | if 'current_inj' in everything.keys():
262 | everything.pop('current_inj',None)
263 | if 'celltype' in everything.keys():
264 | everything.pop('celltype',None)
265 | two_thousand_and_three=False
266 | if two_thousand_and_three:
267 | v = AnalogSignal(get_2003_vm(i,times,**reduced),units=pq.mV,sampling_period=0.25*pq.ms)
268 | else:
269 | v = AnalogSignal(get_vm_known_i(i,times,**everything),units=pq.mV,sampling_period=(times[1]-times[0])*pq.ms)
270 | thresh = threshold_detection(v,0*pq.mV)
271 | return v
272 |
273 | @cython.boundscheck(False)
274 | @cython.wraparound(False)
275 | def inject_direct_current(self, I):
276 | """
277 | Inputs: current : a dictionary with exactly three items, whose keys are: 'amplitude', 'delay', 'duration'
278 | Example: current = {'amplitude':float*pq.pA, 'delay':float*pq.ms, 'duration':float*pq.ms}}
279 | where \'pq\' is a physical unit representation, implemented by casting float values to the quanitities \'type\'.
280 | Description: A parameterized means of applying current injection into defined
281 | Currently only single section neuronal models are supported, the neurite section is understood to be simply the soma.
282 |
283 | """
284 |
285 | attrs = self.attrs
286 | if attrs is None:
287 | attrs = self.default_attrs
288 |
289 | self.attrs = attrs
290 | self.attrs['I'] = np.array(I)
291 |
292 | self.attrs['celltype'] = int(round(self.attrs['celltype']))
293 | everything = copy.copy(self.attrs)
294 |
295 | if 'current_inj' in everything.keys():
296 | everything.pop('current_inj',None)
297 |
298 | if np.bool_(self.attrs['celltype'] <= 3):
299 | everything.pop('celltype',None)
300 | v = get_vm_one_two_three(**everything)
301 | else:
302 |
303 |
304 | if np.bool_(self.attrs['celltype'] == 4):
305 | everything.pop('celltype',None)
306 | v = get_vm_four(**everything)
307 | if np.bool_(self.attrs['celltype'] == 5):
308 | everything.pop('celltype',None)
309 | v = get_vm_five(**everything)
310 | if np.bool_(self.attrs['celltype'] == 6):
311 | everything.pop('celltype',None)
312 | if 'I' in self.attrs.keys():
313 | everything.pop('I',None)
314 | v = get_vm_six(self.attrs['I'],**everything)
315 | if np.bool_(self.attrs['celltype'] == 7):
316 | everything.pop('celltype',None)
317 | v = get_vm_seven(**everything)
318 |
319 | if 'I' in self.attrs.keys():
320 | self.attrs.pop('I',None)
321 |
322 | self.vM = AnalogSignal(v,
323 | units=pq.mV,
324 | sampling_period=0.25*pq.ms)
325 |
326 | return self.vM
327 |
328 |
329 | @cython.boundscheck(False)
330 | @cython.wraparound(False)
331 | def inject_square_current(self, current):
332 | """
333 | Inputs: current : a dictionary with exactly three items, whose keys are: 'amplitude', 'delay', 'duration'
334 | Example: current = {'amplitude':float*pq.pA, 'delay':float*pq.ms, 'duration':float*pq.ms}}
335 | where \'pq\' is a physical unit representation, implemented by casting float values to the quanitities \'type\'.
336 | Description: A parameterized means of applying current injection into defined
337 | Currently only single section neuronal models are supported, the neurite section is understood to be simply the soma.
338 |
339 | """
340 |
341 | attrs = self.attrs
342 | if attrs is None:
343 | attrs = self.default_attrs
344 |
345 | self.attrs = attrs
346 | if 'delay' in current.keys() and 'duration' in current.keys():
347 | square = True
348 | c = current
349 | if isinstance(c['amplitude'],type(pq)):
350 | amplitude = float(c['amplitude'].simplified)
351 | print(c['amplitude'],c['amplitude'].simplified)
352 | duration = float(c['duration'])#.simplified)
353 | delay = float(c['delay'])#.simplified)
354 | else:
355 | amplitude = float(c['amplitude'])
356 | duration = float(c['duration'])
357 | delay = float(c['delay'])
358 | #print(amplitude,duration,delay)
359 | tMax = delay + duration #+ 200.0#*pq.ms
360 |
361 | #self.set_stop_time(tMax*pq.ms)
362 | tMax = self.tstop = float(tMax)
363 | N = int(tMax/0.25)
364 | Iext = np.zeros(N)
365 | delay_ind = int((delay/tMax)*N)
366 | duration_ind = int((duration/tMax)*N)
367 |
368 | Iext[0:delay_ind-1] = 0.0
369 | Iext[delay_ind:delay_ind+duration_ind-1] = amplitude
370 | Iext[delay_ind+duration_ind::] = 0.0
371 | #self.Iext = None
372 | #self.Iext = Iext
373 |
374 | self.attrs['I'] = Iext
375 |
376 | everything = copy.copy(self.attrs)
377 | #everything.update({'N':len(Iext)})
378 |
379 | #everything.update({'Iext':Iext})
380 | #everything.update({'start':delay_ind})
381 | #everything.update({'stop':delay_ind+duration_ind})
382 | #everything.update({'amp':amplitude})
383 | if 'celltype' in everything.keys():
384 | everything.pop('celltype',None)
385 |
386 | if 'current_inj' in everything.keys():
387 | everything.pop('current_inj',None)
388 | #import pdb; pdb.set_trace()
389 |
390 | self.attrs['celltype'] = int(round(self.attrs['celltype']))
391 | assert type(self.attrs['celltype']) is type(int())
392 |
393 | if np.bool_(self.attrs['celltype'] <= 3):
394 | everything.pop('celltype',None)
395 | v = get_vm_one_two_three(**everything)
396 | else:
397 |
398 |
399 | if np.bool_(self.attrs['celltype'] == 4):
400 | v = get_vm_four(**everything)
401 | if np.bool_(self.attrs['celltype'] == 5):
402 | v = get_vm_five(**everything)
403 | if np.bool_(self.attrs['celltype'] == 6):
404 | v = get_vm_six(**everything)
405 | if np.bool_(self.attrs['celltype'] == 7):
406 | v = get_vm_seven(**everything)
407 |
408 |
409 | self.attrs
410 |
411 | self.vM = AnalogSignal(v,
412 | units=pq.mV,
413 | sampling_period=0.25*pq.ms)
414 |
415 | return self.vM
416 |
417 | def _backend_run(self):
418 | results = {}
419 | if len(self.attrs) > 1:
420 | v = get_vm(**self.attrs)
421 | else:
422 | v = get_vm(self.attrs)
423 |
424 | self.vM = AnalogSignal(v,
425 | units = voltage_units,
426 | sampling_period = 0.25*pq.ms)
427 | results['vm'] = self.vM.magnitude
428 | results['t'] = self.vM.times
429 | results['run_number'] = results.get('run_number',0) + 1
430 | return results
431 |
--------------------------------------------------------------------------------
/NEURON/izhiGUI.py:
--------------------------------------------------------------------------------
1 | """
2 | izh.py
3 |
4 | Python/NEURON GUI for the different celltypes of Izhikevich neuron (versions from 2 publications).
5 |
6 | * 2003 Izhikevich artificial neuron model from
7 | EM Izhikevich "Simple Model of Spiking Neurons"
8 | IEEE Transactions On Neural Networks, Vol. 14, No. 6, November 2003 pp 1569-1572
9 |
10 | * 2007 Izhikevich artificial neuron model from
11 | EM Izhikevich (2007) "Dynamical systems in neuroscience" MIT Press
12 |
13 | Cell types available from Izhikevich, 2007 book:
14 | 1. RS - Layer 5 regular spiking pyramidal cell (fig 8.12 from 2007 book)
15 | 2. IB - Layer 5 intrinsically bursting cell (fig 8.19 from 2007 book)
16 | 3. CH - Cat primary visual cortex chattering cell (fig8.23 from 2007 book)
17 | 4. LTS - Rat barrel cortex Low-threshold spiking interneuron (fig8.25 from 2007 book)
18 | 5. FS - Rat visual cortex layer 5 fast-spiking interneuron (fig8.27 from 2007 book)
19 | 6. TC - Cat dorsal LGN thalamocortical (TC) cell (fig8.31 from 2007 book)
20 | 7. RTN - Rat reticular thalamic nucleus (RTN) cell (fig8.32 from 2007 book)
21 |
22 | Implementation by: Salvador Dura-Bernal, Cliff Kerr, Bill Lytton
23 | (salvadordura@gmail.com; cliffk@neurosim.downstate.edu; billl@neurosim.downstate.edu)
24 | """
25 |
26 | # adapted from /u/billl/nrniv/sync/izh.hoc
27 | import os, sys, collections
28 | import numpy as np
29 | from neuron import h, gui
30 | h.load_file('stdrun.hoc')
31 | import izhi2007Figs as iz07fig
32 | import izhi2007Wrapper as izh07
33 | import __main__
34 | py = __main__
35 | h.tstop=500
36 | h.cvode_active(0)
37 | h.dt=0.1
38 | izh, cell07 = None, None # must be declared here since needs to be imported elsewhere
39 |
40 |
41 | type2003 = collections.OrderedDict([
42 | # a b c d vviv tstop
43 | ('regular spiking (RS)' , (0.02 , 0.2 , -65.0 , 8.0 , -63.0 , 150.0)) ,
44 | ('intrinsically bursting (IB)' , (0.02 , 0.2 , -55.0 , 4.0 , -70.0 , 150.0)) ,
45 | ('chattering (CH)' , (0.02 , 0.2 , -50.0 , 2.0 , -70.0 , 150.0)) ,
46 | ('fast spiking (FS)' , (0.1 , 0.2 , -65.0 , 2.0 , -70.0 , 150.0)) ,
47 | ('thalamo-cortical (TC)' , (0.02 , 0.25, -65.0 , 0.05 , -63.0 , 150.0)) ,
48 | ('thalamo-cortical burst (TC)' , (0.02 , 0.25, -65.0 , 0.05 , -87.0 , 150.0)) ,
49 | ('resonator (RZ)' , (0.1 , 0.26 , -65.0 , 2.0 , -70.0 , 100.0)) ,
50 | ('low-threshold spiking (LTS)' , (0.02 , 0.25 , -65.0 , 2.0 , -63.0 , 250.0))])
51 |
52 | type2004 = collections.OrderedDict([
53 | # a b c d vviv tstop
54 | ('tonic spiking' , (0.02 , 0.2 , -65.0 , 6.0 , -70.0 , 100.0)) ,
55 | ('mixed mode' , (0.02 , 0.2 , -55.0 , 4.0 , -70.0 , 160.0)) ,
56 | ('spike latency' , (0.02 , 0.2 , -65.0 , 6.0 , -70.0 , 100.0)) ,
57 | ('rebound spike' , (0.03 , 0.25 , -60.0 , 4.0 , -64.0 , 200.0)) ,
58 | ('Depolarizing afterpotential' , (1.0 , 0.2 , -60.0 , -21.0 , -70.0 , 50.0)) ,
59 | ('phasic spiking' , (0.02 , 0.25 , -65.0 , 6.0 , -64.0 , 200.0)) ,
60 | ('spike frequency adaptation' , (0.01 , 0.2 , -65.0 , 8.0 , -70.0 , 85.0)) ,
61 | ('subthreshold oscillations' , (0.05 , 0.26 , -60.0 , 0.0 , -62.0 , 200.0)) ,
62 | ('rebound burst' , (0.03 , 0.25 , -52.0 , 0.0 , -64.0 , 200.0)) ,
63 | ('accomodation' , (0.02 , 1.0 , -55.0 , 4.0 , -65.0 , 400.0)) ,
64 | ('tonic bursting' , (0.02 , 0.2 , -50.0 , 2.0 , -70.0 , 220.0)) ,
65 | ('Class 1' , (0.02 , -0.1 , -55.0 , 6.0 , -60.0 , 300.0)) ,
66 | ('resonator' , (0.1 , 0.26 , -60.0 , -1.0 , -62.0 , 400.0)) ,
67 | ('threshold variability' , (0.03 , 0.25 , -60.0 , 4.0 , -64.0 , 100.0)) ,
68 | ('inhibition-induced spiking' , (-0.02 , -1.0 , -60.0 , 8.0 , -63.8 , 350.0)) ,
69 | ('phasic bursting' , (0.02 , 0.25 , -55.0 , 0.05 , -64.0 , 200.0)) ,
70 | ('Class 2' , (0.2 , 0.26 , -65.0 , 0.0 , -64.0 , 300.0)) ,
71 | ('integrator' , (0.02 , -0.1 , -55.0 , 6.0 , -60.0 , 100.0)) ,
72 | ('bistability' , (0.1 , 0.26 , -60.0 , 0.0 , -61.0 , 300.0)) ,
73 | ('inhibition-induced bursting' , (-0.026 , -1.0 , -45.0 , -2.0 , -63.8 , 350.0))])
74 |
75 | choices = collections.OrderedDict([
76 | ('2003 PP model' , (lambda: h.Izhi2003a(0.5,sec=cell03), lambda: izh._ref_V, type2003)),
77 | ('2003 Sec model', (lambda: h.Izhi2003b(0.5,sec=cell03), lambda: cell03(0.5)._ref_v, type2003)),
78 | ('2004 PP model' , (lambda: h.Izhi2003a(0.5,sec=cell03), lambda: izh._ref_V, type2004)),
79 | ('2004 Sec model', (lambda: h.Izhi2003b(0.5,sec=cell03), lambda: cell03(0.5)._ref_v, type2004)),
80 | ('2007 PP model' , (lambda: izh07.IzhiCell(host=izh07.dummy), lambda: izh._ref_V, izh07.type2007)),
81 | ('2007 Sec model' , (lambda: izh07.IzhiCell(), lambda: cell07.sec(0.5)._ref_v, izh07.type2007))])
82 |
83 | ch=choices.keys()
84 | def newmodel (ty=None) :
85 | "2003,2004 was the orig model; 2007 is the redesign; look at global izhtype if no "
86 | return izhtype.find('2007') > -1 if ty is None else ty.find('2007') > -1
87 |
88 | #* setup the cell
89 | izhtype='2004 PP model'
90 | def cellset ():
91 | global cell07, cell03, izh, vref, uvvset, fih, izhtype
92 | if newmodel():
93 | cell07 = choices[izhtype][0]()
94 | izh = cell07.izh
95 | def uvvset () : pass
96 | else:
97 | cell03 = h.Section(name="cell2003") # this cell will be used for 2003/4; different cell created in izhi2007Wrapper for those
98 | izh = choices[izhtype][0]()
99 | def uvvset () : vref[0], izh.u = vviv, vviv*izh.b
100 | cell03.L, cell03.diam = 6.37, 5 # empirically tuned -- cell size only used for Izh1
101 | fih = [h.FInitializeHandler(uvvset), h.FInitializeHandler(0,Isend)]
102 | vref = choices[izhtype][1]() # can define this afterwards even though used in uvvset above
103 | # h('objref izh'); h.izh = izh # if need to access from hoc
104 |
105 | #* parameters for different cell types
106 | playvec, playtvec = [h.Vector() for x in range(2)]
107 |
108 | # initialization routines
109 | name, params = None, None
110 |
111 | def p (nm, pm=None) :
112 | global name, vviv, params, vvset
113 | if pm is None : pm = choices[izhtype][2][nm]
114 | name, params = nm, pm
115 | if newmodel():
116 | izh.C, izh.k, izh.vr, izh.vt, izh.vpeak, izh.a, izh.b, izh.c, izh.d, izh.celltype = params
117 | h.tstop=1000
118 | else:
119 | izh.a, izh.b, izh.c, izh.d, vviv, h.tstop = params
120 | g.size(0,h.tstop,-100,50)
121 | try:
122 | if newmodel():
123 | graphx() # interviews graphics
124 | iz07fig.recorder(cell07, choices[izhtype][1]()) # vectors to draw under matplotlib
125 | iz07fig.test1(cell07, nm, izhtype)
126 | else:
127 | iz07fig.closeFig()
128 | graphx()
129 | playinit()
130 | h.run()
131 | except: print sys.exc_info()[0],' :',sys.exc_info()[1]
132 |
133 | def ivwrap (func, label=''):
134 | wrapper = h.VBox()
135 | wrapper.intercept(1)
136 | func()
137 | wrapper.intercept(0)
138 | wrapper.map(label)
139 | return wrapper
140 |
141 | def graphx ():
142 | g.erase_all()
143 | g.addvar("v", choices[izhtype][1](), 2,2)
144 | g.addvar("u", izh._ref_u, 3,1)
145 | g.addvar("Iin", izh._ref_Iin if newmodel() else izh._ref_Iin, 4,2)
146 | try: g.addvar("gsyn", izh._ref_gsyn, 1, 1)
147 | except: pass
148 |
149 | I0=I1=T1=0
150 | def playinit () :
151 | global I0,I1,T1
152 | try: izh.f, izh.g= 5, 140 # standard params: V'=0.04*V^2 + 5*V + 140 - u + Iin
153 | except: pass
154 | bub.label[0] = '%s'%(name)
155 | if name=='Depolarizing afterpotential': bub.label[0] = "%s -- REPEATED SPIKING"%(bub.label[0])
156 | if name=='accomodation': bub.label[0] = "%s -- NOT IMPLEMENTED (different functional form;see izh.mod)"%(bub.label[0])
157 | if name=='inhibition-induced bursting': bub.label[0] = "%s -- NOT IMPLEMENTED (convergence problems)"%(bub.label[0])
158 | g.label(0.1,0.9,bub.label[0])
159 | print bub.label[0]
160 | playvec.play_remove()
161 | playtvec.resize(0); playvec.resize(0)
162 | if name=='Class 1' :
163 | T1=30
164 | playtvec.append(0,T1,h.tstop)
165 | playvec.append(0,0,0.075*(h.tstop-T1))
166 | elif name=='Class 2' : # (H) Class 2 exc.
167 | T1=30
168 | playtvec.append(0,T1,h.tstop)
169 | playvec.append(-0.5, -0.5,-0.05+0.015*(h.tstop-T1))
170 | elif name=='accomodation' : # (R) accomodation
171 | playtvec.append(0, 200, 200.001, 300, 312.5, 312.501, h.tstop)
172 | playvec.append( 0, 200/25, 0 , 0 , 4 , 0 , 0)
173 | if name in ['Class 1', 'Class 2', 'accomodation'] : playvec.play(izh._ref_Iin, playtvec, 1)
174 | if name in ['Class 1', 'integrator'] :
175 | try: izh.f, izh.g = 4.1, 108 # don't exist in all the models
176 | except: pass
177 |
178 | def synon () :
179 | "Turn on a synapse"
180 | global ns, nc
181 | ns = h.NetStim()
182 | nc = h.NetCon(ns,izh,0,1,10)
183 | ns.start, ns.interval, ns.number = 10, 10, 10
184 | nc.weight[0] = 2
185 | izh.taug = 3
186 |
187 | #* box of buttons
188 | class Bubox :
189 |
190 | def __init__ (self, type, li) :
191 | self.izhtype = type
192 | vbox, hbox, hbox1 = h.VBox(), h.HBox(), h.HBox()
193 | self.vbox = vbox
194 | lil = len(li)
195 | self.cols, self.rows = {20:(4,5), 8:(4,2), 9:(3,3)}[lil]
196 | self.label=h.ref('================================================================================')
197 | vbox.intercept(1)
198 | h.xpanel("")
199 | h.xvarlabel(self.label)
200 | if newmodel(self.izhtype):
201 | h.xlabel("V' = (k*(V-vr)*(V-vt) - u + Iin)/C if (V>vpeak) V=c [reset]")
202 | h.xlabel("u' = a*(b*(V-vr) - u) if (V>vpeak) u=u+d")
203 | else:
204 | h.xlabel("v' = 0.04*v*v + f*v + g - u + Iin; if (v>thresh) v=c [reset]")
205 | h.xlabel("u' = a*(b*v - u); if (v>thresh) u=u+d")
206 | h.xpanel()
207 | hbox1.intercept(1)
208 | h.xpanel(""); h.xbutton("RUN",h.run); h.xpanel()
209 | self.xvalue('I0','I0')
210 | self.xvalue('I1','I1')
211 | self.xvalue('T1','T1')
212 | hbox1.intercept(0); hbox1.map("")
213 | hbox.intercept(1)
214 | for ii,(k,v) in enumerate(li.iteritems()):
215 | if ii%self.rows==0: h.xpanel("")
216 | h.xbutton(k, (lambda f, arg1, arg2: lambda: f(arg1,arg2))(p, k, v)) # alternative is to use functools.partial
217 | if ii%self.rows==self.rows-1: h.xpanel()
218 | hbox.intercept(0); hbox.map("")
219 | vbox.intercept(0); vbox.map("Spike patterns")
220 | self.label[0]=""
221 |
222 | def pr (): pass
223 |
224 | def xvalue (self,name,var,obj=py,runner=pr):
225 | h.xpanel("")
226 | h.xvalue(name,(obj, var),0,runner)
227 | h.xpanel()
228 |
229 | def xpvalue (self,name,ptr,runner=pr):
230 | "Doesn't work currently"
231 | h.xpanel("")
232 | h.xpvalue(name,ptr,1,runner)
233 | h.xpanel()
234 |
235 | def transpose (self,x) : return int(x/self.rows) + x%self.rows*self.cols
236 | # end class Bubox
237 |
238 | # current injections for specific models
239 | def Isend () :
240 | global T1,I0,I1
241 | if I0!=0 or I1!=0:
242 | Iin = I0
243 | Isend1(T1,I1)
244 | return
245 | T1=h.tstop/10
246 | if not newmodel(): izh.Iin=0
247 | if name=='tonic spiking': # (A) tonic spiking
248 | Isend1(T1,14)
249 | elif name=='phasic spiking': # (B) phasic spiking
250 | T1=20
251 | Isend1(T1,0.5)
252 | elif name=='tonic bursting': # (C) tonic bursting
253 | T1=22
254 | Isend1(T1,15)
255 | elif name=='phasic bursting': # (D) phasic bursting
256 | T1=20
257 | Isend1(T1,0.6)
258 | elif name=='mixed mode': # (E) mixed mode
259 | Isend1(T1,10)
260 | elif name=='spike frequency adaptation': # (F) spike freq. adapt
261 | Isend1(T1,30)
262 | elif name=='Class 1': # (G) Class 1 exc. -- playvec
263 | pass
264 | elif name=='Class 2': # (H) Class 2 exc. -- playvec
265 | pass
266 | elif name=='spike latency': # (izh.Iin) spike latency
267 | Isend1(T1,7.04)
268 | Isend1(T1+3,0.0)
269 | elif name=='subthreshold oscillations': # (J) subthresh. osc.
270 | Isend1(T1,2)
271 | Isend1(T1+5,0)
272 | elif name=='resonator': # (K) resonator
273 | T2, T3 = T1+20, 0.7*h.tstop
274 | T4 = T3+40
275 | Isend1(T1,0.65) ; Isend1(T2,0.65) ; Isend1(T3,0.65) ; Isend1(T4,0.65)
276 | Isend1(T1+4,0.) ; Isend1(T2+4,0.) ; Isend1(T3+4,0.) ; Isend1(T4+4,0.)
277 | elif name=='integrator': # (L) integrator
278 | T1, T3 = h.tstop/11, 0.7*h.tstop
279 | T2, T4 = T1+5, T3+10
280 | Isend1(T1,9) ; Isend1(T2,9) ; Isend1(T3,9) ; Isend1(T4,9)
281 | Isend1(T1+2,0.) ; Isend1(T2+2,0.) ; Isend1(T3+2,0.) ; Isend1(T4+4,0.)
282 | elif name=='rebound spike': # (M) rebound spike
283 | T1=20
284 | Isend1(T1,-15)
285 | Isend1(T1+5,0)
286 | elif name=='rebound burst': # (N) rebound burst
287 | T1=20
288 | Isend1(T1,-15)
289 | Isend1(T1+5,0)
290 | elif name=='threshold variability': # (O) thresh. variability
291 | T1, T2, T3 =10, 70, 80
292 | Isend1(T1,1) ; Isend1(T2,-6) ; Isend1(T3,1)
293 | Isend1(T1+5,0.) ; Isend1(T2+5,0.) ; Isend1(T3+5,0.)
294 | elif name=='bistability': # (P) bistability
295 | T1, T2, izh.Iin = h.tstop/8, 216, 0.24
296 | Isend1(T1,1.24) ; Isend1(T2,1.24)
297 | Isend1(T1+5,0.24); Isend1(T2+5,0.24)
298 | elif name=='Depolarizing afterpotential': # (Q) DAP depolarizing afterpotential
299 | T1 = 10
300 | Isend1(T1-1,20)
301 | Isend1(T1+1,0)
302 | elif name=='accomodation': # (R) accomodation -- playvec
303 | pass
304 | elif name=='inhibition-induced spiking': # (S) inhibition induced spiking
305 | izh.Iin=80
306 | Isend1(50,75)
307 | Isend1(250,80)
308 | elif name=='inhibition-induced bursting': # (T) inhibition induced bursting
309 | izh.Iin=80
310 | Isend1(50,80) # Isend1(50,75) -- will crash simulator
311 | Isend1(250,80)
312 | elif name=='regular spiking (RS)': # regular spiking (RS)
313 | Isend1(T1,14)
314 | elif name=='intrinsically bursting (IB)': # intrinsically bursting (IB)
315 | Isend1(T1,11)
316 | elif name=='chattering (CH)': # chattering (CH)
317 | Isend1(T1,10)
318 | elif name=='fast spiking (FS)': # fast spiking (FS)
319 | Isend1(T1,10)
320 | elif name=='thalamo-cortical (TC)': # thalamo-cortical (TC)
321 | Isend1(2*T1,1.5)
322 | elif name=='thalamo-cortical burst (TC)': # thalamo-cortical burst (TC)
323 | Isend1(0,-25)
324 | Isend1(3*T1,0)
325 | elif name=='resonator (RZ)': # resonator (RZ)
326 | Isend1(0,-2)
327 | Isend1(T1,-0.5)
328 | Isend1(T1+50,10)
329 | Isend1(T1+55,-0.5)
330 | elif name=='low-threshold spiking (LTS)': # low-threshold spiking (LTS)
331 | Isend1(T1,10)
332 | elif name == 'TC_burst': # thalamo-cortical burst (TC) (2007)
333 | Isend1(0,-1200)
334 | Isend1(120,110)
335 | elif name == 'RTN_burst': # reticular thalamic nucleus burst (TC) (2007)
336 | Isend1(0,-350)
337 | Isend1(120,90)
338 |
339 | def Isend1 (tm, Iin) :
340 | def my_event():
341 | izh.Iin = Iin
342 | h.CVode().re_init()
343 | h.cvode.event(tm, my_event)
344 |
345 | # izhstim() sets up a single stim into izh cell
346 | # effect easily seen by running "Class 1"
347 | def izhstim () :
348 | stim=h.NetStim(0.5)
349 | stim.number = stim.start = 1
350 | nc = h.NetCon(stim,izh)
351 | nc.delay = 2
352 | nc.weight = 0.1
353 | izh.erev = -5
354 |
355 | #* plotting & printing
356 | g, nmenu, bub = None, None, None
357 | def isinstanceh (objref,objtype) : return objref.hname().startswith(objtype.hname()[:-2])
358 |
359 | def winup (izht=izhtype):
360 | global bub, g, nmenu, izhtype
361 | izhtype = izht # swap in the new one
362 | cellset()
363 | if g is None:
364 | g=h.Graph(0)
365 | h.graphList[0].append(g)
366 | if g.view_count()<1:
367 | g.view(-0.1*h.tstop,-90,1.2*h.tstop,150,300,200,400,200)
368 | g.size(0,h.tstop,-80,40)
369 | if not bub is None: bub.vbox.unmap()
370 | bub = Bubox(izhtype,choices[izhtype][2])
371 | bub.label[0] = izhtype
372 | if not nmenu is None: nmenu.unmap()
373 | nmenu = ivwrap(lambda: h.nrnpointmenu(izh), izh.hname())
374 |
375 | def chwin ():
376 | "Launch windows from model list"
377 | h.xpanel("Izhikevich models")
378 | # outer lambda returns inner lambda so as to pass arg to winup() -- the innermost routine
379 | for c in ch:
380 | h.xbutton(c, (lambda f, arg1: lambda: f(arg1))(winup,c))
381 | h.xpanel()
382 |
383 | def vtvec(vv): return np.linspace(0, len(vv)*h.dt, len(vv), endpoint=True)
384 |
385 | if __name__ == '__main__': chwin()
386 |
--------------------------------------------------------------------------------
/PyNN/izhikevich2004.py:
--------------------------------------------------------------------------------
1 | """
2 | This script reproduces Fig. 1 of Izhikevich (2004).
3 |
4 | Original implementation references:
5 |
6 | Izhikevich E.M. (2004) Which Model to Use for Cortical Spiking Neurons?
7 | IEEE Transactions on Neural Networks, 15:1063-1070 (special issue on temporal coding)
8 |
9 | Izhikevich E.M. (2003) Simple Model of Spiking Neurons.
10 | IEEE Transactions on Neural Networks, 14:1569- 1572
11 |
12 | http://www.izhikevich.org/publications/whichmod.htm
13 | http://izhikevich.org/publications/figure1.m
14 |
15 | See http://www.opensourcebrain.org/projects/izhikevichmodel/wiki for info on issues with the current implementation.
16 |
17 |
18 | Usage: python izhikevich2004.py
19 |
20 | where is neuron, nest, brian, or another PyNN backend simulator
21 |
22 |
23 | Requirements: PyNN 0.8 and one or more PyNN-supported simulators
24 |
25 |
26 | Units: all times are in milliseconds, voltages in millivolts and currents in nanoamps
27 |
28 |
29 | Version 0.1 - original script written by Vitor Chaud during Google Summer of Code 2013
30 | Version 0.2 - script condensed and updated to use latest development version of PyNN by Andrew Davison, February and September 2014
31 |
32 |
33 | :copyright: Copyright 2013-2014 Vitor Chaud, Andrew Davison and Padraig Gleeson
34 | :license: Modified BSD, see LICENSE for details.
35 | """
36 |
37 | from __future__ import division
38 | import os
39 | import numpy as np
40 | import matplotlib
41 | matplotlib.use('Agg')
42 | import matplotlib.pyplot as plt
43 | import matplotlib.gridspec as gridspec
44 | from pyNN.utility import get_simulator, normalized_filename
45 |
46 |
47 | global_time_step = 0.01
48 |
49 | plt.rcParams.update({
50 | 'lines.linewidth': 0.5,
51 | 'legend.fontsize': 'small',
52 | 'axes.titlesize': 'small',
53 | 'font.size': 6,
54 | 'savefig.dpi': 200,
55 | })
56 |
57 |
58 | def run_simulation(time_step=global_time_step, a=0.02, b=0.2, c=-65.0, d=6.0,
59 | u_init=None, v_init=-70.0, waveform=None, t_stop=100.0,
60 | title="", scalebar_level=0, label_scalebar=False,
61 | save_data=False):
62 | """
63 | Run a simulation of a single neuron.
64 |
65 | Arguments:
66 | time_step - time step used in solving the differential equations
67 | a - time scale of the recovery variable u
68 | b - sensitivity of u to the subthreshold fluctuations of the membrane potential v
69 | c - after-spike reset value of v
70 | d - after-spike reset of u
71 | u_init - initial value of u
72 | v_init - initial value of v
73 | waveform - a tuple of two NumPy arrays, containing time and amplitude data for the injected current
74 | t_stop - duration of the simulation
75 | title - a title to be added to the figure panel for this simulation
76 | scalebar_level - a value between 0 and 1, controlling the vertical placement of the scalebar
77 | label_scalebar - True or False, whether to add a label to the scalebar
78 | """
79 | global j, fig, gs
80 |
81 | # create a neuron and current source
82 |
83 | sim.setup(timestep=time_step)
84 |
85 | if u_init is None:
86 | u_init = b * v_init
87 | initialValues = {'u': u_init, 'v': v_init}
88 |
89 | cell_type = sim.Izhikevich(a=a, b=b, c=c, d=d, i_offset=0.0)
90 | neuron = sim.create(cell_type)
91 | neuron.initialize(**initialValues)
92 |
93 | neuron.record('v')
94 |
95 | times, amps = waveform
96 | injectedCurrent = sim.StepCurrentSource(times=times, amplitudes=amps)
97 | injectedCurrent.inject_into(neuron)
98 |
99 | # run the simulation and retrieve the recorded data
100 |
101 | sim.run(t_stop)
102 | data = neuron.get_data().segments[0]
103 |
104 | # plot the membrane potential and injected current
105 |
106 | gs1 = gridspec.GridSpecFromSubplotSpec(2, 1,
107 | subplot_spec=gs[j//4, j%4],
108 | height_ratios=[8, 1],
109 | hspace=0.0)
110 | ax1 = plt.subplot(gs1[0])
111 | ax2 = plt.subplot(gs1[1])
112 |
113 | j += 1
114 | for ax in (ax1, ax2):
115 | ax.get_xaxis().set_visible(False)
116 | ax.get_yaxis().set_visible(False)
117 | ax.spines['left'].set_color('None')
118 | ax.spines['right'].set_color('None')
119 | ax.spines['bottom'].set_color('None')
120 | ax.spines['top'].set_color('None')
121 | ax.set_xlim(0.0, t_stop)
122 |
123 | ax1.set_title(title)
124 |
125 | vm = data.filter(name='v')[0]
126 | i_times, i_vars = stepify(times, amps)
127 |
128 | ax1.plot(vm.times, vm)
129 | ax1.set_ylim(-90, 30)
130 |
131 | ax2.plot(i_times, i_vars, 'g')
132 | ymin, ymax = amps.min(), amps.max()
133 | padding = (ymax - ymin)/10
134 | ax2.set_ylim(ymin - padding, ymax + padding)
135 |
136 | # scale bar
137 | scalebar_y = ymin + (ymax - ymin) * scalebar_level
138 | ax2.plot([t_stop - 20, t_stop], [scalebar_y, scalebar_y],
139 | color='k', linestyle='-', linewidth=1)
140 | if label_scalebar:
141 | ax.text(t_stop, ymin + padding, "20 ms", fontsize=4, horizontalalignment='right')
142 |
143 | plt.show(block=False)
144 | fig.canvas.draw()
145 |
146 | if save_data:
147 | datfilename = "results/%s_%s.dat" % (title.replace("(","").replace(")","").replace(" ","_"),options.simulator)
148 |
149 | datfile = open(datfilename,'w')
150 | for i in range(len(vm)):
151 | datfile.write('%s\t%s\n'%(vm.times[i].magnitude,vm[i][0].magnitude))
152 | datfile.close()
153 | print(' Saved data to %s'%datfilename)
154 |
155 |
156 | def step(amplitude, t_stop):
157 | """
158 | Generate the waveform for a current that starts at zero and is stepped up
159 | to the given amplitude at time t_stop/10.
160 | """
161 | times = np.array([0, t_stop/10, t_stop])
162 | amps = np.array([0, amplitude, amplitude])
163 | return times, amps
164 |
165 |
166 | def pulse(amplitude, onsets, width, t_stop, baseline=0.0):
167 | """
168 | Generate the waveform for a series of current pulses.
169 |
170 | Arguments:
171 | amplitude - absolute current value during each pulse
172 | onsets - a list or array of times at which pulses begin
173 | width - duration of each pulse
174 | t_stop - total duration of the waveform
175 | baseline - the current value before, between and after pulses.
176 | """
177 | times = [0]
178 | amps = [baseline]
179 | for onset in onsets:
180 | times += [onset, onset + width]
181 | amps += [amplitude, baseline]
182 | times += [t_stop]
183 | amps += [baseline]
184 | return np.array(times), np.array(amps)
185 |
186 |
187 | def ramp(gradient, onset, t_stop, baseline=0.0, time_step=global_time_step, t_start=0.0):
188 | """
189 | Generate the waveform for a current which is initially constant
190 | and then increases linearly with time.
191 |
192 | Arguments:
193 | gradient - gradient of the ramp
194 | onset - time at which the ramp begins
195 | t_stop - total duration of the waveform
196 | baseline - current value before the ramp
197 | time_step - interval between increments in the ramp current
198 | t_start - time at which the waveform begins (used to construct waveforms
199 | containing multiple ramps).
200 | """
201 | if onset > t_start:
202 | times = np.hstack((np.array((t_start, onset)), # flat part
203 | np.arange(onset + time_step, t_stop + time_step, time_step))) # ramp part
204 | else:
205 | times = np.arange(t_start, t_stop + time_step, time_step)
206 | amps = baseline + gradient*(times - onset) * (times > onset)
207 | return times, amps
208 |
209 |
210 | def stepify(times, values):
211 | """
212 | Generate an explicitly-stepped version of a time series.
213 | """
214 | new_times = np.empty((2*times.size - 1,))
215 | new_values = np.empty_like(new_times)
216 | new_times[::2] = times
217 | new_times[1::2] = times[1:]
218 | new_values[::2] = values
219 | new_values[1::2] = values[:-1]
220 | return new_times, new_values
221 |
222 |
223 | # == Get command-line options, import simulator backend =====================
224 |
225 | sim, options = get_simulator()
226 |
227 | # == Initialize figure ======================================================
228 |
229 | j = 0
230 | plt.ion()
231 | fig = plt.figure(1, facecolor='white', figsize=(6, 6))
232 | gs = gridspec.GridSpec(5, 4)
233 | gs.update(hspace=0.5, wspace=0.4)
234 |
235 | # == Sub-plot A: Tonic spiking ==============================================
236 |
237 | t_stop = 100.0
238 | run_simulation(a=0.02, b=0.2, c=-65.0, d=6.0, v_init=-70.0,
239 | waveform=step(0.014, t_stop),
240 | t_stop=t_stop, title='(A) Tonic spiking',
241 | label_scalebar=True, save_data=True)
242 |
243 | # == Sub-plot B: Phasic spiking =============================================
244 |
245 | t_stop = 200.0
246 | run_simulation(a=0.02, b=0.25, c=-65.0, d=6.0, v_init=-64.0,
247 | waveform=step(0.0005, t_stop),
248 | t_stop=t_stop, title='(B) Phasic spiking')
249 |
250 | # == Sub-plot C: Tonic bursting =============================================
251 |
252 | _stop = 220.0
253 | run_simulation(a=0.02, b=0.2, c=-50.0, d=2.0, v_init=-70.0,
254 | waveform=step(0.015, t_stop),
255 | t_stop=t_stop, title='(C) Tonic bursting', save_data=True)
256 |
257 | # == Sub-plot D: Phasic bursting ============================================
258 |
259 | t_stop = 200.0
260 | run_simulation(a=0.02, b=0.25, c=-55.0, d=0.05, v_init=-64.0,
261 | waveform=step(0.0006, t_stop),
262 | t_stop=t_stop, title='(D) Phasic bursting')
263 |
264 | # == Sub-plot E: Mixed mode =================================================
265 |
266 | t_stop = 160.0
267 | run_simulation(a=0.02, b=0.2, c=-55.0, d=4.0, v_init=-70.0,
268 | waveform=step(0.01, t_stop),
269 | t_stop=t_stop, title='(E) Mixed mode')
270 |
271 | # == Sub-plot F: Spike Frequency Adaptation (SFA) ===========================
272 |
273 | t_stop = 85.0
274 | run_simulation(a=0.01, b=0.2, c=-65.0, d=8.0, v_init=-70.0,
275 | waveform=step(0.03, t_stop),
276 | t_stop=t_stop, title='(F) SFA')
277 |
278 | # == Sub-plot G: Class 1 excitable ==========================================
279 |
280 | '''
281 | Note: This simulation is supposed to use a different parameterization of the
282 | model, i.e.
283 | V' = tau*(0.04*V^2 + 4.1*V + 108 -u + I)
284 | as opposed to
285 | V' = tau*(0.04*V^2 + 5*V + 140 - u + I)
286 | The alternative parameterization is not currently available in PyNN, therefore
287 | the results of this simulation are not expected to match the original figure.
288 | '''
289 |
290 | t_stop = 300.0
291 | run_simulation(a=0.02, b=0.2, c=-65.0, d=6.0, v_init=-70.0,
292 | waveform=ramp(0.000075, 30.0, t_stop),
293 | t_stop=t_stop, title='(G) Class 1 excitable')
294 |
295 | # == Sub-plot H: Class 2 excitable ==========================================
296 |
297 | t_stop = 300.0
298 | run_simulation(a=0.2, b=0.26, c=-65.0, d=0.0, v_init=-64.0,
299 | waveform=ramp(0.000015, 30.0, t_stop, baseline=-0.0005),
300 | t_stop=t_stop, title='(H) Class 2 excitable')
301 |
302 | # == Sub-plot I: Spike latency ==============================================
303 |
304 | t_stop = 100.0
305 | run_simulation(a=0.02, b=0.2, c=-65.0, d=6.0, v_init=-70.0,
306 | waveform=pulse(0.00671, # 0.00704 in original
307 | [10], 3, t_stop),
308 | t_stop=t_stop, title='(I) Spike latency',
309 | scalebar_level=0.5)
310 |
311 | # == Sub-plot J: Subthreshold oscillation ===================================
312 |
313 | t_stop = 200.0
314 | run_simulation(a=0.05, b=0.26, c=-60.0, d=0.0, v_init=-62.0,
315 | waveform=pulse(0.002, [20], 5, t_stop),
316 | t_stop=t_stop, title='(J) Subthreshold oscillation',
317 | scalebar_level=0.5)
318 |
319 | # == Sub-plot K: Resonator ==================================================
320 |
321 | t_stop = 400.0
322 | T1 = t_stop / 10
323 | T2 = T1 + 20
324 | T3 = 0.7 * t_stop
325 | T4 = T3 + 40
326 | run_simulation(a=0.1, b=0.26, c=-60.0, d=-1.0, v_init=-62.0,
327 | waveform=pulse(0.00065, [T1, T2, T3, T4], 4, t_stop),
328 | t_stop=t_stop, title='(K) Resonator',
329 | scalebar_level=0.5)
330 |
331 | # == Sub-plot L: Integrator =================================================
332 |
333 | '''
334 | Note: This simulation is supposed to use a different parameterization of the
335 | model, i.e.
336 | V' = tau*(0.04*V^2 + 4.1*V + 108 -u + I)
337 | as opposed to
338 | V' = tau*(0.04*V^2 + 5*V + 140 - u + I)
339 | The alternative parameterization is not currently available in PyNN, therefore
340 | the results of this simulation are not expected to match the original figure.
341 | '''
342 |
343 | t_stop = 100.0
344 | T1 = t_stop / 11
345 | T2 = T1 + 5
346 | T3 = 0.7 * t_stop
347 | T4 = T3 + 10
348 | run_simulation(a=0.02, b=-0.1, c=-55.0, d=6.0, v_init=-60.0,
349 | waveform=pulse(0.009, [T1, T2, T3, T4], 2, t_stop),
350 | t_stop=t_stop, title='(L) Integrator',
351 | scalebar_level=0.5)
352 |
353 | # == Sub-plot M: Rebound spike ==============================================
354 |
355 | t_stop = 200.0
356 | run_simulation(a=0.03, b=0.25, c=-60.0, d=4.0, v_init=-64.0,
357 | waveform=pulse(-0.015, [20], 5, t_stop),
358 | t_stop=t_stop, title='(M) Rebound spike')
359 |
360 | # == Sub-plot N: Rebound burst ==============================================
361 |
362 | t_stop = 200.0
363 | run_simulation(a=0.03, b=0.25, c=-52.0, d=0.0, v_init=-64.0,
364 | waveform=pulse(-0.015, [20], 5, t_stop),
365 | t_stop=t_stop, title='(N) Rebound burst')
366 |
367 | # == Sub-plot O: Threshold variability ======================================
368 |
369 | t_stop = 100.0
370 | times = np.array([0, 10, 15, 70, 75, 80, 85, t_stop])
371 | amps = np.array([0, 0.001, 0, -0.006, 0, 0.001, 0, 0])
372 | run_simulation(a=0.03, b=0.25, c=-60.0, d=4.0, v_init=-64.0,
373 | waveform=(times, amps),
374 | t_stop=t_stop, title='(O) Threshold variability')
375 |
376 | # == Sub-plot P: Bistability ================================================
377 |
378 | t_stop = 300.0
379 | T1 = t_stop/8
380 | T2 = 208 # 216.0 in original
381 | run_simulation(a=0.1, b=0.26, c=-60.0, d=0.0, v_init=-61.0,
382 | waveform=pulse(0.00124, [T1, T2], 5, t_stop, baseline=0.00024),
383 | t_stop=t_stop, title='(P) Bistability',
384 | scalebar_level=0.5)
385 |
386 | # == Sub-plot Q: Depolarizing after-potential ===============================
387 |
388 | t_stop = 50.0
389 | run_simulation(a=1.0, b=0.18, # 0.2 in original
390 | c=-60.0, d=-21.0, v_init=-70.0,
391 | waveform=pulse(0.02, [9], 2, t_stop),
392 | t_stop=t_stop, title='(Q) DAP',
393 | scalebar_level=0.5)
394 |
395 | # == Sub-plot R: Accomodation ===============================================
396 |
397 | '''
398 | Note: This simulation is supposed to use a different parameterization of the
399 | model, i.e.
400 | u' = tau*a*(b*(V + 65))
401 | as opposed to
402 | u' = tau*a*(b*V - u)
403 | The alternative parameterization is not currently available in PyNN, therefore
404 | the results of this simulation are not expected to match the original figure.
405 | '''
406 |
407 | t_stop = 400.0
408 |
409 | parts = (ramp(0.00004, 0.0, 200.0),
410 | (np.array([200.0 + global_time_step, 300.0 - global_time_step]), np.array([0.0, 0.0])),
411 | ramp(0.00032, 300.0, 312.5, t_start=300.0),
412 | (np.array([312.5 + global_time_step, t_stop]), np.array([0.0, 0.0])))
413 | totalTimes, totalAmps = np.hstack(parts)
414 |
415 | run_simulation(a=0.02, b=1.0, c=-55.0, d=4.0, v_init=-65.0, u_init=-16.0,
416 | waveform=(totalTimes, totalAmps),
417 | t_stop=t_stop, title='(R) Accomodation',
418 | scalebar_level=0.5)
419 |
420 | # == Sub-plot S: Inhibition-induced spiking =================================
421 |
422 | t_stop = 350.0
423 | run_simulation(a=-0.02, b=-1.0, c=-60.0, d=8.0, v_init=-63.8,
424 | waveform=pulse(0.075, [50], 170, # 200 in original
425 | t_stop, baseline=0.08),
426 | t_stop=t_stop, title='(S) Inhibition-induced spiking')
427 |
428 | # == Sub-plot T: Inhibition-induced bursting ================================
429 |
430 | '''
431 | Modifying parameter d from -2.0 to -0.7 in order to reproduce Fig. 1
432 | '''
433 |
434 | t_stop = 350.0
435 | run_simulation(a=-0.026, b=-1.0, c=-45.0, d=-0.7, v_init=-63.8,
436 | waveform=pulse(0.075, [50], 200, t_stop, baseline=0.08),
437 | t_stop=t_stop, title='(T) Inhibition-induced bursting')
438 |
439 |
440 | # == Export figure in PNG format ============================================
441 |
442 | filename = normalized_filename("results", "izhikevich2004", "png", options.simulator)
443 | try:
444 | os.makedirs(os.path.dirname(filename))
445 | except OSError:
446 | pass
447 | fig.savefig(filename)
448 |
449 | print("\n Simulation complete. Results can be seen in figure at %s\n"%(filename))
450 |
451 |
--------------------------------------------------------------------------------