Browse Source

copied from https://github.com/wachtlerlab/HB-PAC_disinhibitory_network.git, v1.0

Ajayrama Kumaraswamy 1 year ago
parent
commit
cb00b8d48b
43 changed files with 3316 additions and 0 deletions
  1. 74 0
      Ai2017Sim.yml
  2. 242 0
      DLInt1SynCurrent.py
  3. 81 0
      DLInt2try.py
  4. 254 0
      JODLInt1DLInt2.py
  5. 99 0
      LICENSE-CCBY
  6. 73 0
      Readme.md
  7. 0 0
      __init__.py
  8. BIN
      __pycache__/JODLInt1DLInt2.cpython-35.pyc
  9. BIN
      __pycache__/brianUtils.cpython-35.pyc
  10. BIN
      __pycache__/dirDefs.cpython-35.pyc
  11. BIN
      __pycache__/mplPars.cpython-35.pyc
  12. BIN
      __pycache__/neoNIXIO.cpython-35.pyc
  13. 31 0
      brianUtils.py
  14. 7 0
      butest.py
  15. 3 0
      dirDefs.py
  16. 150 0
      forAi2017.py
  17. 130 0
      justDLInt1.py
  18. 0 0
      models/__init__.py
  19. BIN
      models/__init__.pyc
  20. BIN
      models/__pycache__/__init__.cpython-35.pyc
  21. BIN
      models/__pycache__/__init__.cpython-36.pyc
  22. BIN
      models/__pycache__/neuronModels.cpython-35.pyc
  23. BIN
      models/__pycache__/neuronModels.cpython-36.pyc
  24. BIN
      models/__pycache__/neurons.cpython-35.pyc
  25. BIN
      models/__pycache__/synapses.cpython-35.pyc
  26. 247 0
      models/neuronModels.py
  27. 20 0
      models/neurons.py
  28. 22 0
      models/synapses.py
  29. 29 0
      mplPars.py
  30. 316 0
      neoNIXIO.py
  31. 309 0
      paramLists/AdExpPars.py
  32. BIN
      paramLists/__pycache__/AdExpPars.cpython-35.pyc
  33. BIN
      paramLists/__pycache__/inputParsList.cpython-35.pyc
  34. BIN
      paramLists/__pycache__/synapsePropsList.cpython-35.pyc
  35. 79 0
      paramLists/inputParsList.py
  36. 31 0
      paramLists/synapsePropsList.py
  37. 182 0
      plotDLInt1DLInt2SynEffect.py
  38. 125 0
      plotMemVs.py
  39. 126 0
      plotShortStims.py
  40. 203 0
      plotSynCurrents.py
  41. 78 0
      runJODLInt1DLInt2Multiple.py
  42. 16 0
      setup.py
  43. 389 0
      simSynCurrents.py

+ 74 - 0
Ai2017Sim.yml

@@ -0,0 +1,74 @@
1
+name: Ai2017Sim
2
+channels:
3
+- brian-team
4
+- defaults
5
+dependencies:
6
+- brian2=2.0.1=np111py35_0
7
+- py-cpuinfo=0.2.3=py35_1
8
+- cycler=0.10.0=py35_0
9
+- cython=0.25.2=py35_0
10
+- dbus=1.10.10=0
11
+- decorator=4.0.11=py35_0
12
+- expat=2.1.0=0
13
+- fontconfig=2.12.1=3
14
+- freetype=2.5.5=2
15
+- glib=2.50.2=1
16
+- gst-plugins-base=1.8.0=0
17
+- gstreamer=1.8.0=0
18
+- icu=54.1=0
19
+- ipython=5.3.0=py35_0
20
+- ipython_genutils=0.2.0=py35_0
21
+- jinja2=2.9.6=py35_0
22
+- jpeg=9b=0
23
+- libffi=3.2.1=1
24
+- libgcc=5.2.0=0
25
+- libgfortran=3.0.0=1
26
+- libiconv=1.14=0
27
+- libpng=1.6.27=0
28
+- libxcb=1.12=1
29
+- libxml2=2.9.4=0
30
+- markupsafe=0.23=py35_2
31
+- matplotlib=2.0.0=np111py35_0
32
+- mkl=2017.0.1=0
33
+- mpmath=0.19=py35_1
34
+- numpy=1.11.3=py35_0
35
+- openssl=1.0.2k=1
36
+- pandas=0.19.2=np111py35_1
37
+- path.py=10.1=py35_0
38
+- pcre=8.39=1
39
+- pexpect=4.2.1=py35_0
40
+- pickleshare=0.7.4=py35_0
41
+- pip=9.0.1=py35_1
42
+- prompt_toolkit=1.0.14=py35_0
43
+- ptyprocess=0.5.1=py35_0
44
+- pygments=2.2.0=py35_0
45
+- pyparsing=2.1.4=py35_0
46
+- pyqt=5.6.0=py35_2
47
+- python=3.5.0=1
48
+- python-dateutil=2.6.0=py35_0
49
+- pytz=2017.2=py35_0
50
+- qt=5.6.2=3
51
+- readline=6.2=2
52
+- scipy=0.19.0=np111py35_0
53
+- seaborn=0.7.1=py35_0
54
+- setuptools=27.2.0=py35_0
55
+- simplegeneric=0.8.1=py35_1
56
+- sip=4.18=py35_0
57
+- six=1.10.0=py35_0
58
+- sqlite=3.13.0=0
59
+- sympy=1.0=py35_0
60
+- tk=8.5.18=0
61
+- traitlets=4.3.2=py35_0
62
+- wcwidth=0.1.7=py35_0
63
+- wheel=0.29.0=py35_0
64
+- xz=5.0.5=1
65
+- zlib=1.2.8=3
66
+- pip:
67
+  - h5py==2.7.0
68
+  - ipython-genutils==0.2.0
69
+  - neo==0.5.0
70
+  - nixio==1.3.0
71
+  - prompt-toolkit==1.0.14
72
+  - quantities==0+unknown
73
+prefix: /home/ajay/Installations/anaconda3/envs/Ai2017Sim
74
+

+ 242 - 0
DLInt1SynCurrent.py

@@ -0,0 +1,242 @@
1
+import os
2
+import sys
3
+
4
+import seaborn as sns
5
+from brian2 import defaultclock, units, StateMonitor
6
+from matplotlib import pyplot as plt
7
+from brian2.core.network import Network
8
+from dirDefs import homeFolder
9
+from models.neuronModels import VSNeuron, JOSpikes265, getSineInput
10
+from models.neurons import AdExp
11
+from models.synapses import exp2Syn, exp2SynStateInits
12
+from mplPars import mplPars
13
+from paramLists import synapsePropsList, inputParsList, AdExpPars
14
+
15
+from neo import AnalogSignal
16
+import nixio
17
+from neoNIXIO import addAnalogSignal2Block, addMultiTag
18
+import quantities as qu
19
+from brianUtils import addBrianQuantity2Section
20
+
21
+
22
+sns.set(style="whitegrid", rc=mplPars)
23
+
24
+
25
+simSettleTime = 600 * units.ms
26
+
27
+simStepSize = 0.1 * units.ms
28
+simDuration = 150 * units.ms
29
+# inputParsName = 'onePulse'
30
+# inputParsName = 'twoPulse'
31
+# inputParsName = 'threePulse'
32
+inputParsName = "fortyMSPulse"
33
+showBefore = 300 * units.ms
34
+showAfter = 50 * units.ms
35
+
36
+# simStepSize = 0.1 * units.ms
37
+# simDuration = 1500 * units.ms
38
+# # inputParsName = 'oneSecondPulse'
39
+# # inputParsName = 'pulseTrainInt20Dur10'
40
+# inputParsName = 'pulseTrainInt20Dur16'
41
+# # inputParsName = 'pulseTrainInt33Dur10'
42
+# # inputParsName = 'pulseTrainInt33Dur16'
43
+# showBefore = 500 * units.ms
44
+# showAfter = 500 * units.ms
45
+
46
+DLInt1ModelProps = "DLInt1Aynur"
47
+DLInt1PropsDict = getattr(AdExpPars, DLInt1ModelProps)
48
+dlint1 = VSNeuron(**AdExp, inits=DLInt1PropsDict, name='dlint1')
49
+dlint1.recordMembraneV()
50
+dlint1.recordSpikes()
51
+
52
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
53
+# DLInt1SynapsePropsE = ""
54
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
55
+# DLInt1SynapsePropsI = ""
56
+DLInt1SynapseProps = "-".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
57
+
58
+
59
+opDir = os.path.join(homeFolder, DLInt1ModelProps, DLInt1SynapseProps, inputParsName)
60
+
61
+
62
+opFile = os.path.join(opDir, 'SynCurrentTraces.png')
63
+OPNixFile = os.path.join(opDir, 'simResWithSynCurrents.h5')
64
+if os.path.isfile(opFile):
65
+    ch = input('Results already exist at {}. Delete?(y/n):'.format(opFile))
66
+    if ch == 'y':
67
+        os.remove(opFile)
68
+        if os.path.isfile(OPNixFile):
69
+            os.remove(OPNixFile)
70
+    else:
71
+        sys.exit('User Abort!')
72
+
73
+elif not os.path.isdir(opDir):
74
+    os.makedirs(opDir)
75
+
76
+inputPars = getattr(inputParsList, inputParsName)
77
+
78
+JO = JOSpikes265(nOutputs=1, simSettleTime=simSettleTime, **inputPars)
79
+
80
+
81
+if DLInt1SynapsePropsE:
82
+    synPropsE = getattr(synapsePropsList, DLInt1SynapsePropsE)
83
+    dlint1.addSynapse(synName="ExiJO", sourceNG=JO.JOSGG, **exp2Syn,
84
+                      synParsInits=synPropsE,
85
+                      synStateInits=exp2SynStateInits,
86
+                      sourceInd=0, destInd=0
87
+                      )
88
+
89
+if DLInt1SynapsePropsI:
90
+    synPropsI = getattr(synapsePropsList, DLInt1SynapsePropsI)
91
+    dlint1.addSynapse(synName="InhJO", sourceNG=JO.JOSGG, **exp2Syn,
92
+                      synParsInits=synPropsI,
93
+                      synStateInits=exp2SynStateInits,
94
+                      sourceInd=0, destInd=0
95
+                      )
96
+
97
+net = Network()
98
+net.add(JO.JOSGG)
99
+dlint1.addToNetwork(net)
100
+
101
+if DLInt1SynapsePropsE:
102
+    gEMonitor = StateMonitor(dlint1.incomingSynapses["ExiJO"], "g_ExiJO", record=True)
103
+    net.add(gEMonitor)
104
+
105
+if DLInt1SynapsePropsI:
106
+    gIMonitor = StateMonitor(dlint1.incomingSynapses["InhJO"], "g_InhJO", record=True)
107
+    net.add(gIMonitor)
108
+
109
+
110
+defaultclock.dt = simStepSize
111
+totalSimDur = simDuration + simSettleTime
112
+net.run(totalSimDur, report='text')
113
+
114
+simT, memV = dlint1.getMemVTrace()
115
+spikeTimes = dlint1.getSpikes()
116
+
117
+dlint1MemVAS = AnalogSignal(signal=memV / units.mV,
118
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
119
+                                t_start=0 * qu.mV,
120
+                                units="mV",
121
+                                name="DLInt1 MemV")
122
+
123
+
124
+dlint1SpikesQU = (spikeTimes / units.ms) * qu.ms
125
+
126
+joSpikesQU = (JO.spikeTimes / units.ms) * qu.ms
127
+
128
+sineInput = getSineInput(simDur=simDuration, simStepSize=simStepSize,
129
+                         sinPulseDurs=inputPars['sinPulseDurs'],
130
+                         sinPulseStarts=inputPars['sinPulseStarts'],
131
+                         freq=265 * units.Hz, simSettleTime=simSettleTime)
132
+
133
+inputAS = AnalogSignal(signal=sineInput,
134
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
135
+                                t_start=0 * qu.mV,
136
+                                units="um",
137
+                                name="Input Vibration Signal")
138
+
139
+fig, axs = plt.subplots(nrows=3, figsize=(10, 6.25), sharex='col')
140
+axs[0].plot(simT / units.ms, memV / units.mV)
141
+axs[0].set_ylabel('DLInt1\nMembrane\nPotential\n(mV)')
142
+spikesY = memV.min() + 1.05 * (memV.max() - memV.min())
143
+axs[0].plot(spikeTimes / units.ms, [spikesY / units.mV] * spikeTimes.shape[0], 'k^')
144
+axs[0].set_xlim([(simSettleTime - showBefore) / units.ms,
145
+                     (totalSimDur + showAfter) / units.ms])
146
+if DLInt1SynapsePropsE:
147
+    gSynE = gEMonitor.g_ExiJO[0]
148
+    iSynE = -gSynE * (memV - synPropsE['Esyn'])
149
+    axs[1].plot(simT / units.ms,
150
+                iSynE / units.nA, 'r-', label=r'$I_{synE}$')
151
+    iSynEAS = AnalogSignal(signal=iSynE / units.nA,
152
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
153
+                                t_start=0 * qu.mV,
154
+                                units="nA",
155
+                                name="DL-Int-1 input EPSC")
156
+
157
+if DLInt1SynapsePropsI:
158
+    gSynI = gIMonitor.g_InhJO[0]
159
+    iSynI = -gSynI * (memV - synPropsI['Esyn'])
160
+    axs[1].plot(simT / units.ms,
161
+                iSynI / units.nA, 'g-', label=r'$I_{synI}$')
162
+    iSynIAS = AnalogSignal(signal=iSynI / units.nA,
163
+                           sampling_period=(simStepSize / units.ms) * qu.ms,
164
+                           t_start=0 * qu.mV,
165
+                           units="nA",
166
+                           name="DL-Int-1 input IPSC")
167
+
168
+axs[1].legend(loc='center right')
169
+axs[1].set_ylabel("Synaptic\ncurrents\n(nA)")
170
+
171
+axs[2].plot(simT / units.ms, sineInput,
172
+            color=[130. / 255, 72. / 255, 7. / 255], ls='-', marker='None',
173
+            label='Vibration Input')
174
+axs[2].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
175
+        label='JO Spikes')
176
+axs[2].legend(loc='upper right')
177
+axs[2].set_xlabel('time (ms)')
178
+axs[2].set_ylabel('Input')
179
+
180
+fig.tight_layout()
181
+fig.canvas.draw()
182
+fig.savefig(opFile, dpi=150)
183
+
184
+nixFile = nixio.File.open(OPNixFile, mode=nixio.FileMode.ReadWrite)
185
+neuronModels = nixFile.create_section("Neuron Models", "Model Parameters")
186
+
187
+DLInt1PropsSec = neuronModels.create_section("DL-Int-1", "AdExp")
188
+
189
+for propName, propVal in DLInt1PropsDict.items():
190
+    addBrianQuantity2Section(DLInt1PropsSec, propName, propVal)
191
+
192
+inputSec = nixFile.create_section("Input Parameters", "Sinusoidal Pulses")
193
+
194
+for parName, parVal in inputPars.items():
195
+    addBrianQuantity2Section(inputSec, parName, parVal)
196
+
197
+addBrianQuantity2Section(inputSec, "simSettleTime", simSettleTime)
198
+
199
+brianSimSettingsSec = nixFile.create_section("Simulation Parameters", "Brian Simulation")
200
+addBrianQuantity2Section(brianSimSettingsSec, "simStepSize", simStepSize)
201
+addBrianQuantity2Section(brianSimSettingsSec, "totalSimDuration", totalSimDur)
202
+brianSimSettingsSec.create_property("method", nixio.Value("euler"))
203
+
204
+
205
+synPropsSec = nixFile.create_section("Synapse Models", "Model Parameters")
206
+
207
+if DLInt1SynapsePropsE:
208
+
209
+    JODLInt1SynESec = synPropsSec.create_section("JODLInt1Exi", "DoubleExpSyn")
210
+    JODLInt1SynEDict = getattr(synapsePropsList, DLInt1SynapsePropsE)
211
+
212
+    for propName, propVal in JODLInt1SynEDict.items():
213
+        addBrianQuantity2Section(JODLInt1SynESec, propName, propVal)
214
+
215
+    JODLInt1SynESec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
216
+    JODLInt1SynESec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
217
+
218
+
219
+if DLInt1SynapsePropsI:
220
+
221
+    JODLInt1SynISec = synPropsSec.create_section("JODLInt1Inh", "DoubleExpSyn")
222
+    JODLInt1SynIDict = getattr(synapsePropsList, DLInt1SynapsePropsI)
223
+
224
+    for propName, propVal in JODLInt1SynIDict.items():
225
+        addBrianQuantity2Section(JODLInt1SynISec, propName, propVal)
226
+    JODLInt1SynISec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
227
+    JODLInt1SynISec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
228
+
229
+blk = nixFile.create_block("Simulation Traces", "Brian Output")
230
+DLInt1DA = addAnalogSignal2Block(blk, dlint1MemVAS)
231
+inputDA = addAnalogSignal2Block(blk, inputAS)
232
+if DLInt1SynapsePropsE:
233
+    epscAS = addAnalogSignal2Block(blk, iSynEAS)
234
+if DLInt1SynapsePropsI:
235
+    ipscAS = addAnalogSignal2Block(blk, iSynIAS)
236
+
237
+addMultiTag("DLInt1 Spikes", type="Spikes", positions=dlint1SpikesQU,
238
+            blk=blk, refs=[DLInt1DA])
239
+addMultiTag("JO Spikes", type="Spikes", positions=joSpikesQU,
240
+            blk=blk, refs=[inputDA])
241
+
242
+nixFile.close()

+ 81 - 0
DLInt2try.py

@@ -0,0 +1,81 @@
1
+import os
2
+import shutil
3
+
4
+import seaborn as sns
5
+from brian2 import defaultclock, units
6
+from brian2.core.network import Network
7
+from matplotlib import pyplot as plt
8
+
9
+from dirDefs import homeFolder
10
+from models.neuronModels import VSNeuron, JOSpikes265, getSineInput
11
+from mplPars import mplPars
12
+from paramLists import synapsePropsList, inputParsList
13
+
14
+sns.set(style="whitegrid", rc=mplPars)
15
+
16
+
17
+simSettleTime = 500 * units.ms
18
+
19
+simStepSize = 0.5 * units.ms
20
+simDuration = 100 * units.ms
21
+# inputParsName = 'onePulse'
22
+# inputParsName = 'twoPulse'
23
+inputParsName = 'threePulse'
24
+
25
+
26
+# simStepSize = 0.5 * units.ms
27
+# simDuration = 1100 * units.ms
28
+# # inputParsName = 'oneSecondPulse'
29
+# # inputParsName = 'pulseTrainInt20Dur10'
30
+# inputParsName = 'pulseTrainInt20Dur16'
31
+# # inputParsName = 'pulseTrainInt33Dur10'
32
+# # inputParsName = 'pulseTrainInt33Dur16'
33
+
34
+NeuronProps = "DLInt2Try2"
35
+NeuronSynapseProps = 'DLInt2_syn_try2'
36
+dlint2 = VSNeuron(NeuronProps)
37
+
38
+opDir = os.path.join(homeFolder, NeuronProps, NeuronSynapseProps, inputParsName)
39
+if os.path.isdir(opDir):
40
+    ch = input('Results already exist at {}. Delete?(y/n):'.format(opDir))
41
+    if ch == 'y':
42
+        shutil.rmtree(opDir)
43
+os.makedirs(opDir)
44
+
45
+period265 = (1 / 265)
46
+inputPars = getattr(inputParsList, inputParsName)
47
+JO = JOSpikes265(nOutputs=1, simSettleTime=simSettleTime, **inputPars)
48
+dlint2.addExp2Synapses(name='JO', nSyn=1, sourceNG=JO.JOSGG,
49
+                       sourceInd=0,
50
+                       **getattr(synapsePropsList, NeuronSynapseProps))
51
+net = Network()
52
+net.add(JO.JOSGG)
53
+dlint2.addToNetwork(net)
54
+defaultclock.dt = simStepSize
55
+totalSimDur = simDuration + simSettleTime
56
+net.run(totalSimDur, report='text')
57
+
58
+simT, memV = dlint2.getMemVTrace()
59
+spikeTimes = dlint2.getSpikes()
60
+fig, axs = plt.subplots(nrows=2, figsize=(10, 6.25), sharex='col')
61
+axs[0].plot(simT / units.ms, memV / units.mV)
62
+spikesY = memV.min() + 1.05 * (memV.max() - memV.min())
63
+axs[0].plot(spikeTimes / units.ms, [spikesY / units.mV] * spikeTimes.shape[0], 'k^')
64
+axs[0].set_ylabel('DLInt1 \nmemV (mV)')
65
+axs[0].set_xlim([simSettleTime / units.ms - 50, totalSimDur / units.ms + 50])
66
+
67
+sineInput = getSineInput(simSettleTime=simSettleTime, simDur=simDuration,
68
+                         simStepSize=simStepSize,
69
+                         sinPulseDurs=inputPars['sinPulseDurs'],
70
+                         sinPulseStarts=inputPars['sinPulseStarts'],
71
+                         freq=265 * units.Hz)
72
+axs[1].plot(simT / units.ms, sineInput, 'r-', label='Vibration Input')
73
+axs[1].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
74
+        label='JO Spikes')
75
+axs[1].legend(loc='upper right')
76
+axs[1].set_xlabel('time (ms)')
77
+axs[1].set_ylabel('Vibration \nInput/JO\n Spikes')
78
+fig.tight_layout()
79
+fig.canvas.draw()
80
+# plt.show()
81
+fig.savefig(os.path.join(opDir, 'Traces.png'), dpi=150)

+ 254 - 0
JODLInt1DLInt2.py

@@ -0,0 +1,254 @@
1
+import os
2
+import sys
3
+
4
+import seaborn as sns
5
+from brian2 import defaultclock, units
6
+from brian2.core.network import Network
7
+from brian2.units.fundamentalunits import Quantity
8
+from matplotlib import pyplot as plt
9
+
10
+from dirDefs import homeFolder
11
+from models.neuronModels import VSNeuron, JOSpikes265, getSineInput
12
+from mplPars import mplPars
13
+from paramLists import synapsePropsList, inputParsList, AdExpPars
14
+from models.synapses import exp2SynStateInits, exp2Syn
15
+from models.neurons import AdExp
16
+
17
+from neo import AnalogSignal, SpikeTrain
18
+import nixio
19
+from neoNIXIO import addAnalogSignal2Block, addMultiTag
20
+import quantities as qu
21
+from brianUtils import addBrianQuantity2Section
22
+
23
+
24
+def runJODLInt1DLInt2(simStepSize: Quantity, simDuration: Quantity, simSettleTime: Quantity,
25
+                      inputParsName: str, showBefore: Quantity, showAfter: Quantity,
26
+                      DLInt1ModelProps: str, DLInt2ModelProps: str,
27
+                      DLInt1SynapsePropsE: str, DLInt1SynapsePropsI: str,
28
+                      DLInt2SynapseProps: str, DLInt1DLInt2SynProps: str,
29
+                      askReplace=True):
30
+
31
+    sns.set(style="whitegrid", rc=mplPars)
32
+
33
+    DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
34
+
35
+    opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
36
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
37
+                         inputParsName)
38
+    opFile = os.path.join(opDir, 'Traces.png')
39
+    OPNixFile = os.path.join(opDir, 'SimResults.h5')
40
+
41
+    if askReplace:
42
+        if os.path.isfile(opFile):
43
+            ch = input('Results already exist at {}. Delete?(y/n):'.format(opFile))
44
+            if ch == 'y':
45
+                os.remove(opFile)
46
+                if os.path.isfile(OPNixFile):
47
+                    os.remove(OPNixFile)
48
+            else:
49
+                sys.exit('User Abort!')
50
+
51
+        elif not os.path.isdir(opDir):
52
+            os.makedirs(opDir)
53
+    else:
54
+        if os.path.isfile(opFile):
55
+            os.remove(opFile)
56
+            if os.path.isfile(OPNixFile):
57
+                os.remove(OPNixFile)
58
+
59
+        elif not os.path.isdir(opDir):
60
+            os.makedirs(opDir)
61
+
62
+    inputPars = getattr(inputParsList, inputParsName)
63
+
64
+
65
+    net = Network()
66
+    JO = JOSpikes265(nOutputs=1, simSettleTime=simSettleTime, **inputPars)
67
+    net.add(JO.JOSGG)
68
+
69
+    DLInt1PropsDict = getattr(AdExpPars, DLInt1ModelProps)
70
+    dlint1 = VSNeuron(**AdExp, inits=DLInt1PropsDict, name='dlint1')
71
+    dlint1.recordSpikes()
72
+    dlint1.recordMembraneV()
73
+
74
+    if DLInt1SynapsePropsE:
75
+        dlint1.addSynapse(synName="ExiJO", sourceNG=JO.JOSGG, **exp2Syn,
76
+                              synParsInits=getattr(synapsePropsList, DLInt1SynapsePropsE),
77
+                              synStateInits=exp2SynStateInits,
78
+                              sourceInd=0, destInd=0
79
+                              )
80
+    if DLInt1SynapsePropsI:
81
+        dlint1.addSynapse(synName="InhJO", sourceNG=JO.JOSGG, **exp2Syn,
82
+                              synParsInits=getattr(synapsePropsList, DLInt1SynapsePropsI),
83
+                              synStateInits=exp2SynStateInits,
84
+                              sourceInd=0, destInd=0
85
+                              )
86
+
87
+    dlint1.addToNetwork(net)
88
+
89
+    DLInt2PropsDict = getattr(AdExpPars, DLInt2ModelProps)
90
+    dlint2 = VSNeuron(**AdExp, inits=DLInt2PropsDict, name='dlint2')
91
+    dlint2.recordMembraneV()
92
+    dlint2.recordSpikes()
93
+
94
+    if DLInt2SynapseProps:
95
+        dlint2.addSynapse(synName="JOExi", sourceNG=JO.JOSGG, **exp2Syn,
96
+                              synParsInits=getattr(synapsePropsList, DLInt2SynapseProps),
97
+                              synStateInits=exp2SynStateInits,
98
+                              sourceInd=0, destInd=0
99
+                              )
100
+
101
+    if DLInt1DLInt2SynProps:
102
+        dlint2.addSynapse(synName="DLInt1", sourceNG=dlint1.ng, **exp2Syn,
103
+                              synParsInits=getattr(synapsePropsList, DLInt1DLInt2SynProps),
104
+                              synStateInits=exp2SynStateInits,
105
+                              sourceInd=0, destInd=0
106
+                              )
107
+
108
+
109
+    dlint2.addToNetwork(net)
110
+    defaultclock.dt = simStepSize
111
+    totalSimDur = simDuration + simSettleTime
112
+    net.run(totalSimDur, report='text')
113
+
114
+    simT, DLInt1_memV = dlint1.getMemVTrace()
115
+    DLInt1_spikeTimes = dlint1.getSpikes()
116
+    fig, axs = plt.subplots(nrows=3, figsize=(10, 6.25), sharex='col')
117
+    axs[0].plot(simT / units.ms, DLInt1_memV / units.mV)
118
+    spikesY = DLInt1_memV.min() + 1.05 * (DLInt1_memV.max() - DLInt1_memV.min())
119
+    axs[0].plot(DLInt1_spikeTimes / units.ms, [spikesY / units.mV] * DLInt1_spikeTimes.shape[0], 'k^')
120
+    axs[0].set_ylabel('DLInt1 \nmemV (mV)')
121
+    axs[0].set_xlim([(simSettleTime - showBefore) / units.ms,
122
+                     (totalSimDur + showAfter) / units.ms])
123
+
124
+    simT, DLInt2_memV = dlint2.getMemVTrace()
125
+    DLInt2_spikeTimes = dlint2.getSpikes()
126
+    axs[1].plot(simT / units.ms, DLInt2_memV / units.mV)
127
+    spikesY = DLInt2_memV.min() + 1.05 * (DLInt2_memV.max() - DLInt2_memV.min())
128
+    axs[1].plot(DLInt2_spikeTimes / units.ms, [spikesY / units.mV] * DLInt2_spikeTimes.shape[0], 'k^')
129
+    axs[1].set_ylabel('DLInt2 \nmemV (mV)')
130
+
131
+    sineInput = getSineInput(simDur=simDuration, simStepSize=simStepSize,
132
+                             sinPulseDurs=inputPars['sinPulseDurs'],
133
+                             sinPulseStarts=inputPars['sinPulseStarts'],
134
+                             freq=265 * units.Hz, simSettleTime=simSettleTime)
135
+    axs[2].plot(simT / units.ms, sineInput, 'r-', label='Vibration Input')
136
+    axs[2].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
137
+            label='JO Spikes')
138
+    axs[2].legend(loc='upper right')
139
+    axs[2].set_xlabel('time (ms)')
140
+    axs[2].set_ylabel('Vibration \nInput/JO\n Spikes')
141
+    fig.tight_layout()
142
+    fig.canvas.draw()
143
+    fig.savefig(opFile, dpi=150)
144
+    plt.close(fig.number)
145
+    del fig
146
+
147
+    dlint1MemVAS = AnalogSignal(signal=DLInt1_memV /units.mV,
148
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
149
+                                t_start=0 * qu.mV,
150
+                                units="mV",
151
+                                name="DLInt1 MemV")
152
+    dlint2MemVAS = AnalogSignal(signal=DLInt2_memV / units.mV,
153
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
154
+                                t_start=0 * qu.mV,
155
+                                units="mV",
156
+                                name="DLInt2 MemV")
157
+    inputAS = AnalogSignal(signal=sineInput,
158
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
159
+                                t_start=0 * qu.mV,
160
+                                units="um",
161
+                                name="Input Vibration Signal")
162
+    dlint1SpikesQU = (DLInt1_spikeTimes / units.ms) * qu.ms
163
+    dlint2SpikesQU = (DLInt2_spikeTimes / units.ms) * qu.ms
164
+    joSpikesQU = (JO.spikeTimes / units.ms) * qu.ms
165
+
166
+    nixFile = nixio.File.open(OPNixFile, mode=nixio.FileMode.ReadWrite)
167
+
168
+    neuronModels = nixFile.create_section("Neuron Models", "Model Parameters")
169
+
170
+
171
+    DLInt1PropsSec = neuronModels.create_section("DL-Int-1", "AdExp")
172
+
173
+    for propName, propVal in DLInt1PropsDict.items():
174
+        addBrianQuantity2Section(DLInt1PropsSec, propName, propVal)
175
+
176
+    DLInt2PropsSec = neuronModels.create_section("DL-Int-2", "AdExp")
177
+
178
+    for propName, propVal in DLInt2PropsDict.items():
179
+        addBrianQuantity2Section(DLInt2PropsSec, propName, propVal)
180
+
181
+    inputSec = nixFile.create_section("Input Parameters", "Sinusoidal Pulses")
182
+
183
+    for parName, parVal in inputPars.items():
184
+        addBrianQuantity2Section(inputSec, parName, parVal)
185
+
186
+    addBrianQuantity2Section(inputSec, "simSettleTime", simSettleTime)
187
+
188
+    brianSimSettingsSec = nixFile.create_section("Simulation Parameters", "Brian Simulation")
189
+    addBrianQuantity2Section(brianSimSettingsSec, "simStepSize", simStepSize)
190
+    addBrianQuantity2Section(brianSimSettingsSec, "totalSimDuration", totalSimDur)
191
+    brianSimSettingsSec.create_property("method", nixio.Value("euler"))
192
+
193
+
194
+    synPropsSec = nixFile.create_section("Synapse Models", "Model Parameters")
195
+
196
+    if DLInt1SynapsePropsE:
197
+
198
+        JODLInt1SynESec = synPropsSec.create_section("JODLInt1Exi", "DoubleExpSyn")
199
+        JODLInt1SynEDict = getattr(synapsePropsList, DLInt1SynapsePropsE)
200
+
201
+        for propName, propVal in JODLInt1SynEDict.items():
202
+            addBrianQuantity2Section(JODLInt1SynESec, propName, propVal)
203
+
204
+        JODLInt1SynESec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
205
+        JODLInt1SynESec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
206
+
207
+
208
+    if DLInt1SynapsePropsI:
209
+
210
+        JODLInt1SynISec = synPropsSec.create_section("JODLInt1Inh", "DoubleExpSyn")
211
+        JODLInt1SynIDict = getattr(synapsePropsList, DLInt1SynapsePropsI)
212
+
213
+        for propName, propVal in JODLInt1SynIDict.items():
214
+            addBrianQuantity2Section(JODLInt1SynISec, propName, propVal)
215
+        JODLInt1SynISec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
216
+        JODLInt1SynISec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
217
+
218
+    if DLInt2SynapseProps:
219
+
220
+        JODLInt2SynESec = synPropsSec.create_section("JODLInt2Exi", "DoubleExpSyn")
221
+        JODLInt2SynEDict = getattr(synapsePropsList, DLInt2SynapseProps)
222
+
223
+        for propName, propVal in JODLInt2SynEDict.items():
224
+            addBrianQuantity2Section(JODLInt2SynESec, propName, propVal)
225
+        JODLInt2SynESec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
226
+        JODLInt2SynESec.create_property("PostSynaptic Neuron", nixio.Value("DLInt2"))
227
+
228
+    if DLInt1DLInt2SynProps:
229
+
230
+        DLInt1DLInt2SynSec = synPropsSec.create_section("DLInt1DLInt2Inh", "DoubleExpSyn")
231
+        DLInt1DLInt2SynDict = getattr(synapsePropsList, DLInt1DLInt2SynProps)
232
+
233
+        for propName, propVal in DLInt1DLInt2SynDict.items():
234
+            addBrianQuantity2Section(DLInt1DLInt2SynSec, propName, propVal)
235
+        DLInt1DLInt2SynSec.create_property("PreSynaptic Neuron", nixio.Value("DLInt1"))
236
+        DLInt1DLInt2SynSec.create_property("PostSynaptic Neuron", nixio.Value("DLInt2"))
237
+
238
+
239
+    blk = nixFile.create_block("Simulation Traces", "Brian Output")
240
+    DLInt1DA = addAnalogSignal2Block(blk, dlint1MemVAS)
241
+    DLInt2DA = addAnalogSignal2Block(blk, dlint2MemVAS)
242
+    inputDA = addAnalogSignal2Block(blk, inputAS)
243
+    addMultiTag("DLInt1 Spikes", type="Spikes", positions=dlint1SpikesQU,
244
+                blk=blk, refs=[DLInt1DA])
245
+    addMultiTag("DLInt2 Spikes", type="Spikes", positions=dlint2SpikesQU,
246
+                blk=blk, refs=[DLInt2DA])
247
+    addMultiTag("JO Spikes", type="Spikes", positions=joSpikesQU,
248
+                blk=blk, refs=[inputDA])
249
+
250
+
251
+    nixFile.close()
252
+
253
+
254
+

+ 99 - 0
LICENSE-CCBY

@@ -0,0 +1,99 @@
1
+Creative Commons Attribution 4.0 International Public License
2
+
3
+By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
4
+
5
+Section 1 – Definitions.
6
+
7
+    Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
8
+    Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
9
+    Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
10
+    Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
11
+    Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
12
+    Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
13
+    Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
14
+    Licensor means the individual(s) or entity(ies) granting rights under this Public License.
15
+    Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
16
+    Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
17
+    You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
18
+
19
+Section 2 – Scope.
20
+
21
+    License grant.
22
+        Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
23
+            reproduce and Share the Licensed Material, in whole or in part; and
24
+            produce, reproduce, and Share Adapted Material.
25
+        Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
26
+        Term. The term of this Public License is specified in Section 6(a).
27
+        Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
28
+        Downstream recipients.
29
+            Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
30
+            No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
31
+        No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
32
+
33
+    Other rights.
34
+        Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
35
+        Patent and trademark rights are not licensed under this Public License.
36
+        To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
37
+
38
+Section 3 – License Conditions.
39
+
40
+Your exercise of the Licensed Rights is expressly made subject to the following conditions.
41
+
42
+    Attribution.
43
+
44
+        If You Share the Licensed Material (including in modified form), You must:
45
+            retain the following if it is supplied by the Licensor with the Licensed Material:
46
+                identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
47
+                a copyright notice;
48
+                a notice that refers to this Public License;
49
+                a notice that refers to the disclaimer of warranties;
50
+                a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
51
+            indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
52
+            indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
53
+        You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
54
+        If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
55
+        If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
56
+
57
+Section 4 – Sui Generis Database Rights.
58
+
59
+Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
60
+
61
+    for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
62
+    if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
63
+    You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
64
+
65
+For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
66
+
67
+Section 5 – Disclaimer of Warranties and Limitation of Liability.
68
+
69
+    Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
70
+    To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
71
+
72
+    The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
73
+
74
+Section 6 – Term and Termination.
75
+
76
+    This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
77
+
78
+    Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
79
+        automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
80
+        upon express reinstatement by the Licensor.
81
+    For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
82
+    For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
83
+    Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
84
+
85
+Section 7 – Other Terms and Conditions.
86
+
87
+    The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
88
+    Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
89
+
90
+Section 8 – Interpretation.
91
+
92
+    For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
93
+    To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
94
+    No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
95
+    Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
96
+
97
+Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
98
+
99
+Creative Commons may be contacted at creativecommons.org.

+ 73 - 0
Readme.md

@@ -0,0 +1,73 @@
1
+This repository contains the code used for the following manuscript:
2
+
3
+
4
+Kumaraswamy, A., Maksutov, A., Kai, K., Ai, H., Ikeno, H., & Wachtler, T. (2017). Network simulations of interneuron circuits in the honeybee primary auditory center. *bioRxiv*. https://doi.org/10.1101/159533
5
+
6
+Authors:
7
+Ajayrama Kumaraswamy, ajkumaraswamy@tutamail.com
8
+Based on and contains parts of work by Aynur Maksutov during AMGEN program 2016 at Wachtlerlab, LMU.
9
+
10
+Installation:
11
+
12
+With anaconda (recommended):
13
+
14
+    1. conda create --name Ai2017Sim -c brian-team ipython>=6.1 numpy>=1.11.2 matplotlib>=1.5.3 seaborn>=0.7.1 brian2>=2.0.1 python>=3.5
15
+    2. source activate Ai2017Sim (unix) or activate Ai2017Sim (windows)
16
+    3. pip install <full path of this repository>
17
+
18
+without anaconda, normal python installation required (https://www.python.org/)
19
+
20
+    1. Install virtualenvwrapper (unix) or virtualenvwrapper-win (windows) be pre-installed with pip
21
+    2. (only on windows) Install microsoft Visual C++ 14.0. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
22
+    3. mkvirtualenv Ai2017Sim
23
+    4. pip install <full path of this repository>
24
+
25
+Usage:
26
+    1. source activate Ai2017Sim (unix) or activate Ai2017Sim (windows)
27
+    2. Change the variable homeFolder in dirDefs.py to a folder. The results of the simulation will be stored here.
28
+    3. The scripts of this repo are described below. All of them have some parameters at their top. Change these and run the scripts as needed.
29
+
30
+
31
+Here is an overview of the contents:
32
+
33
+.  
34
++-- Ai2017Sim.yml: A file that can be used to create a conda environment to run the scripts below. Essentially is a list of dependencies.
35
++-- models
36
+|   +-- neuronModels.py: wrapper classes for brian2 neuron models
37
+|   +-- neurons.py: Model equations and static parameters for neurons  
38
+|   +-- synapses.py: Model equations for synapses  
39
+|  
40
++-- paramLists  
41
+|   +-- AdExpPars.py: Parameter combinations for the AdExp model  
42
+|   +-- inputParsList.py: Stimulii definitions  
43
+|   +-- synapsePropsList.py: Parameter combinations for the difference of exponential synaptic conductance model  
44
+|  
45
++-- brianUtils.py: utility function related to brian2  
46
+|  
47
++-- dirDefs.py: directory definitions imported in other scripts  
48
+|  
49
++-- DLInt1SynCurrent.py: Script to simulate DL-Int-1 recording membrane potential and synaptic currents in [NIX](https://github.com/G-Node/nixpy) files  
50
+|  
51
++-- DLInt2try.py: Legacy code  
52
+|  
53
++-- forAi2017.py: Script to generate a subplot of an upcoming manuscript.  
54
+|  
55
++-- JODLInt1DLInt2: Class to run network simulations  
56
+|  
57
++-- justDLInt1.py: Legacy code  
58
+|  
59
++-- mplPars.py: matplotlib rc parameters  
60
+|  
61
++-- neoNIXIO.py: adapted from GJEMS, utility functions to work jointly with [NIX](https://github.com/G-Node/nixpy) and [neo](https://github.com/NeuralEnsemble/python-neo).  
62
+|  
63
++-- plotDLInt1DLInt2SynEffects.py: script to plot summary of DL-Int-1 and DL-Int-2 responses to pulse trains.  
64
+|  
65
++-- plotShortStims.py: script to plot summary of DL-Int-1 and DL-Int-2 responses to short continuous pulses.  
66
+|  
67
++-- plotSynCurrents.py: script to plot membrane potential and synaptic currents of DL-Int-1 and DL-Int-2 for one stimulus.  
68
+|  
69
++-- runJODLInt1DLInt2Multiple.py: script to simulate the network for multiple stimulii. Out is saved as a [NIX](https://github.com/G-Node/nixpy) File.  
70
+|  
71
++-- simSynCurrents.py: script to simulate DL-Int-1 and DL-Int-2 recording membrane potential and synaptics currents in a [NIX](https://github.com/G-Node/nixpy) file.  
72
+
73
+

+ 0 - 0
__init__.py


BIN
__pycache__/JODLInt1DLInt2.cpython-35.pyc


BIN
__pycache__/brianUtils.cpython-35.pyc


BIN
__pycache__/dirDefs.cpython-35.pyc


BIN
__pycache__/mplPars.cpython-35.pyc


BIN
__pycache__/neoNIXIO.cpython-35.pyc


+ 31 - 0
brianUtils.py

@@ -0,0 +1,31 @@
1
+import numpy as np
2
+from brian2.units.fundamentalunits import Quantity
3
+import nixio
4
+
5
+def getSimT(simDur: Quantity, simStepSize: Quantity) -> Quantity:
6
+
7
+    return np.arange(simDur / simStepSize) * simStepSize
8
+
9
+def addBrianQuantity2Section(sec: nixio.pycore.Section,
10
+                             name: str, qu: Quantity) -> nixio.pycore.Property:
11
+    propStr = qu.in_best_unit()
12
+
13
+    if qu.shape == ():
14
+
15
+        propFloatStr, propUnit = propStr.split(" ")
16
+        propFloat = float(propFloatStr)
17
+
18
+        pr = sec.create_property(name, [nixio.Value(propFloat)])
19
+
20
+    elif len(qu.shape) == 1:
21
+
22
+        propFloatStr, propUnit = propStr.split("] ")
23
+        values = list(map(float, propFloatStr[2:].split()))
24
+        pr = sec.create_property(name, [nixio.Value(val) for val in values])
25
+
26
+    else:
27
+        raise(ValueError("Only scalar or 1D Brian Quantities as supported"))
28
+
29
+    pr.unit = propUnit
30
+
31
+    return pr

+ 7 - 0
butest.py

@@ -0,0 +1,7 @@
1
+import nixio
2
+from brian2 import units
3
+from brianUtils import addBrianQuantity2Section
4
+
5
+nf = nixio.File.open("/tmp/1.h5", nixio.FileMode.ReadWrite)
6
+sec = nf.create_section("test", "Test")
7
+addBrianQuantity2Section(sec, "Test", [1] * units.ms)

+ 3 - 0
dirDefs.py

@@ -0,0 +1,3 @@
1
+import os
2
+homeFolder = os.path.join('/media', 'ajay', 'ADATA_HD720', 'Ginjang',
3
+                          'DataAndResults', 'ephys', 'Ai2017Sim')

+ 150 - 0
forAi2017.py

@@ -0,0 +1,150 @@
1
+import nixio
2
+from dirDefs import homeFolder
3
+import os
4
+import seaborn as sns
5
+from mplPars import mplPars
6
+from brian2 import units
7
+from matplotlib import pyplot as plt
8
+from neoNIXIO import multiTag2SpikeTrain, dataArray2AnalogSignal, \
9
+    simpleFloat, property2qu
10
+import quantities as qu
11
+from neo import AnalogSignal
12
+
13
+mplPars['xtick.labelsize'] = 10
14
+mplPars['ytick.labelsize'] = 10
15
+mplPars["text.usetex"] = False
16
+mplPars["font.sans-serif"] = "Arial"
17
+mplPars["axes.linewidth"] = 1
18
+sns.set(style="ticks", rc=mplPars)
19
+
20
+
21
+simSettleTime = 600 * units.ms
22
+
23
+# simStepSize = 0.1 * units.ms
24
+# simDuration = 150 * units.ms
25
+# # inputParsName = 'onePulse'
26
+# # inputParsName = 'twoPulse'
27
+# # inputParsName = 'threePulse'
28
+# inputParsName = "fortyMSPulse"
29
+# showBefore = 50 * units.ms
30
+# showAfter = 50 * units.ms
31
+
32
+simStepSize = 0.1 * units.ms
33
+simDuration = 450 * units.ms
34
+inputParsName = "pTShortInt33Dur16"
35
+# inputParsName = "pTShortInt100Dur16"
36
+
37
+showBefore = 75 * units.ms
38
+showAfter = -30 * units.ms
39
+
40
+# simStepSize = 0.1 * units.ms
41
+# simDuration = 1500 * units.ms
42
+# # inputParsName = 'oneSecondPulse'
43
+# # inputParsName = 'pulseTrainInt20Dur10'
44
+# inputParsName = 'pulseTrainInt20Dur16'
45
+# # inputParsName = 'pulseTrainInt33Dur10'
46
+# # inputParsName = 'pulseTrainInt33Dur16'
47
+# showBefore = 500 * units.ms
48
+# showAfter = 500 * units.ms
49
+
50
+DLInt1ModelProps = "DLInt1Aynur"
51
+
52
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
53
+# DLInt1SynapsePropsE = ""
54
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
55
+# DLInt1SynapsePropsI = ""
56
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
57
+
58
+DLInt2ModelProps = "DLInt2Try2"
59
+
60
+DLInt2SynapseProps = 'DLInt2_syn_try2'
61
+
62
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
63
+
64
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
65
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
66
+                         inputParsName)
67
+OPNixFile = os.path.join(opDir, 'simResults.h5')
68
+
69
+
70
+totalSimDur = simDuration + simSettleTime
71
+
72
+nixFile = nixio.File.open(OPNixFile, nixio.FileMode.ReadOnly)
73
+
74
+inputSec = nixFile.sections["Input Parameters"]
75
+simSettleTimeQu = property2qu(inputSec.props["simSettleTime"])
76
+
77
+blk = nixFile.blocks["Simulation Traces"]
78
+dlint1MemV = blk.data_arrays["DLInt1 MemV"]
79
+dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
80
+dlint2MemV = blk.data_arrays["DLInt2 MemV"]
81
+dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
82
+sinInput = blk.data_arrays["Input Vibration Signal"]
83
+joSpikesMT = blk.multi_tags["JO Spikes"]
84
+
85
+dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
86
+dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
87
+temp = dataArray2AnalogSignal(sinInput)
88
+sinInputAS = AnalogSignal(signal=15 * temp.magnitude,
89
+                          units=temp.units,
90
+                          t_start=temp.t_start,
91
+                          sampling_period=temp.sampling_period)
92
+sinInputAS = sinInputAS.reshape((sinInputAS.shape[0],))
93
+dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
94
+dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
95
+joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
96
+
97
+# fig0, ax0 = plt.subplots(figsize=(2.5, 1.5))
98
+# fig1, ax1 = plt.subplots(figsize=(2.5, 1.5))
99
+# fig2, ax2 = plt.subplots(figsize=(2.5, 1.75))
100
+#
101
+fig0, ax0 = plt.subplots(figsize=(2.85, 1.5))
102
+fig1, ax1 = plt.subplots(figsize=(2.85, 1.5))
103
+fig2, ax2 = plt.subplots(figsize=(2.85, 1.75))
104
+
105
+ax0.plot(simpleFloat((dlint1MemVAS.times - simSettleTimeQu) / qu.ms),
106
+         simpleFloat(dlint1MemVAS / qu.mV), 'k-', lw=0.4)
107
+ax1.plot(simpleFloat((dlint2MemVAS.times - simSettleTimeQu) / qu.ms),
108
+         simpleFloat(dlint2MemVAS / qu.mV), 'k-', lw=0.4)
109
+ax2.plot(simpleFloat((sinInputAS.times - simSettleTimeQu) / qu.ms),
110
+         simpleFloat(sinInputAS / qu.um), 'k-', lw=0.4)
111
+
112
+for ax in [ax0, ax1, ax2]:
113
+    ax.set_xlim([(-showBefore) / units.ms,
114
+                     (simDuration + showAfter) / units.ms])
115
+    # ax.yaxis.tick_right()
116
+    ax.set_xticks([])
117
+    ax.set_ylim([-50, 5])
118
+    ax.set_yticks([-40, -20, 0])
119
+    # ax.set_yticks([])
120
+
121
+
122
+for ax in [ax0, ax1]:
123
+    markerline, stemlines, baseline \
124
+        = ax.stem(simpleFloat((joSpikesST.times - simSettleTimeQu) / qu.ms),
125
+                      [-42] * joSpikesST.shape[0],
126
+                      linefmt='k-', markerfmt='None', basefmt='None',
127
+                      bottom=-50)
128
+    plt.setp(stemlines, lw=0.4)
129
+
130
+
131
+markerline, stemlines, baseline \
132
+        = ax2.stem(simpleFloat((joSpikesST.times - simSettleTimeQu) / qu.ms),
133
+                      [25] * joSpikesST.shape[0],
134
+                      linefmt='k-', markerfmt='None', basefmt='None',
135
+                      bottom=17)
136
+plt.setp(stemlines, lw=0.5)
137
+ax2.set_ylim([-20, 25])
138
+ax2.set_xticks([0, 100, 200, 300])
139
+
140
+for fig in [fig0, fig1, fig2]:
141
+
142
+    fig.tight_layout()
143
+
144
+fig0.savefig(os.path.join(opDir, "DL-Int-1MemV.svg"), dpi=300,
145
+             bbox_inches='tight', transparent=True)
146
+fig1.savefig(os.path.join(opDir, "DL-Int-2MemV.svg"), dpi=300,
147
+             bbox_inches='tight', transparent=True)
148
+fig2.savefig(os.path.join(opDir, "InputSignal.svg"), dpi=300,
149
+             bbox_inches='tight', transparent=True)
150
+

+ 130 - 0
justDLInt1.py

@@ -0,0 +1,130 @@
1
+import os
2
+import sys
3
+
4
+import seaborn as sns
5
+from brian2 import defaultclock, units
6
+from matplotlib import pyplot as plt
7
+from brian2.core.network import Network
8
+from dirDefs import homeFolder
9
+from models.neuronModels import VSNeuron, JOSpikes265, getSineInput
10
+from models.neurons import AdExp
11
+from models.synapses import exp2Syn, exp2SynStateInits
12
+from mplPars import mplPars
13
+from paramLists import synapsePropsList, inputParsList, AdExpPars
14
+
15
+sns.set(style="whitegrid", rc=mplPars)
16
+
17
+
18
+simSettleTime = 600 * units.ms
19
+
20
+# simStepSize = 0.1 * units.ms
21
+# simDuration = 150 * units.ms
22
+# # inputParsName = 'onePulse'
23
+# # inputParsName = 'twoPulse'
24
+# # inputParsName = 'threePulse'
25
+# # inputParsName = "tenMSPulse"
26
+# # inputParsName = "twentyMSPulse"
27
+# # inputParsName = "thirtyMSPulse"
28
+# inputParsName = "fortyMSPulse"
29
+# # inputParsName = "fiftyMSPulse"
30
+# showBefore = 50 * units.ms
31
+# showAfter = 10 * units.ms
32
+
33
+
34
+simStepSize = 0.1 * units.ms
35
+simDuration = 1500 * units.ms
36
+# inputParsName = 'pulseTrainInt20Dur10'
37
+# inputParsName = 'pulseTrainInt20Dur16'
38
+# inputParsName = 'pulseTrainInt33Dur16'
39
+# inputParsName = 'pulseTrainInt33Dur10'
40
+# inputParsName = 'oneSecondPulse'
41
+# inputParsName = 'pulseTrainInt50Dur10'
42
+inputParsName = 'pulseTrainInt50Dur16'
43
+# inputParsName = 'pulseTrainInt50Dur20'
44
+showBefore = 500 * units.ms
45
+showAfter = 500 * units.ms
46
+
47
+DLInt1ModelProps = "DLInt1Aynur"
48
+dlint1 = VSNeuron(**AdExp, inits=getattr(AdExpPars, DLInt1ModelProps), name='dlint1')
49
+dlint1.recordMembraneV()
50
+dlint1.recordSpikes()
51
+
52
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
53
+# DLInt1SynapsePropsE = ""
54
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
55
+# DLInt1SynapsePropsI = ""
56
+DLInt1SynapseProps = "-".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
57
+
58
+
59
+# opDir = os.path.join(homeFolder, DLInt1ModelProps, DLInt1SynapseProps, inputParsName)
60
+opDir = "/tmp/justDLInt1"
61
+
62
+opFile = os.path.join(opDir, 'Traces.png')
63
+if os.path.isfile(opFile):
64
+    ch = input('Results already exist at {}. Delete?(y/n):'.format(opFile))
65
+    if ch == 'y':
66
+        os.remove(opFile)
67
+    else:
68
+        sys.exit('User Abort!')
69
+
70
+elif not os.path.isdir(opDir):
71
+    os.makedirs(opDir)
72
+
73
+inputPars = getattr(inputParsList, inputParsName)
74
+
75
+JO = JOSpikes265(nOutputs=1, simSettleTime=simSettleTime, **inputPars)
76
+
77
+
78
+if DLInt1SynapsePropsE:
79
+    dlint1.addSynapse(synName="ExiJO", sourceNG=JO.JOSGG, **exp2Syn,
80
+                      synParsInits=getattr(synapsePropsList, DLInt1SynapsePropsE),
81
+                      synStateInits=exp2SynStateInits,
82
+                      sourceInd=0, destInd=0
83
+                      )
84
+if DLInt1SynapsePropsI:
85
+    dlint1.addSynapse(synName="InhJO", sourceNG=JO.JOSGG, **exp2Syn,
86
+                      synParsInits=getattr(synapsePropsList, DLInt1SynapsePropsI),
87
+                      synStateInits=exp2SynStateInits,
88
+                      sourceInd=0, destInd=0
89
+                      )
90
+
91
+net = Network()
92
+net.add(JO.JOSGG)
93
+dlint1.addToNetwork(net)
94
+defaultclock.dt = simStepSize
95
+totalSimDur = simDuration + simSettleTime
96
+net.run(totalSimDur, report='text')
97
+
98
+simT, memV = dlint1.getMemVTrace()
99
+spikeTimes = dlint1.getSpikes()
100
+
101
+
102
+fig, axs = plt.subplots(nrows=2, figsize=(10, 6.25), sharex='col')
103
+axs[0].plot(simT / units.ms, memV / units.mV)
104
+spikesY = memV.min() + 1.05 * (memV.max() - memV.min())
105
+axs[0].plot(spikeTimes / units.ms, [spikesY / units.mV] * spikeTimes.shape[0], 'k^')
106
+axs[0].set_ylabel('DLInt1 \nmemV (mV)')
107
+axs[0].set_xlim([(simSettleTime - showBefore) / units.ms,
108
+                 (totalSimDur + showAfter) / units.ms])
109
+sineInput = getSineInput(simDur=simDuration, simStepSize=simStepSize,
110
+                         sinPulseDurs=inputPars['sinPulseDurs'],
111
+                         sinPulseStarts=inputPars['sinPulseStarts'],
112
+                         freq=265 * units.Hz, simSettleTime=simSettleTime)
113
+axs[1].plot(simT / units.ms, sineInput, 'r-', label='Vibration Input')
114
+axs[1].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
115
+        label='JO Spikes')
116
+axs[1].legend(loc='upper right')
117
+axs[1].set_xlabel('time (ms)')
118
+axs[1].set_ylabel('Vibration \nInput/JO\n Spikes')
119
+fig.tight_layout()
120
+fig.canvas.draw()
121
+# plt.show()
122
+fig.savefig(opFile, dpi=150)
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+

+ 0 - 0
models/__init__.py


BIN
models/__init__.pyc


BIN
models/__pycache__/__init__.cpython-35.pyc


BIN
models/__pycache__/__init__.cpython-36.pyc


BIN
models/__pycache__/neuronModels.cpython-35.pyc


BIN
models/__pycache__/neuronModels.cpython-36.pyc


BIN
models/__pycache__/neurons.cpython-35.pyc


BIN
models/__pycache__/synapses.cpython-35.pyc


+ 247 - 0
models/neuronModels.py

@@ -0,0 +1,247 @@
1
+from copy import copy
2
+from typing import Union, Iterable
3
+
4
+import numpy as np
5
+from brian2 import NeuronGroup, TimedArray, StateMonitor, SpikeMonitor, SpikeGeneratorGroup, array
6
+from brian2 import Synapses
7
+from brian2 import units
8
+from brian2.core.network import Network
9
+from brian2.equations.codestrings import CodeString
10
+from brian2.equations.equations import Equations
11
+from brian2.units.fundamentalunits import Quantity
12
+
13
+from brianUtils import getSimT
14
+
15
+def addSynNameVar(var: str, name: str) -> str:
16
+
17
+    return "_".join([var, name])
18
+
19
+def addSynNameEqs(model: str, prePosts: Iterable[Union[str, None]], synName: str) -> tuple:
20
+
21
+    mEq = Equations(model)
22
+    newM = copy(model)
23
+    for name in mEq.names:
24
+        if (not name.endswith("_post")) and (not name.endswith("_pre")):
25
+            newM = newM.replace(name, addSynNameVar(name, synName))
26
+
27
+
28
+    newPrePosts = []
29
+    prePostCSs = []
30
+    for p in prePosts:
31
+        newP = copy(p)
32
+        if p:
33
+            cs = CodeString(p)
34
+            for name in cs.identifiers:
35
+                if (not name.endswith("_post")) and (not name.endswith("_pre")):
36
+                    newP = newP.replace(name, addSynNameVar(name, synName))
37
+            newPrePosts.append(newP)
38
+            prePostCSs.append(cs)
39
+        else:
40
+            newPrePosts.append(None)
41
+            prePostCSs.append(None)
42
+
43
+    return newM, mEq, newPrePosts, prePostCSs
44
+
45
+
46
+class VSNeuron(object):
47
+
48
+    def __init__(self, model: str, name: str,
49
+                 inits: dict,
50
+                 threshold: str,
51
+                 reset: str,
52
+                 method: str = "euler"):
53
+
54
+        super().__init__()
55
+        self.ngParams = {"model": model, "threshold": threshold, "reset": reset, "method": method,
56
+                         "name": name}
57
+        self.inits = inits
58
+        self.incomingSynapses = {}
59
+        self.incomingSynapsePars = {}
60
+        self.synCurrentNames = []
61
+        self.recordMemVFlag = False
62
+        self.recordSpikesFlag = False
63
+        self.ng = None
64
+
65
+    def updateInits(self, initUpdate: dict):
66
+
67
+        self.inits.update(initUpdate)
68
+
69
+    def setInputCurrent(self, I: Union[TimedArray, float]):
70
+        self.inits["I"] = I
71
+
72
+    def recordMembraneV(self):
73
+
74
+        self.recordMemVFlag = True
75
+
76
+    def recordSpikes(self):
77
+
78
+        self.recordSpikesFlag = True
79
+
80
+    def getMemVTrace(self):
81
+
82
+        assert self.recordMemVFlag, 'Membrane Voltage was not recorded' \
83
+                                            'for this neuron'
84
+        return self.memVRecord.t, self.memVRecord[0].V
85
+
86
+    def getSpikes(self):
87
+
88
+        assert self.recordSpikesFlag, "Spikes were not recorded for this neuron"
89
+
90
+        return self.spikeRecord.t
91
+
92
+    def addToNetwork(self, network: Network):
93
+
94
+        self.ngParams["model"] = "\n".join((self.ngParams["model"], "Iext: amp"))
95
+        self.inits["Iext"] = 0 * units.amp
96
+        eq2Add = "I = Iext "
97
+
98
+        for synCurrentName in self.synCurrentNames:
99
+
100
+            self.ngParams["model"] = "\n".join((self.ngParams["model"], "{} : amp".format(synCurrentName)))
101
+            self.inits[synCurrentName] = 0 * units.amp
102
+            eq2Add += " + {} ".format(synCurrentName)
103
+
104
+        eq2Add += ": amp"
105
+
106
+        self.ngParams["model"] = "\n".join((self.ngParams["model"], eq2Add))
107
+
108
+        self.ng = NeuronGroup(N=1, **self.ngParams)
109
+        self.initSim()
110
+        network.add(self.ng)
111
+        if self.recordMemVFlag:
112
+            self.memVRecord = StateMonitor(self.ng, "V", record=[0])
113
+            network.add(self.memVRecord)
114
+        if self.recordSpikesFlag:
115
+            self.spikeRecord = SpikeMonitor(self.ng)
116
+            network.add(self.spikeRecord)
117
+
118
+        for synName, synPars in self.incomingSynapsePars.items():
119
+
120
+            syn = Synapses(synPars["source"], self.ng,
121
+                           model=synPars["model"],
122
+                           on_pre=synPars["on_pre"],
123
+                           on_post=synPars["on_post"],
124
+                           method=synPars["method"])
125
+
126
+            syn.connect(i=synPars["sourceInd"], j=synPars["destInd"])
127
+
128
+            for k, v in synPars["initMap"].items():
129
+
130
+                setattr(syn, k, v)
131
+
132
+            self.incomingSynapses[synName] = syn
133
+            network.add(syn)
134
+
135
+
136
+    def initSim(self):
137
+
138
+        for k, v in self.inits.items():
139
+            setattr(self.ng, k, v)
140
+
141
+    def addSynapse(self, synName: str, sourceNG: NeuronGroup,
142
+                   model: str, synParsInits: dict, synStateInits: dict,
143
+                   on_pre: Union[str, None] = None,
144
+                   on_post: Union[str, None] = None,
145
+                   sourceInd: int = 0, destInd: int = 0,
146
+                   method: str = "euler"):
147
+
148
+
149
+        assert synName not in self.incomingSynapses, 'A Synapse with {} already exists'.format(synName)
150
+        ISyn_PostInd = model.find("ISyn_post")
151
+        assert ISyn_PostInd >= 0, "Synapse model should have an equation for" \
152
+                                            "\'ISyn_post\'"
153
+        nextEndLineInd = model.find("\n", ISyn_PostInd)
154
+        assert model[nextEndLineInd - 8: nextEndLineInd] == "(summed)", \
155
+            "Equation for \'ISyn_post\' must have (summed) flag"
156
+
157
+
158
+        newModel, mEq, [newOn_pre, newOn_post], prePostCSs = \
159
+            addSynNameEqs(model, [on_pre, on_post], synName)
160
+
161
+        allSV = mEq.diff_eq_names
162
+        allPars = list(mEq.parameter_names)
163
+
164
+
165
+        for cs in prePostCSs:
166
+            if cs:
167
+                for i in cs.identifiers:
168
+                    if i not in allSV:
169
+                        allPars.append(i)
170
+
171
+        for par in allPars:
172
+            assert par in synParsInits, "Initialization not provided for {} in synParsInits".format(par)
173
+
174
+        for sv in allSV:
175
+            assert sv in synStateInits, "Initialization not provided for {} in synStateInits".format(sv)
176
+
177
+        ISynName = "_".join(("ISyn", synName))
178
+        self.synCurrentNames.append(ISynName)
179
+
180
+        newModel = newModel.replace("ISyn", ISynName)
181
+
182
+        initMap = {"delay": synParsInits["delay"]}
183
+        for par in allPars:
184
+            initMap[addSynNameVar(par, synName)] = synParsInits[par]
185
+
186
+        for sv in allSV:
187
+            initMap[addSynNameVar(sv, synName)] = synStateInits[sv]
188
+
189
+        synPars = {"source": sourceNG, "model": newModel, "on_pre": newOn_pre,
190
+                   "on_post": newOn_post, "method": method,
191
+                   "sourceInd": sourceInd, "destInd": destInd, "initMap": initMap}
192
+
193
+        self.incomingSynapsePars[synName] = synPars
194
+
195
+
196
+
197
+
198
+class JOSpikes265(object):
199
+
200
+    def __init__(self, nOutputs: int =1, simSettleTime: Quantity = 0 * units.ms,
201
+                 sinPulseStarts: array = array(()) * units.ms,
202
+                 sinPulseDurs: array = array(()) * units.ms):
203
+
204
+        self.nOutputs = nOutputs
205
+        freq = 265 * units.Hz
206
+        spikePhase = np.deg2rad(240)
207
+        phaseDelay = (1 / freq) * (spikePhase / (2 * np.pi))
208
+        self.spikeTimes = []
209
+        self.spikeInds = []
210
+        simSettleTimeF = float(simSettleTime)
211
+
212
+        for start, dur in zip(sinPulseStarts, sinPulseDurs):
213
+
214
+            startF = float(start)
215
+            durF = float(dur)
216
+            periodF = float(1/freq)
217
+            phaseDelayF = float(phaseDelay)
218
+
219
+            cycleStarts = np.arange(startF, startF + durF, periodF)
220
+            for i in range(nOutputs):
221
+                self.spikeTimes += (simSettleTimeF + cycleStarts + phaseDelayF).tolist()
222
+                self.spikeInds += [i] * len(cycleStarts)
223
+
224
+        self.spikeTimes = self.spikeTimes * units.second
225
+        self.JOSGG = SpikeGeneratorGroup(nOutputs, array(self.spikeInds),
226
+                                         self.spikeTimes)
227
+
228
+def getSineInput(simDur: Quantity, simStepSize: Quantity,
229
+                 sinPulseStarts: Quantity, sinPulseDurs: Quantity,
230
+                 freq: Quantity, simSettleTime: Quantity = 0 * units.ms,):
231
+
232
+    simT = getSimT(simSettleTime + simDur, simStepSize)
233
+    sineInput = np.zeros(simT.shape)
234
+
235
+    for start, dur in zip(sinPulseStarts, sinPulseDurs):
236
+
237
+        settleStart = start + simSettleTime
238
+        settleEnd = start + dur + simSettleTime
239
+
240
+        timeMask = (simT >= settleStart) & (simT <= settleEnd)
241
+        sineInput[timeMask] = np.sin(2 * np.pi * freq * (simT[timeMask] - (0.5 / freq) - start))
242
+
243
+    return sineInput
244
+
245
+
246
+
247
+

+ 20 - 0
models/neurons.py

@@ -0,0 +1,20 @@
1
+AdExpEqs = "\n".join((
2
+    "Ex = gL*sF*exp( (V - Vt)/sF ) : amp",
3
+    "IL = gL*(EL - V) : amp",
4
+    "dV/dt = (I + IL + Ex - w)/C : volt",
5
+    "dw/dt = (a*(V - EL) - w)/tau : amp",
6
+    "Vt : volt",
7
+    "Vr : volt",
8
+    "b : amp",
9
+    "sF : volt",
10
+    "tau: second",
11
+    "EL : volt",
12
+    "gL : siemens",
13
+    "C : farad",
14
+    "a : siemens",
15
+    "Vp : volt"
16
+    ))
17
+
18
+AdExp = {"model": AdExpEqs,
19
+         "threshold": "V > Vp",
20
+         "reset": "V = Vr; w+=b"}

+ 22 - 0
models/synapses.py

@@ -0,0 +1,22 @@
1
+from brian2 import units
2
+
3
+exp2SynEqs = "\n".join((
4
+    "g = B - A: siemens",
5
+    "ISyn_post =  -g * (V_post - Esyn): amp (summed)",
6
+    "dB/dt = -B/tau2: siemens (clock-driven)",
7
+    "dA/dt = -A/tau1: siemens (clock-driven)",
8
+    "tau1: second",
9
+    "tau2: second",
10
+    "wSyn: siemens",
11
+    "Esyn: volt",
12
+    ))
13
+
14
+exp2Syn = {
15
+    "model": exp2SynEqs,
16
+    "on_pre": "A += wSyn\nB += wSyn",
17
+}
18
+
19
+exp2SynStateInits = {
20
+    "A": 0 * units.siemens,
21
+    "B": 0 * units.siemens
22
+}

+ 29 - 0
mplPars.py

@@ -0,0 +1,29 @@
1
+# mplPars = {'text.usetex': True,
2
+#            'axes.labelsize': 'large',
3
+#            'axes.titlesize': 24,
4
+#            'font.family': 'sans-serif',
5
+#            'font.sans-serif': 'computer modern roman',
6
+#            'font.size': 24,
7
+#            'font.weight': 'black',
8
+#            'xtick.labelsize': 20,
9
+#            'ytick.labelsize': 20,
10
+#            'legend.fontsize': 20,
11
+#            'legend.frameon': True,
12
+#            'legend.framealpha': 0,
13
+#            'legend.fancybox': True,
14
+#            'text.latex.preamble': r'\usepackage{cmbright}'
15
+#            }
16
+
17
+mplPars = {'axes.labelsize': 'large',
18
+           'axes.titlesize': 24,
19
+           'font.family': 'sans-serif',
20
+           'font.sans-serif': 'computer modern roman',
21
+           'font.size': 24,
22
+           'font.weight': 'black',
23
+           'xtick.labelsize': 20,
24
+           'ytick.labelsize': 20,
25
+           'legend.fontsize': 20,
26
+           'legend.frameon': True,
27
+           'legend.framealpha': 0,
28
+           'legend.fancybox': True,
29
+           }

+ 316 - 0
neoNIXIO.py

@@ -0,0 +1,316 @@
1
+# Ajayrama Kumaraswamy, 2016
2
+# Ginjang Project, LMU
3
+
4
+import nixio as nix
5
+import neo
6
+import quantities as qu
7
+import numpy as np
8
+
9
+qu2Val = lambda x: nix.Value(float(x))
10
+quUnitStr = lambda x: x.dimensionality.string
11
+
12
+#***********************************************************************************************************************
13
+
14
+def addAnalogSignal2Block(blk, analogSignal):
15
+    '''
16
+    Create a new data array in the block blk and add the data in analogSignal to it
17
+    :param blk: nix.block
18
+    :param analogSignal: neo.analogsignal
19
+    :return: data, nix.data_array, the newly added data_array
20
+    '''
21
+
22
+    assert hasattr(analogSignal, 'name'), 'Analog signal has no name'
23
+
24
+    data = blk.create_data_array(analogSignal.name, 'nix.regular_sampled', data=analogSignal.magnitude)
25
+
26
+    data.unit = quUnitStr(analogSignal)
27
+    data.label = analogSignal.name
28
+
29
+    qu.set_default_units = 'SI'
30
+    samplingPeriod = analogSignal.sampling_period.simplified
31
+    t = data.append_sampled_dimension(float(samplingPeriod))
32
+    t.label = 'time'
33
+    t.unit = quUnitStr(samplingPeriod)
34
+    t.offset = float(analogSignal.t_start.simplified)
35
+
36
+    return data
37
+
38
+#***********************************************************************************************************************
39
+
40
+def dataArray2AnalogSignal(dataArray):
41
+    '''
42
+    Convert a nix data_array into a neo analogsignal
43
+    :param dataArray: nix.data_array
44
+    :return: neo.analogsignal
45
+    '''
46
+
47
+    assert len(dataArray.dimensions) == 1, 'Only one dimensional arrays are supported'
48
+    dim = dataArray.dimensions[0]
49
+    assert isinstance(dim, nix.pycore.SampledDimension), 'Only Sampled Dimensions' \
50
+                                                         'are supported'
51
+
52
+    t_start = qu.Quantity(dim.offset, units=dim.unit)
53
+    samplingPeriod = qu.Quantity(dim.sampling_interval, units=dim.unit)
54
+
55
+    analogSignal = neo.AnalogSignal(signal=np.array(dataArray[:]),
56
+                                    units=dataArray.unit,
57
+                                    sampling_period=samplingPeriod,
58
+                                    t_start=t_start)
59
+
60
+    analogSignal.name = dataArray.name
61
+
62
+    return analogSignal
63
+
64
+#***********************************************************************************************************************
65
+
66
+def property2qu(property):
67
+    '''
68
+    Convert a nix property to a quantities Quantity
69
+    :param property: nix.property
70
+    :return: quantities.Quantity
71
+    '''
72
+
73
+    return qu.Quantity([v.value for v in property.values], units=property.unit)
74
+
75
+#***********************************************************************************************************************
76
+
77
+def addQuantity2section(sec, quant, name):
78
+    '''
79
+    Create new property in section sec and add the data in quantity.Quantitiy quant to it
80
+    :param sec: nix.section
81
+    :param quant: quantities.Quantity
82
+    :param name: name of the property to add
83
+    :return: p, nix.property, the property added.
84
+    '''
85
+
86
+    if quant.shape == ():
87
+
88
+        p = sec.create_property(name, [qu2Val(quant)])
89
+
90
+    #only 1D arrays
91
+    elif len(quant.shape) == 1:
92
+
93
+        #not an empty 1D array
94
+        if quant.shape[0]:
95
+
96
+            p = sec.create_property(name, [qu2Val(x) for x in quant])
97
+
98
+        else:
99
+            raise(ValueError('Quantity passed must be either scalar or 1 dimensional'))
100
+
101
+    else:
102
+            raise(ValueError('Quantity passed must be either scalar or 1 dimensional'))
103
+
104
+    p.unit = quUnitStr(quant)
105
+
106
+    return p
107
+
108
+#***********************************************************************************************************************
109
+
110
+def createPosDA(name, pos, blk):
111
+    '''
112
+    Create a data_array of type 'nix.positions' with the pos data in the block blk
113
+    :param name: string, name of the data_array to create
114
+    :param pos: iterable of floats, data to be added to the created data_array
115
+    :param blk: nix.block, the block in which the data_array is to be created
116
+    :return: positions, nix.data_array, the newly created data_array
117
+    '''
118
+
119
+    positions = blk.create_data_array(name, 'nix.positions', data=pos)
120
+    positions.append_set_dimension()
121
+    positions.append_set_dimension()
122
+
123
+    return positions
124
+
125
+#***********************************************************************************************************************
126
+
127
+def createExtDA(name, ext, blk):
128
+    '''
129
+   Create a data_array of type 'nix.extents' with the pos data in the block blk
130
+   :param name: string, name of the data_array to create
131
+   :param ext: iterable of floats, data to be added to the created data_array
132
+   :param blk: nix.block, the block in which the data_array is to be created
133
+   :return: extents, nix.data_array, the newly created data_array
134
+   '''
135
+
136
+    extents = blk.create_data_array(name, 'nix.extents', data=ext)
137
+    extents.append_set_dimension()
138
+    extents.append_set_dimension()
139
+
140
+    return extents
141
+
142
+#***********************************************************************************************************************
143
+
144
+def tag2AnalogSignal(tag, refInd):
145
+    '''
146
+    Create a neo.analogsignal from the snippet of data represented by a nix.tag and its reference at index refInd
147
+    :param tag: nix.tag
148
+    :param refInd: the index of the reference among those of the tag to use
149
+    :return: neo.analogsignal with the snipped of reference data tagged by tag.
150
+    '''
151
+
152
+    ref = tag.references[refInd]
153
+    dim = ref.dimensions[0]
154
+    offset = dim.offset
155
+    ts = dim.sampling_interval
156
+    nSamples = ref[:].shape[0]
157
+
158
+    startInd = max(0, int(np.floor((tag.position[0] - offset) / ts)))
159
+    endInd = min(startInd + int(np.floor(tag.extent[0] / ts)) + 1, nSamples)
160
+    trace = ref[startInd:endInd]
161
+
162
+    analogSignal = neo.AnalogSignal(signal=trace,
163
+                                    units=ref.unit,
164
+                                    sampling_period=qu.Quantity(ts, units=dim.unit),
165
+                                    t_start=qu.Quantity(offset + startInd * ts, units=dim.unit))
166
+
167
+    analogSignal = analogSignal.reshape((analogSignal.shape[0],))
168
+    # trace = tag.retrieve_data(refInd)[:]
169
+    # tVec = tag.position[0] + np.linspace(0, tag.extent[0], trace.shape[0])
170
+
171
+    return analogSignal
172
+
173
+#***********************************************************************************************************************
174
+
175
+def getTagPosExt(tag):
176
+
177
+    position = tag.position[0] * qu.Quantity(1, units=tag.units[0])
178
+    extent = tag.extent[0] * qu.Quantity(1, units=tag.units[0])
179
+
180
+    return position, extent
181
+
182
+
183
+
184
+#***********************************************************************************************************************
185
+def multiTag2SpikeTrain(tag, tStart, tStop):
186
+    '''
187
+    Create a neo.spiketrain from nix.multitag
188
+    :param tag: nix.multitag
189
+    :param tStart: float, time of start of the spike train in units of the multitag
190
+    :param tStop: float, time of stop of the spike train in units of the multitag
191
+    :return: neo.spiketrain
192
+    '''
193
+
194
+
195
+    if len(tag.positions):
196
+        sp = neo.SpikeTrain(times=tag.positions[:], t_start=tStart, t_stop=tStop, units=tag.units[0])
197
+    else:
198
+        sp = neo.SpikeTrain(times=[], t_start=tStart, t_stop=tStop, units=qu.s)
199
+
200
+    return sp
201
+
202
+
203
+#***********************************************************************************************************************
204
+
205
+def addMultiTag(name, type, positions, blk, refs, metadata=None, extents=None):
206
+    '''
207
+    Add a multi_tag to one or more data_arrays
208
+    :param name: string, name of the multi_tag
209
+    :param type: string, type of the multi_tag
210
+    :param positions: quantities.Quantity, positions of the multi_tag
211
+    :param blk: nix.Block, the block in which the multi_tag is to be created
212
+    :param refs: list, list of nix.data_array objects, to which the multi_tag refers
213
+    :param metadata: nix.Section, to which the the multi_tag refers
214
+    :param extents: nix.data_array, extents of the multi_tag
215
+    :return: nix.multi_tag, the newly created multi_tag
216
+    '''
217
+
218
+    refUnits0 = refs[0].dimensions[0].unit
219
+    for ref in refs:
220
+        assert len(ref.dimensions) == 1, 'Only 1D refs are supported for now.'
221
+        assert ref.dimensions[0].unit == refUnits0, 'refs must have same time units'
222
+
223
+    positionsUnitsNormed = simpleFloat(positions / qu.Quantity(1, units=refUnits0))
224
+    positionsDA = createPosDA('{}_DA'.format(name), positionsUnitsNormed, blk)
225
+    tag = blk.create_multi_tag(name, type, positionsDA)
226
+    tag.units = [str(refUnits0)]
227
+
228
+    if extents is not None:
229
+        tag.extents = extents
230
+
231
+    for ref in refs:
232
+        tag.references.append(ref)
233
+
234
+    if metadata is not None:
235
+        tag.metadata = metadata
236
+
237
+#***********************************************************************************************************************
238
+
239
+def addTag(name, type, position, blk, refs, metadata=None, extent=None):
240
+    '''
241
+    Add a tag to one or more data_arrays
242
+    :param name: string, name of the tag
243
+    :param type: string, type of the tag
244
+    :param position: float, position of the tag
245
+    :param blk: nix.Block, the block in which the multi_tag is to be created
246
+    :param refs: list, list of nix.data_array objects, to which the multi_tag refers
247
+    :param metadata: nix.Section, to which the the multi_tag refers
248
+    :param extent: float, extent of the multi_tag
249
+    :return: nix.tag, the newly created tag
250
+    '''
251
+    tag = blk.create_tag(name, type, [position])
252
+
253
+
254
+
255
+    if extent is not None:
256
+        tag.extent = [extent]
257
+
258
+    for ref in refs:
259
+        tag.references.append(ref)
260
+        tag.units = [str(ref.dimensions[0].unit)]
261
+
262
+    if metadata is not None:
263
+        tag.metadata = metadata
264
+
265
+
266
+#***********************************************************************************************************************
267
+
268
+def simpleFloat(quant):
269
+    '''
270
+    Float or List of float(s) of simplified version of a quantity that can be
271
+    effectively represented as a float or list of floats.
272
+    :param quant: a quantity.Quantity or an iterable of quantity.Quantity objects
273
+    :return: float or iterable of floats depending on the argument quant
274
+    '''
275
+
276
+    # one element quantity
277
+    if quant.shape == ():
278
+
279
+        return float(quant.simplified)
280
+
281
+    # 1D quantity
282
+    elif len(quant.shape) == 1:
283
+
284
+        if quant.shape[0]:
285
+
286
+            return quant.simplified.magnitude.tolist()
287
+
288
+        else:
289
+
290
+            return []
291
+
292
+    # 2D quantity
293
+    elif len(quant.shape) == 2:
294
+
295
+        if quant.shape[0]:
296
+
297
+            # 2D column quantity
298
+            if quant.shape[1] == 1:
299
+                return quant.simplified.magnitude[:, 0].tolist()
300
+
301
+            # 2D row quantity
302
+            if quant.shape[0] == 1:
303
+                return quant.simplified.magnitude[0, :].tolist()
304
+
305
+            else:
306
+                raise (TypeError('simpleFloat only supports scalar, '
307
+                                 '1D, 2D row and 2D column quantities'))
308
+        else:
309
+            return []
310
+
311
+    else:
312
+
313
+        raise(TypeError('simpleFloat only supports scalar, '
314
+                        '1D, 2D row and 2D column quantities'))
315
+
316
+#***********************************************************************************************************************

+ 309 - 0
paramLists/AdExpPars.py

@@ -0,0 +1,309 @@
1
+# Most of these parameters are part of the work by Aynur Makhsutov
2
+# during AMGEN program 2016 at Wachtlerlab, LMU. The last few parameters sets
3
+# that start with "DLInt" have been newly added.
4
+
5
+
6
+from brian2 import nA, mV, ms, nS, pF, nF, uA, uF
7
+
8
+
9
+resonator = {
10
+    "b": 0.0805 * nA,
11
+    "V":-70.4*mV,
12
+    "sF": 2 * mV,
13
+    "tau": 144 * ms,
14
+    "EL": -70.6 * mV,
15
+    "gL": 20 * nS,
16
+    "C": 2810 * pF,
17
+    "a": 8 * nS
18
+}
19
+
20
+integrator = {
21
+    "b": 0.0805 * nA,
22
+    "V":-70.4*mV,
23
+    "sF": 2 * mV,
24
+    "tau": 144 * ms,
25
+    "EL": -70.6 * mV,
26
+    "gL": 20 * nS,
27
+    "C": 12 * nF,
28
+    "a": 4 * nS
29
+}
30
+
31
+rebound = {
32
+    "w": 0 * uA,
33
+    "Vr": -60 * mV,  # -48.5*mV,
34
+    "Vt": -50.4 * mV,
35
+    "b": 0.0805 * nA,
36
+    "V": -60 * mV,
37
+    "sF": 2 * mV,
38
+    "tau": 720 * ms,
39
+    "EL": -60 * mV,
40
+    "gL": 30 * nS,
41
+    "C": 281 * pF,
42
+    "a": 80 * nS
43
+}
44
+
45
+bursting = {
46
+    "w": 0 * uA,
47
+    "Vr": -47.4 * mV,
48
+    "Vt": -50.4 * mV,
49
+    "b": 0.0805 * nA,
50
+    "V": -70.4 * mV,
51
+    "sF": 2 * mV,
52
+    "tau": 144 * ms,
53
+    "EL": -70.6 * mV,
54
+    "gL": 30 * nS,
55
+    "C": 281 * pF,
56
+    "a": 4 * nS
57
+}
58
+
59
+bursting_rebound = {
60
+    "w": 0 * uA,
61
+    "Vr": -47.4 * mV,
62
+    "Vt": -50.4 * mV,
63
+    "b": 0.0805 * nA,
64
+    "V": -60 * mV,
65
+    "sF": 2 * mV,
66
+    "tau": 720 * ms,
67
+    "EL": -60 * mV,
68
+    "gL": 30 * nS,
69
+    "C": 281 * pF,
70
+    "a": 80 * nS
71
+}
72
+
73
+bursting_rebound_low = {
74
+    "w": 0 * uA,
75
+    "Vr": -47.4 * mV,
76
+    "Vt": -50.4 * mV,
77
+    "b": 0.0805 * nA,
78
+    "V": -60 * mV,
79
+    "sF": 2 * mV,
80
+    "tau": 720 * ms,
81
+    "EL": -60 * mV,
82
+    "gL": 30 * nS,
83
+    "C": 281 * pF,
84
+    "a": 30 * nS
85
+}
86
+
87
+bursting_rebound_high = {
88
+    "w": 0 * uA,
89
+    "Vr": -47.4 * mV,
90
+    "Vt": -50.4 * mV,
91
+    "b": 0.0805 * nA,
92
+    "V": -60 * mV,
93
+    "sF": 2 * mV,
94
+    "tau": 720 * ms,
95
+    "EL": -60 * mV,
96
+    "gL": 30 * nS,
97
+    "C": 281 * pF,
98
+    "a": 150 * nS
99
+}
100
+
101
+
102
+perc = {
103
+    "Vr": 0.1,
104
+    "Vt": 0.1,
105
+    "b": 0.99,
106
+    "sF": 0.2,
107
+    "tau": 0.6,
108
+    "gL": 0.01,
109
+    "C": 0.2,
110
+    "a": 0.4
111
+}
112
+
113
+hopf_resonator = {
114
+    "w": 0 * uA,
115
+    "Vr": -47.4 * mV,
116
+    "Vt": -50.4 * mV,
117
+    "b": 0.0805 * nA,
118
+    "V": -60 * mV,
119
+    "sF": 2 * mV,
120
+    "tau": 120 * ms,
121
+    "EL": -60 * mV,
122
+    "gL": 30 * nS,
123
+    "C": 681 * pF,
124
+    "a": 80 * nS
125
+}
126
+
127
+hopf_resonator2 = {
128
+    "w": 0 * uA,
129
+    "Vr": -47.4 * mV,
130
+    "Vt": -50.4 * mV,
131
+    "b": 0.0805 * nA,
132
+    "V": -60 * mV,
133
+    "sF": 2 * mV,
134
+    "tau": 120 * ms,
135
+    "EL": -60 * mV,
136
+    "gL": 6 * nS,
137
+    "C": 1200 * pF,
138
+    "a": 80 * nS
139
+}
140
+
141
+saddle_resonator = {
142
+    "w": 0 * uA,
143
+    "Vr": -47.4 * mV,
144
+    "Vt": -50.4 * mV,
145
+    "b": 0.0805 * nA,
146
+    "V": -60 * mV,
147
+    "sF": 2 * mV,
148
+    "tau": 12 * ms,
149
+    "EL": -60 * mV,
150
+    "gL": 30 * nS,
151
+    "C": 800 * pF,
152
+    "a": 30 * nS
153
+}
154
+
155
+saddle_resonator2 = {
156
+    "w": 0 * uA,
157
+    "Vr": -47.4 * mV,
158
+    "Vt": -50.4 * mV,
159
+    "b": 0.0805 * nA,
160
+    "V": -60 * mV,
161
+    "sF": 2 * mV,
162
+    "tau": 12 * ms,
163
+    "EL": -60 * mV,
164
+    "gL": 3 * nS,
165
+    "C": 800 * pF,
166
+    "a": 30 * nS
167
+}
168
+
169
+saddle_integrator = {
170
+    "w": 0 * uA,
171
+    "Vr": -47.4 * mV,
172
+    "Vt": -50.4 * mV,
173
+    "b": 0.0805 * nA,
174
+    "V": -60 * mV,
175
+    "sF": 2 * mV,
176
+    "tau": 12 * ms,
177
+    "EL": -60 * mV,
178
+    "gL": 40 * nS,
179
+    "C": 1200 * pF,
180
+    "a": 3 * nS
181
+}
182
+
183
+saddle_mixed = {
184
+    "w": 0 * uA,
185
+    "Vr": -47.4 * mV,
186
+    "Vt": -50.4 * mV,
187
+    "b": 0.0805 * nA,
188
+    "V": -60 * mV,
189
+    "sF": 2 * mV,
190
+    "tau": 12 * ms,
191
+    "EL": -60 * mV,
192
+    "gL": 80 * nS,
193
+    "C": 300 * pF,
194
+    "a": 10 * nS
195
+}
196
+
197
+result13 = {
198
+    "w": 0 * uA,
199
+    "Vr": -62.8 * mV,
200
+    "Vt": -49.2 * mV,
201
+    "b": 1.41 * nA,
202
+    "V": -60 * mV,
203
+    "sF": 7.2 * mV,
204
+    "tau": 600 * ms,
205
+    "EL": -60 * mV,
206
+    "gL": 80 * nS,
207
+    "C": 276 * pF,
208
+    "a": 1037 * nS
209
+}
210
+
211
+mean_24_08_2016 = {
212
+    "w": 0 * uA,
213
+    "Vr": -55.56 * mV,
214
+    "Vt": -49.82 * mV,
215
+    "b": 1.85 * nA,
216
+    "V": -60 * mV,
217
+    "sF": 6.69 * mV,
218
+    "tau": 617.8 * ms,
219
+    "EL": -60 * mV,
220
+    "gL": 411.7 * nS,
221
+    "C": 5242.8 * pF,
222
+    "a": 923 * nS
223
+}
224
+
225
+std_inits = {
226
+            "w": 0*uA,
227
+            "Vr": -70.6 * mV,#-48.5*mV,
228
+            "Vt": -50.4 * mV,
229
+            "b": 0.0805 * nA,
230
+            "V":-70.4 * mV,
231
+            "sF": 2 * mV,
232
+            "tau": 144 * ms,
233
+            "EL": -70.6 * mV,
234
+            "gL": 30 * nS,
235
+            "C": 281 * pF,
236
+            "a": 4 * nS,
237
+            "Vp": -25 * mV,
238
+    "I": 0 * nA
239
+}
240
+
241
+DLInt2Try1 = {
242
+    "b": 0.0805 * nA,
243
+    "V": -30*mV,
244
+    "sF": 2 * mV,
245
+    "tau": 5 * ms,
246
+    "EL": -30 * mV,
247
+    "gL": 200000 * nS,
248
+    "C": 0.5 * uF,
249
+    "a": 4 * nS,
250
+    "Vr": -30 * mV,
251
+    "Vt": -20 * mV,
252
+    "Vp": -10 * mV
253
+}
254
+
255
+DLInt1Try1 = {
256
+    "b": 0.0805 * nA,
257
+    "V": -30*mV,
258
+    "sF": 2 * mV,
259
+    "tau": 1 * ms,
260
+    "EL": -30 * mV,
261
+    "gL": 200000 * nS,
262
+    "C": 0.5 * uF,
263
+    "a": 200000 * nS,
264
+    "Vr": -30 * mV,
265
+    "Vt": -15 * mV,
266
+    "Vp": -5 * mV
267
+}
268
+
269
+DLInt1Try2 = {
270
+    "b": 1.367 * nA,
271
+    "V": -30*mV,
272
+    "sF": 6 * mV,
273
+    "tau": 100 * ms,
274
+    "EL": -30 * mV,
275
+    "gL": 200000 * nS,
276
+    "C": 0.5 * uF,
277
+    "a": 400000 * nS,
278
+    "Vr": -30 * mV,
279
+    "Vt": -25 * mV,
280
+    "Vp": 0 * mV
281
+}
282
+
283
+DLInt1Aynur = {
284
+    "b": 1 * nA,
285
+    "V": -30 * mV,
286
+    "sF": 6 * mV,
287
+    "tau": 180 * ms,
288
+    "EL": -30 * mV,
289
+    "gL": 500 * nS,
290
+    "C": 0.125 * nF,
291
+    "a": 500 * nS,
292
+    "Vr": -31 * mV,
293
+    "Vt": -27.5 * mV,
294
+    "Vp": 0 * mV
295
+}
296
+
297
+DLInt2Try2 = {
298
+    "b": 1 * nA,
299
+    "V": -30 * mV,
300
+    "sF": 6 * mV,
301
+    "tau": 0.08 * ms,
302
+    "EL": -30 * mV,
303
+    "gL": 500 * nS,
304
+    "C": 0.125 * nF,
305
+    "a": 500 * nS,
306
+    "Vr": -31 * mV,
307
+    "Vt": -27.5 * mV,
308
+    "Vp": 0 * mV
309
+}

BIN
paramLists/__pycache__/AdExpPars.cpython-35.pyc


BIN
paramLists/__pycache__/inputParsList.cpython-35.pyc


BIN
paramLists/__pycache__/synapsePropsList.cpython-35.pyc


+ 79 - 0
paramLists/inputParsList.py

@@ -0,0 +1,79 @@
1
+from brian2 import units, array
2
+from brian2.units.fundamentalunits import Quantity
3
+import numpy as np
4
+
5
+period265 = (1 / 265)
6
+
7
+onePulse = dict(sinPulseStarts=array([0]) * units.ms,
8
+                sinPulseDurs=array([0.9 * period265]) * units.second)
9
+twoPulse = dict(sinPulseStarts=array([0]) * units.ms,
10
+                sinPulseDurs=array([1.9 * period265]) * units.second)
11
+threePulse = dict(sinPulseStarts=array([0]) * units.ms,
12
+                sinPulseDurs=array([2.9 * period265]) * units.second)
13
+
14
+tenMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
15
+                sinPulseDurs=array([10]) * units.ms)
16
+twentyMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
17
+                sinPulseDurs=array([20]) * units.ms)
18
+thirtyMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
19
+                sinPulseDurs=array([30]) * units.ms)
20
+fortyMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
21
+                sinPulseDurs=array([40]) * units.ms)
22
+fiftyMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
23
+                sinPulseDurs=array([50]) * units.ms)
24
+
25
+
26
+
27
+oneSecondPulse = dict(sinPulseStarts=array([0]) * units.ms,
28
+                sinPulseDurs=array([1]) * units.second)
29
+
30
+def getPulseTrainInputPars(pulseDur: Quantity, pulseInt: Quantity,
31
+                           stimDur: Quantity) -> dict:
32
+    pulseDurF = float(pulseDur)
33
+    pulseIntF = float(pulseInt)
34
+    stimDurF = float(stimDur)
35
+
36
+    sinPulseStarts = (np.arange(0, stimDurF, pulseIntF)) * units.second
37
+    sinPulseDurs = ([pulseDurF] * len(sinPulseStarts)) * units.second
38
+
39
+    return dict(sinPulseStarts=sinPulseStarts,
40
+                sinPulseDurs=sinPulseDurs)
41
+
42
+pulseTrainInt20Dur10 = getPulseTrainInputPars(pulseDur=10*units.ms, pulseInt=20*units.ms,
43
+                                              stimDur=1*units.second)
44
+pulseTrainInt20Dur16 = getPulseTrainInputPars(pulseDur=16*units.ms, pulseInt=20*units.ms,
45
+                                              stimDur=1*units.second)
46
+pulseTrainInt33Dur10 = getPulseTrainInputPars(pulseDur=10*units.ms, pulseInt=33*units.ms,
47
+                                              stimDur=1*units.second)
48
+pulseTrainInt33Dur16 = getPulseTrainInputPars(pulseDur=16*units.ms, pulseInt=33*units.ms,
49
+                                              stimDur=1*units.second)
50
+pulseTrainInt50Dur10 = getPulseTrainInputPars(pulseDur=10*units.ms, pulseInt=50*units.ms,
51
+                                              stimDur=1*units.second)
52
+pulseTrainInt50Dur16 = getPulseTrainInputPars(pulseDur=16*units.ms, pulseInt=50*units.ms,
53
+                                              stimDur=1*units.second)
54
+pulseTrainInt50Dur20 = getPulseTrainInputPars(pulseDur=20*units.ms, pulseInt=50*units.ms,
55
+                                              stimDur=1*units.second)
56
+pulseTrainInt50Dur30 = getPulseTrainInputPars(pulseDur=30*units.ms, pulseInt=50*units.ms,
57
+                                              stimDur=1*units.second)
58
+pTShortInt20Dur10 = getPulseTrainInputPars(pulseDur=10 * units.ms, pulseInt=20 * units.ms,
59
+                                           stimDur=250 * units.ms)
60
+pTShortInt20Dur16 = getPulseTrainInputPars(pulseDur=16 * units.ms, pulseInt=20 * units.ms,
61
+                                           stimDur=250 * units.ms)
62
+pTShortInt33Dur10 = getPulseTrainInputPars(pulseDur=10 * units.ms, pulseInt=33 * units.ms,
63
+                                           stimDur=250 * units.ms)
64
+pTShortInt33Dur16 = getPulseTrainInputPars(pulseDur=16 * units.ms, pulseInt=33 * units.ms,
65
+                                           stimDur=250 * units.ms)
66
+pTShortInt33Dur20 = getPulseTrainInputPars(pulseDur=20 * units.ms, pulseInt=33 * units.ms,
67
+                                           stimDur=250 * units.ms)
68
+pTShortInt50Dur10 = getPulseTrainInputPars(pulseDur=10 * units.ms, pulseInt=50 * units.ms,
69
+                                           stimDur=250 * units.ms)
70
+pTShortInt50Dur16 = getPulseTrainInputPars(pulseDur=16 * units.ms, pulseInt=50 * units.ms,
71
+                                           stimDur=250 * units.ms)
72
+pTShortInt50Dur20 = getPulseTrainInputPars(pulseDur=20 * units.ms, pulseInt=50 * units.ms,
73
+                                           stimDur=250 * units.ms)
74
+pTShortInt100Dur10 = getPulseTrainInputPars(pulseDur=10 * units.ms, pulseInt=100 * units.ms,
75
+                                           stimDur=250 * units.ms)
76
+pTShortInt100Dur16 = getPulseTrainInputPars(pulseDur=16 * units.ms, pulseInt=100 * units.ms,
77
+                                           stimDur=250 * units.ms)
78
+pTShortInt100Dur20 = getPulseTrainInputPars(pulseDur=20 * units.ms, pulseInt=100 * units.ms,
79
+                                           stimDur=250 * units.ms)

+ 31 - 0
paramLists/synapsePropsList.py

@@ -0,0 +1,31 @@
1
+from brian2 import units
2
+
3
+DLInt1_syn_try1 = dict(wSyn=[5000, 400] * units.usiemens,
4
+                    Esyn=[0, -80] * units.mvolt,
5
+                    tau1=[4, 4] * units.ms, tau2=[4.5, 8] * units.ms,
6
+                    delay=[6, 10] * units.ms)
7
+
8
+DLInt1_syn_try2 = dict(wSyn=[15000, 1500] * units.nsiemens,
9
+                    Esyn=[0, -80] * units.mvolt,
10
+                    tau1=[4, 4] * units.ms, tau2=[4.5, 8] * units.ms,
11
+                    delay=[6, 18] * units.ms)
12
+
13
+DLInt1_syn_try2_e = dict(wSyn=25 * units.nsiemens,
14
+                    Esyn=0 * units.mvolt,
15
+                    tau1=0.5 * units.ms, tau2=2 * units.ms,
16
+                    delay=5 * units.ms)
17
+
18
+DLInt1_syn_try2_i = dict(wSyn=160 * units.nsiemens,
19
+                    Esyn=-80 * units.mvolt,
20
+                    tau1=12 * units.ms, tau2=15 * units.ms,
21
+                    delay=10 * units.ms)
22
+
23
+DLInt2_syn_try2 = dict(wSyn=75 * units.nsiemens,
24
+                    Esyn=0 * units.mvolt,
25
+                    tau1=0.5 * units.ms, tau2=2 * units.ms,
26
+                    delay=5 * units.ms)
27
+
28
+DLInt1_DLInt2_try1 = dict(wSyn=500 * units.nsiemens,
29
+                    Esyn=-80 * units.mvolt,
30
+                    tau1=7 * units.ms, tau2=8 * units.ms,
31
+                    delay=3 * units.ms)

+ 182 - 0
plotDLInt1DLInt2SynEffect.py

@@ -0,0 +1,182 @@
1
+import nixio
2
+from matplotlib import pyplot as plt
3
+from brian2 import units
4
+from dirDefs import homeFolder
5
+import os
6
+from neoNIXIO import dataArray2AnalogSignal, multiTag2SpikeTrain, simpleFloat
7
+from mplPars import mplPars
8
+import seaborn as sns
9
+import quantities as qu
10
+
11
+sns.set(rc=mplPars)
12
+
13
+
14
+simSettleTime = 600 * units.ms
15
+
16
+simStepSize = 0.1 * units.ms
17
+simDuration = 450 * units.ms
18
+totalSimDur = simSettleTime + simDuration
19
+IntDurs = [
20
+    (20, 10),
21
+    (20, 16),
22
+    (33, 10),
23
+    (33, 16),
24
+    (33, 20),
25
+    (50, 10),
26
+    (50, 16),
27
+    (50, 20),
28
+    (100, 10),
29
+    (100, 16),
30
+    (100, 20)
31
+]
32
+
33
+pulseInts = sorted(set([x[0] for x in IntDurs]))
34
+pulseDurs = sorted(set([x[1] for x in IntDurs]))
35
+
36
+showBefore = 75 * units.ms
37
+showAfter = -30 * units.ms
38
+
39
+DLInt1ModelProps = "DLInt1Aynur"
40
+
41
+
42
+DLInt2ModelProps = "DLInt2Try2"
43
+
44
+
45
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
46
+# DLInt1SynapsePropsE = ""
47
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
48
+# DLInt1SynapsePropsI = ""
49
+
50
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
51
+
52
+DLInt2SynapseProps = 'DLInt2_syn_try2'
53
+# DLInt2SynapseProps = ""
54
+
55
+
56
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
57
+# DLInt1DLInt2SynProps = ""
58
+
59
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
60
+
61
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
62
+                     DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps)
63
+
64
+fig1, axs1 = plt.subplots(nrows=len(pulseDurs), ncols=len(pulseInts),
65
+                          figsize=(14, 11.2), sharex='col')
66
+fig2, axs2 = plt.subplots(nrows=len(pulseDurs), ncols=len(pulseInts),
67
+                          figsize=(14, 11.2), sharex='col')
68
+
69
+for IntDur in IntDurs:
70
+
71
+    pulseInt = IntDur[0]
72
+    pulseDur = IntDur[1]
73
+    inputParsName = 'pTShortInt{:2d}Dur{:2d}'.format(pulseInt, pulseDur)
74
+    opDirWith = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
75
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
76
+                         inputParsName)
77
+    OPNixFileWith = os.path.join(opDirWith, 'SimResults.h5')
78
+
79
+    opDirWithout = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
80
+                             DLInt1SynapseProps + DLInt2SynapseProps,
81
+                             inputParsName)
82
+    OPNixFileWithout = os.path.join(opDirWithout, 'SimResults.h5')
83
+
84
+    nixFile = nixio.File.open(OPNixFileWith, nixio.FileMode.ReadOnly)
85
+    blk = nixFile.blocks["Simulation Traces"]
86
+    dlint1MemV = blk.data_arrays["DLInt1 MemV"]
87
+    dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
88
+    dlint2MemV = blk.data_arrays["DLInt2 MemV"]
89
+    dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
90
+    sinInput = blk.data_arrays["Input Vibration Signal"]
91
+    joSpikesMT = blk.multi_tags["JO Spikes"]
92
+
93
+    dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
94
+    dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
95
+    sinInputAS = dataArray2AnalogSignal(sinInput)
96
+    dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
97
+    dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
98
+    joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
99
+
100
+    nixFileWithout = nixio.File.open(OPNixFileWithout, nixio.FileMode.ReadOnly)
101
+    blkWithout = nixFileWithout.blocks["Simulation Traces"]
102
+    dlint2MemVWithout = blkWithout.data_arrays["DLInt2 MemV"]
103
+    dlint2SpikesMTWithout = blkWithout.multi_tags["DLInt2 Spikes"]
104
+    dlint2MemVASWithout = dataArray2AnalogSignal(dlint2MemVWithout)
105
+    dlint2SpikesSTWithout = multiTag2SpikeTrain(dlint2SpikesMTWithout,
106
+                                                sinInputAS.t_start, sinInputAS.t_stop)
107
+
108
+
109
+    rowInd = pulseDurs.index(pulseDur)
110
+    colInd = pulseInts.index(pulseInt)
111
+
112
+    axs1[rowInd, colInd].plot(simpleFloat(dlint1MemVAS.times / qu.ms),
113
+                              simpleFloat(dlint1MemVAS / qu.mV), 'b-', lw=1)
114
+    # mew needs setting for seaborn. https://github.com/mwaskom/seaborn/issues/644
115
+    axs1[rowInd, colInd].plot(simpleFloat(dlint1SpikesST.times / qu.ms),
116
+                              [4] * dlint1SpikesST.shape[0],
117
+                              'b|', ms=8, mew=1)
118
+    axs1[rowInd, colInd].plot(simpleFloat(sinInputAS.times / qu.ms),
119
+                              simpleFloat(-50 + (sinInputAS * 5) / qu.um)
120
+                              , 'k-', lw=1)
121
+    axs1[rowInd, colInd].set_xlim([(simSettleTime - showBefore) / units.ms,
122
+                                   (totalSimDur + showAfter) / units.ms])
123
+
124
+
125
+    axs2[rowInd, colInd].plot(simpleFloat(dlint2MemVAS.times / qu.ms),
126
+                              simpleFloat(dlint2MemVAS / qu.mV), 'b-', lw=1)
127
+    axs2[rowInd, colInd].plot(simpleFloat(dlint2MemVASWithout.times / qu.ms),
128
+                              simpleFloat(-45 + (dlint2MemVASWithout / qu.mV)),
129
+                              'r-', lw=1)
130
+    axs2[rowInd, colInd].plot(simpleFloat(dlint2SpikesST.times / qu.ms),
131
+                              [12] * dlint2SpikesST.shape[0],
132
+                            'b|', ms=8, mew=1)
133
+    axs2[rowInd, colInd].plot(simpleFloat(dlint2SpikesSTWithout.times / qu.ms),
134
+                              [6] * dlint2SpikesSTWithout.shape[0],
135
+                              'r|', ms=8, mew=1)
136
+    axs2[rowInd, colInd].plot(simpleFloat(sinInputAS.times / qu.ms),
137
+                              simpleFloat(-105 + (sinInputAS * 7.5) / qu.um)
138
+                              , 'k-', lw=1)
139
+    axs2[rowInd, colInd].set_xlim([(simSettleTime - showBefore) / units.ms,
140
+                                   (totalSimDur + showAfter) / units.ms])
141
+
142
+
143
+for rowInd in range(axs1.shape[0]):
144
+    for colInd in range(axs1.shape[1]):
145
+        ax = axs1[rowInd, colInd]
146
+        ax.set_ylim([-60, 10])
147
+        ax.yaxis.tick_right()
148
+        ax.set_yticklabels([""] * len(ax.get_yticks()))
149
+        ax.set_xticklabels([""] * len(ax.get_xticks()))
150
+
151
+for rowInd in range(axs2.shape[0]):
152
+    for colInd in range(axs2.shape[1]):
153
+        ax = axs2[rowInd, colInd]
154
+        ax.set_ylim([-120, 20])
155
+        ax.yaxis.tick_right()
156
+        ax.set_yticklabels([""] * len(ax.get_yticks()))
157
+        ax.set_xticklabels([""] * len(ax.get_xticks()))
158
+
159
+for ind, val in enumerate(pulseInts):
160
+
161
+    axs1[0, ind].set_title(str(val))
162
+    axs2[0, ind].set_title(str(val))
163
+
164
+for ind, val in enumerate(pulseDurs):
165
+
166
+    axs1[ind, 0].set_ylabel(str(val))
167
+    axs2[ind, 0].set_ylabel(str(val))
168
+
169
+fig1.tight_layout()
170
+fig2.tight_layout()
171
+
172
+fig1.savefig(os.path.join(opDir, 'DLInt1Summary.png'), dpi=150)
173
+fig2.savefig(os.path.join(opDir, 'DLInt2Summary.png'), dpi=150)
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+

+ 125 - 0
plotMemVs.py

@@ -0,0 +1,125 @@
1
+import nixio
2
+from dirDefs import homeFolder
3
+import os
4
+import seaborn as sns
5
+from mplPars import mplPars
6
+from brian2 import units
7
+from matplotlib import pyplot as plt
8
+from neoNIXIO import multiTag2SpikeTrain, dataArray2AnalogSignal, simpleFloat
9
+import quantities as qu
10
+
11
+mplPars["axes.titlesize"] = 14
12
+mplPars["font.size"] = 14
13
+mplPars["xtick.labelsize"] = 12
14
+mplPars["ytick.labelsize"] = 12
15
+mplPars["legend.fontsize"] = 12
16
+sns.set(rc=mplPars)
17
+
18
+
19
+simSettleTime = 600 * units.ms
20
+
21
+# simStepSize = 0.1 * units.ms
22
+# simDuration = 150 * units.ms
23
+# # inputParsName = 'onePulse'
24
+# # inputParsName = 'twoPulse'
25
+# # inputParsName = 'threePulse'
26
+# inputParsName = "thirtyMSPulse"
27
+# # inputParsName = "fortyMSPulse"
28
+#
29
+# showBefore = 50 * units.ms
30
+# showAfter = 0 * units.ms
31
+
32
+# simStepSize = 0.1 * units.ms
33
+# simDuration = 450 * units.ms
34
+# # inputParsName = "pTShortInt20Dur10"
35
+# # inputParsName = "pTShortInt20Dur16"
36
+# # inputParsName = "pTShortInt33Dur10"
37
+# # inputParsName = "pTShortInt33Dur16"
38
+# # inputParsName = "pTShortInt33Dur20"
39
+# # inputParsName = "pTShortInt50Dur10"
40
+# # inputParsName = "pTShortInt50Dur16"
41
+# # inputParsName = "pTShortInt50Dur20"
42
+# inputParsName = "pTShortInt100Dur10"
43
+# # inputParsName = "pTShortInt100Dur16"
44
+# # inputParsName = "pTShortInt100Dur20"
45
+#
46
+# showBefore = 100 * units.ms
47
+# showAfter = 100 * units.ms
48
+
49
+simStepSize = 0.1 * units.ms
50
+simDuration = 1500 * units.ms
51
+inputParsName = 'oneSecondPulse'
52
+# inputParsName = 'pulseTrainInt20Dur10'
53
+# inputParsName = 'pulseTrainInt20Dur16'
54
+# inputParsName = 'pulseTrainInt33Dur10'
55
+# inputParsName = 'pulseTrainInt33Dur16'
56
+
57
+showBefore = 500 * units.ms
58
+showAfter = 0 * units.ms
59
+
60
+DLInt1ModelProps = "DLInt1Aynur"
61
+
62
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
63
+# DLInt1SynapsePropsE = ""
64
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
65
+# DLInt1SynapsePropsI = ""
66
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
67
+
68
+DLInt2ModelProps = "DLInt2Try2"
69
+
70
+DLInt2SynapseProps = 'DLInt2_syn_try2'
71
+
72
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
73
+
74
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
75
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
76
+                         inputParsName)
77
+OPNixFile = os.path.join(opDir, 'SimResults.h5')
78
+
79
+
80
+totalSimDur = simDuration + simSettleTime
81
+
82
+nixFile = nixio.File.open(OPNixFile, nixio.FileMode.ReadOnly)
83
+blk = nixFile.blocks["Simulation Traces"]
84
+dlint1MemV = blk.data_arrays["DLInt1 MemV"]
85
+dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
86
+dlint2MemV = blk.data_arrays["DLInt2 MemV"]
87
+dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
88
+sinInput = blk.data_arrays["Input Vibration Signal"]
89
+joSpikesMT = blk.multi_tags["JO Spikes"]
90
+
91
+dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
92
+dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
93
+sinInputAS = dataArray2AnalogSignal(sinInput)
94
+dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
95
+dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
96
+joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
97
+
98
+fig1, axs1 = plt.subplots(nrows=2, figsize=(7, 4.375), sharex='col')
99
+axs1[0].plot(simpleFloat(dlint1MemVAS.times / qu.ms),
100
+                simpleFloat(dlint1MemVAS / qu.mV), 'b-', lw=0.5)
101
+axs1[0].plot(simpleFloat(sinInputAS.times / qu.ms),
102
+                simpleFloat((sinInputAS * 2.5 - 55 * qu.um) / qu.um),
103
+               'k-', lw=0.5)
104
+axs1[0].set_ylabel("DL-Int-1")
105
+axs1[0].set_ylim([-60, 10])
106
+
107
+axs1[1].plot(simpleFloat(dlint2MemVAS.times / qu.ms),
108
+                simpleFloat(dlint2MemVAS / qu.mV), 'b-', lw=0.5)
109
+
110
+axs1[1].plot(simpleFloat(sinInputAS.times / qu.ms),
111
+                simpleFloat((sinInputAS * 2.5 - 55 * qu.um) / qu.um),
112
+               'k-', lw=0.5)
113
+axs1[1].set_ylabel("DL-Int-2")
114
+# axs1[1].set_xlabel("Time (ms)")
115
+
116
+axs1[1].set_xlim([(simSettleTime - showBefore) / units.ms,
117
+                     (totalSimDur + showAfter) / units.ms])
118
+axs1[0].set_yticklabels([""] * len(axs1[1].get_yticks()))
119
+axs1[1].set_yticklabels([""] * len(axs1[1].get_yticks()))
120
+axs1[1].set_xticklabels([""] * len(axs1[1].get_xticks()))
121
+
122
+for fig in [fig1]:
123
+    fig.tight_layout()
124
+
125
+fig1.savefig(os.path.join(opDir, "Traces.png"), dpi=300)

+ 126 - 0
plotShortStims.py

@@ -0,0 +1,126 @@
1
+from brian2 import units
2
+from matplotlib import pyplot as plt
3
+import seaborn as sns
4
+import os
5
+from dirDefs import homeFolder
6
+import nixio
7
+from neoNIXIO import multiTag2SpikeTrain, dataArray2AnalogSignal, simpleFloat
8
+import quantities as qu
9
+from mplPars import mplPars
10
+
11
+sns.set(rc=mplPars)
12
+sns.axes_style('whitegrid')
13
+
14
+simSettleTime = 600 * units.ms
15
+#
16
+simStepSize = 0.1 * units.ms
17
+simDuration = 150 * units.ms
18
+inputParsNames = {
19
+                     10: "tenMSPulse",
20
+                     20: "twentyMSPulse",
21
+                     30: "thirtyMSPulse",
22
+                     40: "fortyMSPulse"
23
+                     }
24
+showBefore = 50 * units.ms
25
+showAfter = 50 * units.ms
26
+
27
+totalSimDur = simSettleTime + simDuration
28
+
29
+DLInt1ModelProps = "DLInt1Aynur"
30
+
31
+
32
+DLInt2ModelProps = "DLInt2Try2"
33
+
34
+
35
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
36
+# DLInt1SynapsePropsE = ""
37
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
38
+# DLInt1SynapsePropsI = ""
39
+
40
+DLInt2SynapseProps = 'DLInt2_syn_try2'
41
+# DLInt2SynapseProps = ""
42
+
43
+
44
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
45
+# DLInt1DLInt2SynProps = ""
46
+
47
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
48
+
49
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
50
+                     DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps)
51
+
52
+fig, axs = plt.subplots(nrows=2, ncols=len(inputParsNames), figsize=(14, 11.2),
53
+                        sharex='col')
54
+
55
+for ipInd, (ipVal, ipName) in enumerate(inputParsNames.items()):
56
+
57
+    nixFile = os.path.join(opDir, ipName, 'SimResults.h5')
58
+    nixFile = nixio.File.open(nixFile, nixio.FileMode.ReadOnly)
59
+    blk = nixFile.blocks["Simulation Traces"]
60
+    dlint1MemV = blk.data_arrays["DLInt1 MemV"]
61
+    dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
62
+    dlint2MemV = blk.data_arrays["DLInt2 MemV"]
63
+    dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
64
+    sinInput = blk.data_arrays["Input Vibration Signal"]
65
+    joSpikesMT = blk.multi_tags["JO Spikes"]
66
+
67
+    dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
68
+    dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
69
+    sinInputAS = dataArray2AnalogSignal(sinInput)
70
+    dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
71
+    dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
72
+    joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
73
+
74
+    axs[0, ipInd].plot(simpleFloat(dlint1MemVAS.times / qu.ms),
75
+                              simpleFloat(dlint1MemVAS / qu.mV), 'b-')
76
+    # mew needs setting for seaborn. https://github.com/mwaskom/seaborn/issues/644
77
+    axs[0, ipInd].plot(simpleFloat(dlint1SpikesST.times / qu.ms),
78
+                              [4] * dlint1SpikesST.shape[0],
79
+                              'b|', ms=8, mew=1)
80
+    markerline, stemlines, baseline \
81
+        = axs[0, ipInd].stem(simpleFloat(joSpikesST.times / qu.ms),
82
+                      [-40] * joSpikesST.shape[0],
83
+                      linefmt='r-.', markerfmt='None', basefmt='None',
84
+                      bottom=-60)
85
+    plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
86
+    axs[0, ipInd].plot(simpleFloat(sinInputAS.times / qu.ms),
87
+                              simpleFloat(((5 * qu.um * sinInputAS) - 50 * qu.um) / qu.um)
88
+                              , 'k-')
89
+    # axs[0, ipInd].set_xlim([(simSettleTime - showBefore) / units.ms,
90
+    #                                (totalSimDur + showAfter) / units.ms])
91
+    axs[0, ipInd].set_ylim([-60, 10])
92
+    axs[0, ipInd].yaxis.tick_right()
93
+
94
+
95
+    axs[1, ipInd].plot(simpleFloat(dlint2MemVAS.times / qu.ms),
96
+                       simpleFloat(dlint2MemVAS / qu.mV), 'b-')
97
+    # mew needs setting for seaborn. https://github.com/mwaskom/seaborn/issues/644
98
+    axs[1, ipInd].plot(simpleFloat(dlint2SpikesST.times / qu.ms),
99
+                       [4] * dlint2SpikesST.shape[0],
100
+                       'b|', ms=8, mew=1)
101
+    markerline, stemlines, baseline \
102
+        = axs[1, ipInd].stem(simpleFloat(joSpikesST.times / qu.ms),
103
+                             [-40] * joSpikesST.shape[0],
104
+                             linefmt='r-.', markerfmt='None', basefmt='None',
105
+                             bottom=-60)
106
+    plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
107
+    axs[1, ipInd].plot(simpleFloat(sinInputAS.times / qu.ms),
108
+                       simpleFloat(((5 * qu.um * sinInputAS) - 50 * qu.um) / qu.um)
109
+                       , 'k-')
110
+    axs[1, ipInd].set_xlim([(simSettleTime - showBefore) / units.ms,
111
+                            (totalSimDur + showAfter) / units.ms])
112
+    axs[1, ipInd].set_ylim([-60, 10])
113
+    axs[1, ipInd].yaxis.tick_right()
114
+
115
+for ind in range(len(inputParsNames) - 1):
116
+    axs[0, ind].set_yticks([])
117
+    axs[1, ind].set_yticks([])
118
+
119
+for ipInd, (ipVal, ipName) in enumerate(inputParsNames.items()):
120
+    axs[0, ipInd].set_title(ipVal)
121
+
122
+axs[0, 0].set_ylabel("DL-Int-1")
123
+axs[1, 0].set_ylabel("DL-Int-2")
124
+
125
+fig.tight_layout()
126
+fig.savefig(os.path.join(opDir, "shortStims.png"), dpi=300)

+ 203 - 0
plotSynCurrents.py

@@ -0,0 +1,203 @@
1
+import nixio
2
+from dirDefs import homeFolder
3
+import os
4
+import seaborn as sns
5
+from mplPars import mplPars
6
+from brian2 import units
7
+from matplotlib import pyplot as plt
8
+from neoNIXIO import multiTag2SpikeTrain, dataArray2AnalogSignal, simpleFloat
9
+import quantities as qu
10
+
11
+sns.set(rc=mplPars)