Browse Source

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

Ajayrama Kumaraswamy 6 years 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 @@
+name: Ai2017Sim
+channels:
+- brian-team
+- defaults
+dependencies:
+- brian2=2.0.1=np111py35_0
+- py-cpuinfo=0.2.3=py35_1
+- cycler=0.10.0=py35_0
+- cython=0.25.2=py35_0
+- dbus=1.10.10=0
+- decorator=4.0.11=py35_0
+- expat=2.1.0=0
+- fontconfig=2.12.1=3
+- freetype=2.5.5=2
+- glib=2.50.2=1
+- gst-plugins-base=1.8.0=0
+- gstreamer=1.8.0=0
+- icu=54.1=0
+- ipython=5.3.0=py35_0
+- ipython_genutils=0.2.0=py35_0
+- jinja2=2.9.6=py35_0
+- jpeg=9b=0
+- libffi=3.2.1=1
+- libgcc=5.2.0=0
+- libgfortran=3.0.0=1
+- libiconv=1.14=0
+- libpng=1.6.27=0
+- libxcb=1.12=1
+- libxml2=2.9.4=0
+- markupsafe=0.23=py35_2
+- matplotlib=2.0.0=np111py35_0
+- mkl=2017.0.1=0
+- mpmath=0.19=py35_1
+- numpy=1.11.3=py35_0
+- openssl=1.0.2k=1
+- pandas=0.19.2=np111py35_1
+- path.py=10.1=py35_0
+- pcre=8.39=1
+- pexpect=4.2.1=py35_0
+- pickleshare=0.7.4=py35_0
+- pip=9.0.1=py35_1
+- prompt_toolkit=1.0.14=py35_0
+- ptyprocess=0.5.1=py35_0
+- pygments=2.2.0=py35_0
+- pyparsing=2.1.4=py35_0
+- pyqt=5.6.0=py35_2
+- python=3.5.0=1
+- python-dateutil=2.6.0=py35_0
+- pytz=2017.2=py35_0
+- qt=5.6.2=3
+- readline=6.2=2
+- scipy=0.19.0=np111py35_0
+- seaborn=0.7.1=py35_0
+- setuptools=27.2.0=py35_0
+- simplegeneric=0.8.1=py35_1
+- sip=4.18=py35_0
+- six=1.10.0=py35_0
+- sqlite=3.13.0=0
+- sympy=1.0=py35_0
+- tk=8.5.18=0
+- traitlets=4.3.2=py35_0
+- wcwidth=0.1.7=py35_0
+- wheel=0.29.0=py35_0
+- xz=5.0.5=1
+- zlib=1.2.8=3
+- pip:
+  - h5py==2.7.0
+  - ipython-genutils==0.2.0
+  - neo==0.5.0
+  - nixio==1.3.0
+  - prompt-toolkit==1.0.14
+  - quantities==0+unknown
+prefix: /home/ajay/Installations/anaconda3/envs/Ai2017Sim
+

+ 242 - 0
DLInt1SynCurrent.py

@@ -0,0 +1,242 @@
+import os
+import sys
+
+import seaborn as sns
+from brian2 import defaultclock, units, StateMonitor
+from matplotlib import pyplot as plt
+from brian2.core.network import Network
+from dirDefs import homeFolder
+from models.neuronModels import VSNeuron, JOSpikes265, getSineInput
+from models.neurons import AdExp
+from models.synapses import exp2Syn, exp2SynStateInits
+from mplPars import mplPars
+from paramLists import synapsePropsList, inputParsList, AdExpPars
+
+from neo import AnalogSignal
+import nixio
+from neoNIXIO import addAnalogSignal2Block, addMultiTag
+import quantities as qu
+from brianUtils import addBrianQuantity2Section
+
+
+sns.set(style="whitegrid", rc=mplPars)
+
+
+simSettleTime = 600 * units.ms
+
+simStepSize = 0.1 * units.ms
+simDuration = 150 * units.ms
+# inputParsName = 'onePulse'
+# inputParsName = 'twoPulse'
+# inputParsName = 'threePulse'
+inputParsName = "fortyMSPulse"
+showBefore = 300 * units.ms
+showAfter = 50 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 1500 * units.ms
+# # inputParsName = 'oneSecondPulse'
+# # inputParsName = 'pulseTrainInt20Dur10'
+# inputParsName = 'pulseTrainInt20Dur16'
+# # inputParsName = 'pulseTrainInt33Dur10'
+# # inputParsName = 'pulseTrainInt33Dur16'
+# showBefore = 500 * units.ms
+# showAfter = 500 * units.ms
+
+DLInt1ModelProps = "DLInt1Aynur"
+DLInt1PropsDict = getattr(AdExpPars, DLInt1ModelProps)
+dlint1 = VSNeuron(**AdExp, inits=DLInt1PropsDict, name='dlint1')
+dlint1.recordMembraneV()
+dlint1.recordSpikes()
+
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
+# DLInt1SynapsePropsE = ""
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
+# DLInt1SynapsePropsI = ""
+DLInt1SynapseProps = "-".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+
+opDir = os.path.join(homeFolder, DLInt1ModelProps, DLInt1SynapseProps, inputParsName)
+
+
+opFile = os.path.join(opDir, 'SynCurrentTraces.png')
+OPNixFile = os.path.join(opDir, 'simResWithSynCurrents.h5')
+if os.path.isfile(opFile):
+    ch = input('Results already exist at {}. Delete?(y/n):'.format(opFile))
+    if ch == 'y':
+        os.remove(opFile)
+        if os.path.isfile(OPNixFile):
+            os.remove(OPNixFile)
+    else:
+        sys.exit('User Abort!')
+
+elif not os.path.isdir(opDir):
+    os.makedirs(opDir)
+
+inputPars = getattr(inputParsList, inputParsName)
+
+JO = JOSpikes265(nOutputs=1, simSettleTime=simSettleTime, **inputPars)
+
+
+if DLInt1SynapsePropsE:
+    synPropsE = getattr(synapsePropsList, DLInt1SynapsePropsE)
+    dlint1.addSynapse(synName="ExiJO", sourceNG=JO.JOSGG, **exp2Syn,
+                      synParsInits=synPropsE,
+                      synStateInits=exp2SynStateInits,
+                      sourceInd=0, destInd=0
+                      )
+
+if DLInt1SynapsePropsI:
+    synPropsI = getattr(synapsePropsList, DLInt1SynapsePropsI)
+    dlint1.addSynapse(synName="InhJO", sourceNG=JO.JOSGG, **exp2Syn,
+                      synParsInits=synPropsI,
+                      synStateInits=exp2SynStateInits,
+                      sourceInd=0, destInd=0
+                      )
+
+net = Network()
+net.add(JO.JOSGG)
+dlint1.addToNetwork(net)
+
+if DLInt1SynapsePropsE:
+    gEMonitor = StateMonitor(dlint1.incomingSynapses["ExiJO"], "g_ExiJO", record=True)
+    net.add(gEMonitor)
+
+if DLInt1SynapsePropsI:
+    gIMonitor = StateMonitor(dlint1.incomingSynapses["InhJO"], "g_InhJO", record=True)
+    net.add(gIMonitor)
+
+
+defaultclock.dt = simStepSize
+totalSimDur = simDuration + simSettleTime
+net.run(totalSimDur, report='text')
+
+simT, memV = dlint1.getMemVTrace()
+spikeTimes = dlint1.getSpikes()
+
+dlint1MemVAS = AnalogSignal(signal=memV / units.mV,
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
+                                t_start=0 * qu.mV,
+                                units="mV",
+                                name="DLInt1 MemV")
+
+
+dlint1SpikesQU = (spikeTimes / units.ms) * qu.ms
+
+joSpikesQU = (JO.spikeTimes / units.ms) * qu.ms
+
+sineInput = getSineInput(simDur=simDuration, simStepSize=simStepSize,
+                         sinPulseDurs=inputPars['sinPulseDurs'],
+                         sinPulseStarts=inputPars['sinPulseStarts'],
+                         freq=265 * units.Hz, simSettleTime=simSettleTime)
+
+inputAS = AnalogSignal(signal=sineInput,
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
+                                t_start=0 * qu.mV,
+                                units="um",
+                                name="Input Vibration Signal")
+
+fig, axs = plt.subplots(nrows=3, figsize=(10, 6.25), sharex='col')
+axs[0].plot(simT / units.ms, memV / units.mV)
+axs[0].set_ylabel('DLInt1\nMembrane\nPotential\n(mV)')
+spikesY = memV.min() + 1.05 * (memV.max() - memV.min())
+axs[0].plot(spikeTimes / units.ms, [spikesY / units.mV] * spikeTimes.shape[0], 'k^')
+axs[0].set_xlim([(simSettleTime - showBefore) / units.ms,
+                     (totalSimDur + showAfter) / units.ms])
+if DLInt1SynapsePropsE:
+    gSynE = gEMonitor.g_ExiJO[0]
+    iSynE = -gSynE * (memV - synPropsE['Esyn'])
+    axs[1].plot(simT / units.ms,
+                iSynE / units.nA, 'r-', label=r'$I_{synE}$')
+    iSynEAS = AnalogSignal(signal=iSynE / units.nA,
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
+                                t_start=0 * qu.mV,
+                                units="nA",
+                                name="DL-Int-1 input EPSC")
+
+if DLInt1SynapsePropsI:
+    gSynI = gIMonitor.g_InhJO[0]
+    iSynI = -gSynI * (memV - synPropsI['Esyn'])
+    axs[1].plot(simT / units.ms,
+                iSynI / units.nA, 'g-', label=r'$I_{synI}$')
+    iSynIAS = AnalogSignal(signal=iSynI / units.nA,
+                           sampling_period=(simStepSize / units.ms) * qu.ms,
+                           t_start=0 * qu.mV,
+                           units="nA",
+                           name="DL-Int-1 input IPSC")
+
+axs[1].legend(loc='center right')
+axs[1].set_ylabel("Synaptic\ncurrents\n(nA)")
+
+axs[2].plot(simT / units.ms, sineInput,
+            color=[130. / 255, 72. / 255, 7. / 255], ls='-', marker='None',
+            label='Vibration Input')
+axs[2].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
+        label='JO Spikes')
+axs[2].legend(loc='upper right')
+axs[2].set_xlabel('time (ms)')
+axs[2].set_ylabel('Input')
+
+fig.tight_layout()
+fig.canvas.draw()
+fig.savefig(opFile, dpi=150)
+
+nixFile = nixio.File.open(OPNixFile, mode=nixio.FileMode.ReadWrite)
+neuronModels = nixFile.create_section("Neuron Models", "Model Parameters")
+
+DLInt1PropsSec = neuronModels.create_section("DL-Int-1", "AdExp")
+
+for propName, propVal in DLInt1PropsDict.items():
+    addBrianQuantity2Section(DLInt1PropsSec, propName, propVal)
+
+inputSec = nixFile.create_section("Input Parameters", "Sinusoidal Pulses")
+
+for parName, parVal in inputPars.items():
+    addBrianQuantity2Section(inputSec, parName, parVal)
+
+addBrianQuantity2Section(inputSec, "simSettleTime", simSettleTime)
+
+brianSimSettingsSec = nixFile.create_section("Simulation Parameters", "Brian Simulation")
+addBrianQuantity2Section(brianSimSettingsSec, "simStepSize", simStepSize)
+addBrianQuantity2Section(brianSimSettingsSec, "totalSimDuration", totalSimDur)
+brianSimSettingsSec.create_property("method", nixio.Value("euler"))
+
+
+synPropsSec = nixFile.create_section("Synapse Models", "Model Parameters")
+
+if DLInt1SynapsePropsE:
+
+    JODLInt1SynESec = synPropsSec.create_section("JODLInt1Exi", "DoubleExpSyn")
+    JODLInt1SynEDict = getattr(synapsePropsList, DLInt1SynapsePropsE)
+
+    for propName, propVal in JODLInt1SynEDict.items():
+        addBrianQuantity2Section(JODLInt1SynESec, propName, propVal)
+
+    JODLInt1SynESec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
+    JODLInt1SynESec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
+
+
+if DLInt1SynapsePropsI:
+
+    JODLInt1SynISec = synPropsSec.create_section("JODLInt1Inh", "DoubleExpSyn")
+    JODLInt1SynIDict = getattr(synapsePropsList, DLInt1SynapsePropsI)
+
+    for propName, propVal in JODLInt1SynIDict.items():
+        addBrianQuantity2Section(JODLInt1SynISec, propName, propVal)
+    JODLInt1SynISec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
+    JODLInt1SynISec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
+
+blk = nixFile.create_block("Simulation Traces", "Brian Output")
+DLInt1DA = addAnalogSignal2Block(blk, dlint1MemVAS)
+inputDA = addAnalogSignal2Block(blk, inputAS)
+if DLInt1SynapsePropsE:
+    epscAS = addAnalogSignal2Block(blk, iSynEAS)
+if DLInt1SynapsePropsI:
+    ipscAS = addAnalogSignal2Block(blk, iSynIAS)
+
+addMultiTag("DLInt1 Spikes", type="Spikes", positions=dlint1SpikesQU,
+            blk=blk, refs=[DLInt1DA])
+addMultiTag("JO Spikes", type="Spikes", positions=joSpikesQU,
+            blk=blk, refs=[inputDA])
+
+nixFile.close()

+ 81 - 0
DLInt2try.py

@@ -0,0 +1,81 @@
+import os
+import shutil
+
+import seaborn as sns
+from brian2 import defaultclock, units
+from brian2.core.network import Network
+from matplotlib import pyplot as plt
+
+from dirDefs import homeFolder
+from models.neuronModels import VSNeuron, JOSpikes265, getSineInput
+from mplPars import mplPars
+from paramLists import synapsePropsList, inputParsList
+
+sns.set(style="whitegrid", rc=mplPars)
+
+
+simSettleTime = 500 * units.ms
+
+simStepSize = 0.5 * units.ms
+simDuration = 100 * units.ms
+# inputParsName = 'onePulse'
+# inputParsName = 'twoPulse'
+inputParsName = 'threePulse'
+
+
+# simStepSize = 0.5 * units.ms
+# simDuration = 1100 * units.ms
+# # inputParsName = 'oneSecondPulse'
+# # inputParsName = 'pulseTrainInt20Dur10'
+# inputParsName = 'pulseTrainInt20Dur16'
+# # inputParsName = 'pulseTrainInt33Dur10'
+# # inputParsName = 'pulseTrainInt33Dur16'
+
+NeuronProps = "DLInt2Try2"
+NeuronSynapseProps = 'DLInt2_syn_try2'
+dlint2 = VSNeuron(NeuronProps)
+
+opDir = os.path.join(homeFolder, NeuronProps, NeuronSynapseProps, inputParsName)
+if os.path.isdir(opDir):
+    ch = input('Results already exist at {}. Delete?(y/n):'.format(opDir))
+    if ch == 'y':
+        shutil.rmtree(opDir)
+os.makedirs(opDir)
+
+period265 = (1 / 265)
+inputPars = getattr(inputParsList, inputParsName)
+JO = JOSpikes265(nOutputs=1, simSettleTime=simSettleTime, **inputPars)
+dlint2.addExp2Synapses(name='JO', nSyn=1, sourceNG=JO.JOSGG,
+                       sourceInd=0,
+                       **getattr(synapsePropsList, NeuronSynapseProps))
+net = Network()
+net.add(JO.JOSGG)
+dlint2.addToNetwork(net)
+defaultclock.dt = simStepSize
+totalSimDur = simDuration + simSettleTime
+net.run(totalSimDur, report='text')
+
+simT, memV = dlint2.getMemVTrace()
+spikeTimes = dlint2.getSpikes()
+fig, axs = plt.subplots(nrows=2, figsize=(10, 6.25), sharex='col')
+axs[0].plot(simT / units.ms, memV / units.mV)
+spikesY = memV.min() + 1.05 * (memV.max() - memV.min())
+axs[0].plot(spikeTimes / units.ms, [spikesY / units.mV] * spikeTimes.shape[0], 'k^')
+axs[0].set_ylabel('DLInt1 \nmemV (mV)')
+axs[0].set_xlim([simSettleTime / units.ms - 50, totalSimDur / units.ms + 50])
+
+sineInput = getSineInput(simSettleTime=simSettleTime, simDur=simDuration,
+                         simStepSize=simStepSize,
+                         sinPulseDurs=inputPars['sinPulseDurs'],
+                         sinPulseStarts=inputPars['sinPulseStarts'],
+                         freq=265 * units.Hz)
+axs[1].plot(simT / units.ms, sineInput, 'r-', label='Vibration Input')
+axs[1].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
+        label='JO Spikes')
+axs[1].legend(loc='upper right')
+axs[1].set_xlabel('time (ms)')
+axs[1].set_ylabel('Vibration \nInput/JO\n Spikes')
+fig.tight_layout()
+fig.canvas.draw()
+# plt.show()
+fig.savefig(os.path.join(opDir, 'Traces.png'), dpi=150)

+ 254 - 0
JODLInt1DLInt2.py

@@ -0,0 +1,254 @@
+import os
+import sys
+
+import seaborn as sns
+from brian2 import defaultclock, units
+from brian2.core.network import Network
+from brian2.units.fundamentalunits import Quantity
+from matplotlib import pyplot as plt
+
+from dirDefs import homeFolder
+from models.neuronModels import VSNeuron, JOSpikes265, getSineInput
+from mplPars import mplPars
+from paramLists import synapsePropsList, inputParsList, AdExpPars
+from models.synapses import exp2SynStateInits, exp2Syn
+from models.neurons import AdExp
+
+from neo import AnalogSignal, SpikeTrain
+import nixio
+from neoNIXIO import addAnalogSignal2Block, addMultiTag
+import quantities as qu
+from brianUtils import addBrianQuantity2Section
+
+
+def runJODLInt1DLInt2(simStepSize: Quantity, simDuration: Quantity, simSettleTime: Quantity,
+                      inputParsName: str, showBefore: Quantity, showAfter: Quantity,
+                      DLInt1ModelProps: str, DLInt2ModelProps: str,
+                      DLInt1SynapsePropsE: str, DLInt1SynapsePropsI: str,
+                      DLInt2SynapseProps: str, DLInt1DLInt2SynProps: str,
+                      askReplace=True):
+
+    sns.set(style="whitegrid", rc=mplPars)
+
+    DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+    opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
+                         inputParsName)
+    opFile = os.path.join(opDir, 'Traces.png')
+    OPNixFile = os.path.join(opDir, 'SimResults.h5')
+
+    if askReplace:
+        if os.path.isfile(opFile):
+            ch = input('Results already exist at {}. Delete?(y/n):'.format(opFile))
+            if ch == 'y':
+                os.remove(opFile)
+                if os.path.isfile(OPNixFile):
+                    os.remove(OPNixFile)
+            else:
+                sys.exit('User Abort!')
+
+        elif not os.path.isdir(opDir):
+            os.makedirs(opDir)
+    else:
+        if os.path.isfile(opFile):
+            os.remove(opFile)
+            if os.path.isfile(OPNixFile):
+                os.remove(OPNixFile)
+
+        elif not os.path.isdir(opDir):
+            os.makedirs(opDir)
+
+    inputPars = getattr(inputParsList, inputParsName)
+
+
+    net = Network()
+    JO = JOSpikes265(nOutputs=1, simSettleTime=simSettleTime, **inputPars)
+    net.add(JO.JOSGG)
+
+    DLInt1PropsDict = getattr(AdExpPars, DLInt1ModelProps)
+    dlint1 = VSNeuron(**AdExp, inits=DLInt1PropsDict, name='dlint1')
+    dlint1.recordSpikes()
+    dlint1.recordMembraneV()
+
+    if DLInt1SynapsePropsE:
+        dlint1.addSynapse(synName="ExiJO", sourceNG=JO.JOSGG, **exp2Syn,
+                              synParsInits=getattr(synapsePropsList, DLInt1SynapsePropsE),
+                              synStateInits=exp2SynStateInits,
+                              sourceInd=0, destInd=0
+                              )
+    if DLInt1SynapsePropsI:
+        dlint1.addSynapse(synName="InhJO", sourceNG=JO.JOSGG, **exp2Syn,
+                              synParsInits=getattr(synapsePropsList, DLInt1SynapsePropsI),
+                              synStateInits=exp2SynStateInits,
+                              sourceInd=0, destInd=0
+                              )
+
+    dlint1.addToNetwork(net)
+
+    DLInt2PropsDict = getattr(AdExpPars, DLInt2ModelProps)
+    dlint2 = VSNeuron(**AdExp, inits=DLInt2PropsDict, name='dlint2')
+    dlint2.recordMembraneV()
+    dlint2.recordSpikes()
+
+    if DLInt2SynapseProps:
+        dlint2.addSynapse(synName="JOExi", sourceNG=JO.JOSGG, **exp2Syn,
+                              synParsInits=getattr(synapsePropsList, DLInt2SynapseProps),
+                              synStateInits=exp2SynStateInits,
+                              sourceInd=0, destInd=0
+                              )
+
+    if DLInt1DLInt2SynProps:
+        dlint2.addSynapse(synName="DLInt1", sourceNG=dlint1.ng, **exp2Syn,
+                              synParsInits=getattr(synapsePropsList, DLInt1DLInt2SynProps),
+                              synStateInits=exp2SynStateInits,
+                              sourceInd=0, destInd=0
+                              )
+
+
+    dlint2.addToNetwork(net)
+    defaultclock.dt = simStepSize
+    totalSimDur = simDuration + simSettleTime
+    net.run(totalSimDur, report='text')
+
+    simT, DLInt1_memV = dlint1.getMemVTrace()
+    DLInt1_spikeTimes = dlint1.getSpikes()
+    fig, axs = plt.subplots(nrows=3, figsize=(10, 6.25), sharex='col')
+    axs[0].plot(simT / units.ms, DLInt1_memV / units.mV)
+    spikesY = DLInt1_memV.min() + 1.05 * (DLInt1_memV.max() - DLInt1_memV.min())
+    axs[0].plot(DLInt1_spikeTimes / units.ms, [spikesY / units.mV] * DLInt1_spikeTimes.shape[0], 'k^')
+    axs[0].set_ylabel('DLInt1 \nmemV (mV)')
+    axs[0].set_xlim([(simSettleTime - showBefore) / units.ms,
+                     (totalSimDur + showAfter) / units.ms])
+
+    simT, DLInt2_memV = dlint2.getMemVTrace()
+    DLInt2_spikeTimes = dlint2.getSpikes()
+    axs[1].plot(simT / units.ms, DLInt2_memV / units.mV)
+    spikesY = DLInt2_memV.min() + 1.05 * (DLInt2_memV.max() - DLInt2_memV.min())
+    axs[1].plot(DLInt2_spikeTimes / units.ms, [spikesY / units.mV] * DLInt2_spikeTimes.shape[0], 'k^')
+    axs[1].set_ylabel('DLInt2 \nmemV (mV)')
+
+    sineInput = getSineInput(simDur=simDuration, simStepSize=simStepSize,
+                             sinPulseDurs=inputPars['sinPulseDurs'],
+                             sinPulseStarts=inputPars['sinPulseStarts'],
+                             freq=265 * units.Hz, simSettleTime=simSettleTime)
+    axs[2].plot(simT / units.ms, sineInput, 'r-', label='Vibration Input')
+    axs[2].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
+            label='JO Spikes')
+    axs[2].legend(loc='upper right')
+    axs[2].set_xlabel('time (ms)')
+    axs[2].set_ylabel('Vibration \nInput/JO\n Spikes')
+    fig.tight_layout()
+    fig.canvas.draw()
+    fig.savefig(opFile, dpi=150)
+    plt.close(fig.number)
+    del fig
+
+    dlint1MemVAS = AnalogSignal(signal=DLInt1_memV /units.mV,
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
+                                t_start=0 * qu.mV,
+                                units="mV",
+                                name="DLInt1 MemV")
+    dlint2MemVAS = AnalogSignal(signal=DLInt2_memV / units.mV,
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
+                                t_start=0 * qu.mV,
+                                units="mV",
+                                name="DLInt2 MemV")
+    inputAS = AnalogSignal(signal=sineInput,
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
+                                t_start=0 * qu.mV,
+                                units="um",
+                                name="Input Vibration Signal")
+    dlint1SpikesQU = (DLInt1_spikeTimes / units.ms) * qu.ms
+    dlint2SpikesQU = (DLInt2_spikeTimes / units.ms) * qu.ms
+    joSpikesQU = (JO.spikeTimes / units.ms) * qu.ms
+
+    nixFile = nixio.File.open(OPNixFile, mode=nixio.FileMode.ReadWrite)
+
+    neuronModels = nixFile.create_section("Neuron Models", "Model Parameters")
+
+
+    DLInt1PropsSec = neuronModels.create_section("DL-Int-1", "AdExp")
+
+    for propName, propVal in DLInt1PropsDict.items():
+        addBrianQuantity2Section(DLInt1PropsSec, propName, propVal)
+
+    DLInt2PropsSec = neuronModels.create_section("DL-Int-2", "AdExp")
+
+    for propName, propVal in DLInt2PropsDict.items():
+        addBrianQuantity2Section(DLInt2PropsSec, propName, propVal)
+
+    inputSec = nixFile.create_section("Input Parameters", "Sinusoidal Pulses")
+
+    for parName, parVal in inputPars.items():
+        addBrianQuantity2Section(inputSec, parName, parVal)
+
+    addBrianQuantity2Section(inputSec, "simSettleTime", simSettleTime)
+
+    brianSimSettingsSec = nixFile.create_section("Simulation Parameters", "Brian Simulation")
+    addBrianQuantity2Section(brianSimSettingsSec, "simStepSize", simStepSize)
+    addBrianQuantity2Section(brianSimSettingsSec, "totalSimDuration", totalSimDur)
+    brianSimSettingsSec.create_property("method", nixio.Value("euler"))
+
+
+    synPropsSec = nixFile.create_section("Synapse Models", "Model Parameters")
+
+    if DLInt1SynapsePropsE:
+
+        JODLInt1SynESec = synPropsSec.create_section("JODLInt1Exi", "DoubleExpSyn")
+        JODLInt1SynEDict = getattr(synapsePropsList, DLInt1SynapsePropsE)
+
+        for propName, propVal in JODLInt1SynEDict.items():
+            addBrianQuantity2Section(JODLInt1SynESec, propName, propVal)
+
+        JODLInt1SynESec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
+        JODLInt1SynESec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
+
+
+    if DLInt1SynapsePropsI:
+
+        JODLInt1SynISec = synPropsSec.create_section("JODLInt1Inh", "DoubleExpSyn")
+        JODLInt1SynIDict = getattr(synapsePropsList, DLInt1SynapsePropsI)
+
+        for propName, propVal in JODLInt1SynIDict.items():
+            addBrianQuantity2Section(JODLInt1SynISec, propName, propVal)
+        JODLInt1SynISec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
+        JODLInt1SynISec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
+
+    if DLInt2SynapseProps:
+
+        JODLInt2SynESec = synPropsSec.create_section("JODLInt2Exi", "DoubleExpSyn")
+        JODLInt2SynEDict = getattr(synapsePropsList, DLInt2SynapseProps)
+
+        for propName, propVal in JODLInt2SynEDict.items():
+            addBrianQuantity2Section(JODLInt2SynESec, propName, propVal)
+        JODLInt2SynESec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
+        JODLInt2SynESec.create_property("PostSynaptic Neuron", nixio.Value("DLInt2"))
+
+    if DLInt1DLInt2SynProps:
+
+        DLInt1DLInt2SynSec = synPropsSec.create_section("DLInt1DLInt2Inh", "DoubleExpSyn")
+        DLInt1DLInt2SynDict = getattr(synapsePropsList, DLInt1DLInt2SynProps)
+
+        for propName, propVal in DLInt1DLInt2SynDict.items():
+            addBrianQuantity2Section(DLInt1DLInt2SynSec, propName, propVal)
+        DLInt1DLInt2SynSec.create_property("PreSynaptic Neuron", nixio.Value("DLInt1"))
+        DLInt1DLInt2SynSec.create_property("PostSynaptic Neuron", nixio.Value("DLInt2"))
+
+
+    blk = nixFile.create_block("Simulation Traces", "Brian Output")
+    DLInt1DA = addAnalogSignal2Block(blk, dlint1MemVAS)
+    DLInt2DA = addAnalogSignal2Block(blk, dlint2MemVAS)
+    inputDA = addAnalogSignal2Block(blk, inputAS)
+    addMultiTag("DLInt1 Spikes", type="Spikes", positions=dlint1SpikesQU,
+                blk=blk, refs=[DLInt1DA])
+    addMultiTag("DLInt2 Spikes", type="Spikes", positions=dlint2SpikesQU,
+                blk=blk, refs=[DLInt2DA])
+    addMultiTag("JO Spikes", type="Spikes", positions=joSpikesQU,
+                blk=blk, refs=[inputDA])
+
+
+    nixFile.close()
+
+
+

+ 99 - 0
LICENSE-CCBY

@@ -0,0 +1,99 @@
+Creative Commons Attribution 4.0 International Public License
+
+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.
+
+Section 1 – Definitions.
+
+    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.
+    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.
+    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.
+    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.
+    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.
+    Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
+    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.
+    Licensor means the individual(s) or entity(ies) granting rights under this Public License.
+    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.
+    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.
+    You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
+
+Section 2 – Scope.
+
+    License grant.
+        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:
+            reproduce and Share the Licensed Material, in whole or in part; and
+            produce, reproduce, and Share Adapted Material.
+        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.
+        Term. The term of this Public License is specified in Section 6(a).
+        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.
+        Downstream recipients.
+            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.
+            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.
+        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).
+
+    Other rights.
+        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.
+        Patent and trademark rights are not licensed under this Public License.
+        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.
+
+Section 3 – License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the following conditions.
+
+    Attribution.
+
+        If You Share the Licensed Material (including in modified form), You must:
+            retain the following if it is supplied by the Licensor with the Licensed Material:
+                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);
+                a copyright notice;
+                a notice that refers to this Public License;
+                a notice that refers to the disclaimer of warranties;
+                a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
+            indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
+            indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
+        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.
+        If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
+        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.
+
+Section 4 – Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
+
+    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;
+    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
+    You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
+
+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.
+
+Section 5 – Disclaimer of Warranties and Limitation of Liability.
+
+    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.
+    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.
+
+    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.
+
+Section 6 – Term and Termination.
+
+    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.
+
+    Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
+        automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
+        upon express reinstatement by the Licensor.
+    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.
+    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.
+    Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
+
+Section 7 – Other Terms and Conditions.
+
+    The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
+    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.
+
+Section 8 – Interpretation.
+
+    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.
+    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.
+    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.
+    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.
+
+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.
+
+Creative Commons may be contacted at creativecommons.org.

+ 73 - 0
Readme.md

@@ -0,0 +1,73 @@
+This repository contains the code used for the following manuscript:
+
+
+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
+
+Authors:
+Ajayrama Kumaraswamy, ajkumaraswamy@tutamail.com
+Based on and contains parts of work by Aynur Maksutov during AMGEN program 2016 at Wachtlerlab, LMU.
+
+Installation:
+
+With anaconda (recommended):
+
+    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
+    2. source activate Ai2017Sim (unix) or activate Ai2017Sim (windows)
+    3. pip install <full path of this repository>
+
+without anaconda, normal python installation required (https://www.python.org/)
+
+    1. Install virtualenvwrapper (unix) or virtualenvwrapper-win (windows) be pre-installed with pip
+    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
+    3. mkvirtualenv Ai2017Sim
+    4. pip install <full path of this repository>
+
+Usage:
+    1. source activate Ai2017Sim (unix) or activate Ai2017Sim (windows)
+    2. Change the variable homeFolder in dirDefs.py to a folder. The results of the simulation will be stored here.
+    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.
+
+
+Here is an overview of the contents:
+
+.  
++-- Ai2017Sim.yml: A file that can be used to create a conda environment to run the scripts below. Essentially is a list of dependencies.
++-- models
+|   +-- neuronModels.py: wrapper classes for brian2 neuron models
+|   +-- neurons.py: Model equations and static parameters for neurons  
+|   +-- synapses.py: Model equations for synapses  
+|  
++-- paramLists  
+|   +-- AdExpPars.py: Parameter combinations for the AdExp model  
+|   +-- inputParsList.py: Stimulii definitions  
+|   +-- synapsePropsList.py: Parameter combinations for the difference of exponential synaptic conductance model  
+|  
++-- brianUtils.py: utility function related to brian2  
+|  
++-- dirDefs.py: directory definitions imported in other scripts  
+|  
++-- DLInt1SynCurrent.py: Script to simulate DL-Int-1 recording membrane potential and synaptic currents in [NIX](https://github.com/G-Node/nixpy) files  
+|  
++-- DLInt2try.py: Legacy code  
+|  
++-- forAi2017.py: Script to generate a subplot of an upcoming manuscript.  
+|  
++-- JODLInt1DLInt2: Class to run network simulations  
+|  
++-- justDLInt1.py: Legacy code  
+|  
++-- mplPars.py: matplotlib rc parameters  
+|  
++-- 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).  
+|  
++-- plotDLInt1DLInt2SynEffects.py: script to plot summary of DL-Int-1 and DL-Int-2 responses to pulse trains.  
+|  
++-- plotShortStims.py: script to plot summary of DL-Int-1 and DL-Int-2 responses to short continuous pulses.  
+|  
++-- plotSynCurrents.py: script to plot membrane potential and synaptic currents of DL-Int-1 and DL-Int-2 for one stimulus.  
+|  
++-- runJODLInt1DLInt2Multiple.py: script to simulate the network for multiple stimulii. Out is saved as a [NIX](https://github.com/G-Node/nixpy) File.  
+|  
++-- 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.  
+
+

+ 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 @@
+import numpy as np
+from brian2.units.fundamentalunits import Quantity
+import nixio
+
+def getSimT(simDur: Quantity, simStepSize: Quantity) -> Quantity:
+
+    return np.arange(simDur / simStepSize) * simStepSize
+
+def addBrianQuantity2Section(sec: nixio.pycore.Section,
+                             name: str, qu: Quantity) -> nixio.pycore.Property:
+    propStr = qu.in_best_unit()
+
+    if qu.shape == ():
+
+        propFloatStr, propUnit = propStr.split(" ")
+        propFloat = float(propFloatStr)
+
+        pr = sec.create_property(name, [nixio.Value(propFloat)])
+
+    elif len(qu.shape) == 1:
+
+        propFloatStr, propUnit = propStr.split("] ")
+        values = list(map(float, propFloatStr[2:].split()))
+        pr = sec.create_property(name, [nixio.Value(val) for val in values])
+
+    else:
+        raise(ValueError("Only scalar or 1D Brian Quantities as supported"))
+
+    pr.unit = propUnit
+
+    return pr

+ 7 - 0
butest.py

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

+ 3 - 0
dirDefs.py

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

+ 150 - 0
forAi2017.py

@@ -0,0 +1,150 @@
+import nixio
+from dirDefs import homeFolder
+import os
+import seaborn as sns
+from mplPars import mplPars
+from brian2 import units
+from matplotlib import pyplot as plt
+from neoNIXIO import multiTag2SpikeTrain, dataArray2AnalogSignal, \
+    simpleFloat, property2qu
+import quantities as qu
+from neo import AnalogSignal
+
+mplPars['xtick.labelsize'] = 10
+mplPars['ytick.labelsize'] = 10
+mplPars["text.usetex"] = False
+mplPars["font.sans-serif"] = "Arial"
+mplPars["axes.linewidth"] = 1
+sns.set(style="ticks", rc=mplPars)
+
+
+simSettleTime = 600 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 150 * units.ms
+# # inputParsName = 'onePulse'
+# # inputParsName = 'twoPulse'
+# # inputParsName = 'threePulse'
+# inputParsName = "fortyMSPulse"
+# showBefore = 50 * units.ms
+# showAfter = 50 * units.ms
+
+simStepSize = 0.1 * units.ms
+simDuration = 450 * units.ms
+inputParsName = "pTShortInt33Dur16"
+# inputParsName = "pTShortInt100Dur16"
+
+showBefore = 75 * units.ms
+showAfter = -30 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 1500 * units.ms
+# # inputParsName = 'oneSecondPulse'
+# # inputParsName = 'pulseTrainInt20Dur10'
+# inputParsName = 'pulseTrainInt20Dur16'
+# # inputParsName = 'pulseTrainInt33Dur10'
+# # inputParsName = 'pulseTrainInt33Dur16'
+# showBefore = 500 * units.ms
+# showAfter = 500 * units.ms
+
+DLInt1ModelProps = "DLInt1Aynur"
+
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
+# DLInt1SynapsePropsE = ""
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
+# DLInt1SynapsePropsI = ""
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+DLInt2ModelProps = "DLInt2Try2"
+
+DLInt2SynapseProps = 'DLInt2_syn_try2'
+
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
+
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
+                         inputParsName)
+OPNixFile = os.path.join(opDir, 'simResults.h5')
+
+
+totalSimDur = simDuration + simSettleTime
+
+nixFile = nixio.File.open(OPNixFile, nixio.FileMode.ReadOnly)
+
+inputSec = nixFile.sections["Input Parameters"]
+simSettleTimeQu = property2qu(inputSec.props["simSettleTime"])
+
+blk = nixFile.blocks["Simulation Traces"]
+dlint1MemV = blk.data_arrays["DLInt1 MemV"]
+dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
+dlint2MemV = blk.data_arrays["DLInt2 MemV"]
+dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
+sinInput = blk.data_arrays["Input Vibration Signal"]
+joSpikesMT = blk.multi_tags["JO Spikes"]
+
+dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
+dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
+temp = dataArray2AnalogSignal(sinInput)
+sinInputAS = AnalogSignal(signal=15 * temp.magnitude,
+                          units=temp.units,
+                          t_start=temp.t_start,
+                          sampling_period=temp.sampling_period)
+sinInputAS = sinInputAS.reshape((sinInputAS.shape[0],))
+dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+
+# fig0, ax0 = plt.subplots(figsize=(2.5, 1.5))
+# fig1, ax1 = plt.subplots(figsize=(2.5, 1.5))
+# fig2, ax2 = plt.subplots(figsize=(2.5, 1.75))
+#
+fig0, ax0 = plt.subplots(figsize=(2.85, 1.5))
+fig1, ax1 = plt.subplots(figsize=(2.85, 1.5))
+fig2, ax2 = plt.subplots(figsize=(2.85, 1.75))
+
+ax0.plot(simpleFloat((dlint1MemVAS.times - simSettleTimeQu) / qu.ms),
+         simpleFloat(dlint1MemVAS / qu.mV), 'k-', lw=0.4)
+ax1.plot(simpleFloat((dlint2MemVAS.times - simSettleTimeQu) / qu.ms),
+         simpleFloat(dlint2MemVAS / qu.mV), 'k-', lw=0.4)
+ax2.plot(simpleFloat((sinInputAS.times - simSettleTimeQu) / qu.ms),
+         simpleFloat(sinInputAS / qu.um), 'k-', lw=0.4)
+
+for ax in [ax0, ax1, ax2]:
+    ax.set_xlim([(-showBefore) / units.ms,
+                     (simDuration + showAfter) / units.ms])
+    # ax.yaxis.tick_right()
+    ax.set_xticks([])
+    ax.set_ylim([-50, 5])
+    ax.set_yticks([-40, -20, 0])
+    # ax.set_yticks([])
+
+
+for ax in [ax0, ax1]:
+    markerline, stemlines, baseline \
+        = ax.stem(simpleFloat((joSpikesST.times - simSettleTimeQu) / qu.ms),
+                      [-42] * joSpikesST.shape[0],
+                      linefmt='k-', markerfmt='None', basefmt='None',
+                      bottom=-50)
+    plt.setp(stemlines, lw=0.4)
+
+
+markerline, stemlines, baseline \
+        = ax2.stem(simpleFloat((joSpikesST.times - simSettleTimeQu) / qu.ms),
+                      [25] * joSpikesST.shape[0],
+                      linefmt='k-', markerfmt='None', basefmt='None',
+                      bottom=17)
+plt.setp(stemlines, lw=0.5)
+ax2.set_ylim([-20, 25])
+ax2.set_xticks([0, 100, 200, 300])
+
+for fig in [fig0, fig1, fig2]:
+
+    fig.tight_layout()
+
+fig0.savefig(os.path.join(opDir, "DL-Int-1MemV.svg"), dpi=300,
+             bbox_inches='tight', transparent=True)
+fig1.savefig(os.path.join(opDir, "DL-Int-2MemV.svg"), dpi=300,
+             bbox_inches='tight', transparent=True)
+fig2.savefig(os.path.join(opDir, "InputSignal.svg"), dpi=300,
+             bbox_inches='tight', transparent=True)
+

+ 130 - 0
justDLInt1.py

@@ -0,0 +1,130 @@
+import os
+import sys
+
+import seaborn as sns
+from brian2 import defaultclock, units
+from matplotlib import pyplot as plt
+from brian2.core.network import Network
+from dirDefs import homeFolder
+from models.neuronModels import VSNeuron, JOSpikes265, getSineInput
+from models.neurons import AdExp
+from models.synapses import exp2Syn, exp2SynStateInits
+from mplPars import mplPars
+from paramLists import synapsePropsList, inputParsList, AdExpPars
+
+sns.set(style="whitegrid", rc=mplPars)
+
+
+simSettleTime = 600 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 150 * units.ms
+# # inputParsName = 'onePulse'
+# # inputParsName = 'twoPulse'
+# # inputParsName = 'threePulse'
+# # inputParsName = "tenMSPulse"
+# # inputParsName = "twentyMSPulse"
+# # inputParsName = "thirtyMSPulse"
+# inputParsName = "fortyMSPulse"
+# # inputParsName = "fiftyMSPulse"
+# showBefore = 50 * units.ms
+# showAfter = 10 * units.ms
+
+
+simStepSize = 0.1 * units.ms
+simDuration = 1500 * units.ms
+# inputParsName = 'pulseTrainInt20Dur10'
+# inputParsName = 'pulseTrainInt20Dur16'
+# inputParsName = 'pulseTrainInt33Dur16'
+# inputParsName = 'pulseTrainInt33Dur10'
+# inputParsName = 'oneSecondPulse'
+# inputParsName = 'pulseTrainInt50Dur10'
+inputParsName = 'pulseTrainInt50Dur16'
+# inputParsName = 'pulseTrainInt50Dur20'
+showBefore = 500 * units.ms
+showAfter = 500 * units.ms
+
+DLInt1ModelProps = "DLInt1Aynur"
+dlint1 = VSNeuron(**AdExp, inits=getattr(AdExpPars, DLInt1ModelProps), name='dlint1')
+dlint1.recordMembraneV()
+dlint1.recordSpikes()
+
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
+# DLInt1SynapsePropsE = ""
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
+# DLInt1SynapsePropsI = ""
+DLInt1SynapseProps = "-".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+
+# opDir = os.path.join(homeFolder, DLInt1ModelProps, DLInt1SynapseProps, inputParsName)
+opDir = "/tmp/justDLInt1"
+
+opFile = os.path.join(opDir, 'Traces.png')
+if os.path.isfile(opFile):
+    ch = input('Results already exist at {}. Delete?(y/n):'.format(opFile))
+    if ch == 'y':
+        os.remove(opFile)
+    else:
+        sys.exit('User Abort!')
+
+elif not os.path.isdir(opDir):
+    os.makedirs(opDir)
+
+inputPars = getattr(inputParsList, inputParsName)
+
+JO = JOSpikes265(nOutputs=1, simSettleTime=simSettleTime, **inputPars)
+
+
+if DLInt1SynapsePropsE:
+    dlint1.addSynapse(synName="ExiJO", sourceNG=JO.JOSGG, **exp2Syn,
+                      synParsInits=getattr(synapsePropsList, DLInt1SynapsePropsE),
+                      synStateInits=exp2SynStateInits,
+                      sourceInd=0, destInd=0
+                      )
+if DLInt1SynapsePropsI:
+    dlint1.addSynapse(synName="InhJO", sourceNG=JO.JOSGG, **exp2Syn,
+                      synParsInits=getattr(synapsePropsList, DLInt1SynapsePropsI),
+                      synStateInits=exp2SynStateInits,
+                      sourceInd=0, destInd=0
+                      )
+
+net = Network()
+net.add(JO.JOSGG)
+dlint1.addToNetwork(net)
+defaultclock.dt = simStepSize
+totalSimDur = simDuration + simSettleTime
+net.run(totalSimDur, report='text')
+
+simT, memV = dlint1.getMemVTrace()
+spikeTimes = dlint1.getSpikes()
+
+
+fig, axs = plt.subplots(nrows=2, figsize=(10, 6.25), sharex='col')
+axs[0].plot(simT / units.ms, memV / units.mV)
+spikesY = memV.min() + 1.05 * (memV.max() - memV.min())
+axs[0].plot(spikeTimes / units.ms, [spikesY / units.mV] * spikeTimes.shape[0], 'k^')
+axs[0].set_ylabel('DLInt1 \nmemV (mV)')
+axs[0].set_xlim([(simSettleTime - showBefore) / units.ms,
+                 (totalSimDur + showAfter) / units.ms])
+sineInput = getSineInput(simDur=simDuration, simStepSize=simStepSize,
+                         sinPulseDurs=inputPars['sinPulseDurs'],
+                         sinPulseStarts=inputPars['sinPulseStarts'],
+                         freq=265 * units.Hz, simSettleTime=simSettleTime)
+axs[1].plot(simT / units.ms, sineInput, 'r-', label='Vibration Input')
+axs[1].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
+        label='JO Spikes')
+axs[1].legend(loc='upper right')
+axs[1].set_xlabel('time (ms)')
+axs[1].set_ylabel('Vibration \nInput/JO\n Spikes')
+fig.tight_layout()
+fig.canvas.draw()
+# plt.show()
+fig.savefig(opFile, dpi=150)
+
+
+
+
+
+
+
+

+ 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 @@
+from copy import copy
+from typing import Union, Iterable
+
+import numpy as np
+from brian2 import NeuronGroup, TimedArray, StateMonitor, SpikeMonitor, SpikeGeneratorGroup, array
+from brian2 import Synapses
+from brian2 import units
+from brian2.core.network import Network
+from brian2.equations.codestrings import CodeString
+from brian2.equations.equations import Equations
+from brian2.units.fundamentalunits import Quantity
+
+from brianUtils import getSimT
+
+def addSynNameVar(var: str, name: str) -> str:
+
+    return "_".join([var, name])
+
+def addSynNameEqs(model: str, prePosts: Iterable[Union[str, None]], synName: str) -> tuple:
+
+    mEq = Equations(model)
+    newM = copy(model)
+    for name in mEq.names:
+        if (not name.endswith("_post")) and (not name.endswith("_pre")):
+            newM = newM.replace(name, addSynNameVar(name, synName))
+
+
+    newPrePosts = []
+    prePostCSs = []
+    for p in prePosts:
+        newP = copy(p)
+        if p:
+            cs = CodeString(p)
+            for name in cs.identifiers:
+                if (not name.endswith("_post")) and (not name.endswith("_pre")):
+                    newP = newP.replace(name, addSynNameVar(name, synName))
+            newPrePosts.append(newP)
+            prePostCSs.append(cs)
+        else:
+            newPrePosts.append(None)
+            prePostCSs.append(None)
+
+    return newM, mEq, newPrePosts, prePostCSs
+
+
+class VSNeuron(object):
+
+    def __init__(self, model: str, name: str,
+                 inits: dict,
+                 threshold: str,
+                 reset: str,
+                 method: str = "euler"):
+
+        super().__init__()
+        self.ngParams = {"model": model, "threshold": threshold, "reset": reset, "method": method,
+                         "name": name}
+        self.inits = inits
+        self.incomingSynapses = {}
+        self.incomingSynapsePars = {}
+        self.synCurrentNames = []
+        self.recordMemVFlag = False
+        self.recordSpikesFlag = False
+        self.ng = None
+
+    def updateInits(self, initUpdate: dict):
+
+        self.inits.update(initUpdate)
+
+    def setInputCurrent(self, I: Union[TimedArray, float]):
+        self.inits["I"] = I
+
+    def recordMembraneV(self):
+
+        self.recordMemVFlag = True
+
+    def recordSpikes(self):
+
+        self.recordSpikesFlag = True
+
+    def getMemVTrace(self):
+
+        assert self.recordMemVFlag, 'Membrane Voltage was not recorded' \
+                                            'for this neuron'
+        return self.memVRecord.t, self.memVRecord[0].V
+
+    def getSpikes(self):
+
+        assert self.recordSpikesFlag, "Spikes were not recorded for this neuron"
+
+        return self.spikeRecord.t
+
+    def addToNetwork(self, network: Network):
+
+        self.ngParams["model"] = "\n".join((self.ngParams["model"], "Iext: amp"))
+        self.inits["Iext"] = 0 * units.amp
+        eq2Add = "I = Iext "
+
+        for synCurrentName in self.synCurrentNames:
+
+            self.ngParams["model"] = "\n".join((self.ngParams["model"], "{} : amp".format(synCurrentName)))
+            self.inits[synCurrentName] = 0 * units.amp
+            eq2Add += " + {} ".format(synCurrentName)
+
+        eq2Add += ": amp"
+
+        self.ngParams["model"] = "\n".join((self.ngParams["model"], eq2Add))
+
+        self.ng = NeuronGroup(N=1, **self.ngParams)
+        self.initSim()
+        network.add(self.ng)
+        if self.recordMemVFlag:
+            self.memVRecord = StateMonitor(self.ng, "V", record=[0])
+            network.add(self.memVRecord)
+        if self.recordSpikesFlag:
+            self.spikeRecord = SpikeMonitor(self.ng)
+            network.add(self.spikeRecord)
+
+        for synName, synPars in self.incomingSynapsePars.items():
+
+            syn = Synapses(synPars["source"], self.ng,
+                           model=synPars["model"],
+                           on_pre=synPars["on_pre"],
+                           on_post=synPars["on_post"],
+                           method=synPars["method"])
+
+            syn.connect(i=synPars["sourceInd"], j=synPars["destInd"])
+
+            for k, v in synPars["initMap"].items():
+
+                setattr(syn, k, v)
+
+            self.incomingSynapses[synName] = syn
+            network.add(syn)
+
+
+    def initSim(self):
+
+        for k, v in self.inits.items():
+            setattr(self.ng, k, v)
+
+    def addSynapse(self, synName: str, sourceNG: NeuronGroup,
+                   model: str, synParsInits: dict, synStateInits: dict,
+                   on_pre: Union[str, None] = None,
+                   on_post: Union[str, None] = None,
+                   sourceInd: int = 0, destInd: int = 0,
+                   method: str = "euler"):
+
+
+        assert synName not in self.incomingSynapses, 'A Synapse with {} already exists'.format(synName)
+        ISyn_PostInd = model.find("ISyn_post")
+        assert ISyn_PostInd >= 0, "Synapse model should have an equation for" \
+                                            "\'ISyn_post\'"
+        nextEndLineInd = model.find("\n", ISyn_PostInd)
+        assert model[nextEndLineInd - 8: nextEndLineInd] == "(summed)", \
+            "Equation for \'ISyn_post\' must have (summed) flag"
+
+
+        newModel, mEq, [newOn_pre, newOn_post], prePostCSs = \
+            addSynNameEqs(model, [on_pre, on_post], synName)
+
+        allSV = mEq.diff_eq_names
+        allPars = list(mEq.parameter_names)
+
+
+        for cs in prePostCSs:
+            if cs:
+                for i in cs.identifiers:
+                    if i not in allSV:
+                        allPars.append(i)
+
+        for par in allPars:
+            assert par in synParsInits, "Initialization not provided for {} in synParsInits".format(par)
+
+        for sv in allSV:
+            assert sv in synStateInits, "Initialization not provided for {} in synStateInits".format(sv)
+
+        ISynName = "_".join(("ISyn", synName))
+        self.synCurrentNames.append(ISynName)
+
+        newModel = newModel.replace("ISyn", ISynName)
+
+        initMap = {"delay": synParsInits["delay"]}
+        for par in allPars:
+            initMap[addSynNameVar(par, synName)] = synParsInits[par]
+
+        for sv in allSV:
+            initMap[addSynNameVar(sv, synName)] = synStateInits[sv]
+
+        synPars = {"source": sourceNG, "model": newModel, "on_pre": newOn_pre,
+                   "on_post": newOn_post, "method": method,
+                   "sourceInd": sourceInd, "destInd": destInd, "initMap": initMap}
+
+        self.incomingSynapsePars[synName] = synPars
+
+
+
+
+class JOSpikes265(object):
+
+    def __init__(self, nOutputs: int =1, simSettleTime: Quantity = 0 * units.ms,
+                 sinPulseStarts: array = array(()) * units.ms,
+                 sinPulseDurs: array = array(()) * units.ms):
+
+        self.nOutputs = nOutputs
+        freq = 265 * units.Hz
+        spikePhase = np.deg2rad(240)
+        phaseDelay = (1 / freq) * (spikePhase / (2 * np.pi))
+        self.spikeTimes = []
+        self.spikeInds = []
+        simSettleTimeF = float(simSettleTime)
+
+        for start, dur in zip(sinPulseStarts, sinPulseDurs):
+
+            startF = float(start)
+            durF = float(dur)
+            periodF = float(1/freq)
+            phaseDelayF = float(phaseDelay)
+
+            cycleStarts = np.arange(startF, startF + durF, periodF)
+            for i in range(nOutputs):
+                self.spikeTimes += (simSettleTimeF + cycleStarts + phaseDelayF).tolist()
+                self.spikeInds += [i] * len(cycleStarts)
+
+        self.spikeTimes = self.spikeTimes * units.second
+        self.JOSGG = SpikeGeneratorGroup(nOutputs, array(self.spikeInds),
+                                         self.spikeTimes)
+
+def getSineInput(simDur: Quantity, simStepSize: Quantity,
+                 sinPulseStarts: Quantity, sinPulseDurs: Quantity,
+                 freq: Quantity, simSettleTime: Quantity = 0 * units.ms,):
+
+    simT = getSimT(simSettleTime + simDur, simStepSize)
+    sineInput = np.zeros(simT.shape)
+
+    for start, dur in zip(sinPulseStarts, sinPulseDurs):
+
+        settleStart = start + simSettleTime
+        settleEnd = start + dur + simSettleTime
+
+        timeMask = (simT >= settleStart) & (simT <= settleEnd)
+        sineInput[timeMask] = np.sin(2 * np.pi * freq * (simT[timeMask] - (0.5 / freq) - start))
+
+    return sineInput
+
+
+
+

+ 20 - 0
models/neurons.py

@@ -0,0 +1,20 @@
+AdExpEqs = "\n".join((
+    "Ex = gL*sF*exp( (V - Vt)/sF ) : amp",
+    "IL = gL*(EL - V) : amp",
+    "dV/dt = (I + IL + Ex - w)/C : volt",
+    "dw/dt = (a*(V - EL) - w)/tau : amp",
+    "Vt : volt",
+    "Vr : volt",
+    "b : amp",
+    "sF : volt",
+    "tau: second",
+    "EL : volt",
+    "gL : siemens",
+    "C : farad",
+    "a : siemens",
+    "Vp : volt"
+    ))
+
+AdExp = {"model": AdExpEqs,
+         "threshold": "V > Vp",
+         "reset": "V = Vr; w+=b"}

+ 22 - 0
models/synapses.py

@@ -0,0 +1,22 @@
+from brian2 import units
+
+exp2SynEqs = "\n".join((
+    "g = B - A: siemens",
+    "ISyn_post =  -g * (V_post - Esyn): amp (summed)",
+    "dB/dt = -B/tau2: siemens (clock-driven)",
+    "dA/dt = -A/tau1: siemens (clock-driven)",
+    "tau1: second",
+    "tau2: second",
+    "wSyn: siemens",
+    "Esyn: volt",
+    ))
+
+exp2Syn = {
+    "model": exp2SynEqs,
+    "on_pre": "A += wSyn\nB += wSyn",
+}
+
+exp2SynStateInits = {
+    "A": 0 * units.siemens,
+    "B": 0 * units.siemens
+}

+ 29 - 0
mplPars.py

@@ -0,0 +1,29 @@
+# mplPars = {'text.usetex': True,
+#            'axes.labelsize': 'large',
+#            'axes.titlesize': 24,
+#            'font.family': 'sans-serif',
+#            'font.sans-serif': 'computer modern roman',
+#            'font.size': 24,
+#            'font.weight': 'black',
+#            'xtick.labelsize': 20,
+#            'ytick.labelsize': 20,
+#            'legend.fontsize': 20,
+#            'legend.frameon': True,
+#            'legend.framealpha': 0,
+#            'legend.fancybox': True,
+#            'text.latex.preamble': r'\usepackage{cmbright}'
+#            }
+
+mplPars = {'axes.labelsize': 'large',
+           'axes.titlesize': 24,
+           'font.family': 'sans-serif',
+           'font.sans-serif': 'computer modern roman',
+           'font.size': 24,
+           'font.weight': 'black',
+           'xtick.labelsize': 20,
+           'ytick.labelsize': 20,
+           'legend.fontsize': 20,
+           'legend.frameon': True,
+           'legend.framealpha': 0,
+           'legend.fancybox': True,
+           }

+ 316 - 0
neoNIXIO.py

@@ -0,0 +1,316 @@
+# Ajayrama Kumaraswamy, 2016
+# Ginjang Project, LMU
+
+import nixio as nix
+import neo
+import quantities as qu
+import numpy as np
+
+qu2Val = lambda x: nix.Value(float(x))
+quUnitStr = lambda x: x.dimensionality.string
+
+#***********************************************************************************************************************
+
+def addAnalogSignal2Block(blk, analogSignal):
+    '''
+    Create a new data array in the block blk and add the data in analogSignal to it
+    :param blk: nix.block
+    :param analogSignal: neo.analogsignal
+    :return: data, nix.data_array, the newly added data_array
+    '''
+
+    assert hasattr(analogSignal, 'name'), 'Analog signal has no name'
+
+    data = blk.create_data_array(analogSignal.name, 'nix.regular_sampled', data=analogSignal.magnitude)
+
+    data.unit = quUnitStr(analogSignal)
+    data.label = analogSignal.name
+
+    qu.set_default_units = 'SI'
+    samplingPeriod = analogSignal.sampling_period.simplified
+    t = data.append_sampled_dimension(float(samplingPeriod))
+    t.label = 'time'
+    t.unit = quUnitStr(samplingPeriod)
+    t.offset = float(analogSignal.t_start.simplified)
+
+    return data
+
+#***********************************************************************************************************************
+
+def dataArray2AnalogSignal(dataArray):
+    '''
+    Convert a nix data_array into a neo analogsignal
+    :param dataArray: nix.data_array
+    :return: neo.analogsignal
+    '''
+
+    assert len(dataArray.dimensions) == 1, 'Only one dimensional arrays are supported'
+    dim = dataArray.dimensions[0]
+    assert isinstance(dim, nix.pycore.SampledDimension), 'Only Sampled Dimensions' \
+                                                         'are supported'
+
+    t_start = qu.Quantity(dim.offset, units=dim.unit)
+    samplingPeriod = qu.Quantity(dim.sampling_interval, units=dim.unit)
+
+    analogSignal = neo.AnalogSignal(signal=np.array(dataArray[:]),
+                                    units=dataArray.unit,
+                                    sampling_period=samplingPeriod,
+                                    t_start=t_start)
+
+    analogSignal.name = dataArray.name
+
+    return analogSignal
+
+#***********************************************************************************************************************
+
+def property2qu(property):
+    '''
+    Convert a nix property to a quantities Quantity
+    :param property: nix.property
+    :return: quantities.Quantity
+    '''
+
+    return qu.Quantity([v.value for v in property.values], units=property.unit)
+
+#***********************************************************************************************************************
+
+def addQuantity2section(sec, quant, name):
+    '''
+    Create new property in section sec and add the data in quantity.Quantitiy quant to it
+    :param sec: nix.section
+    :param quant: quantities.Quantity
+    :param name: name of the property to add
+    :return: p, nix.property, the property added.
+    '''
+
+    if quant.shape == ():
+
+        p = sec.create_property(name, [qu2Val(quant)])
+
+    #only 1D arrays
+    elif len(quant.shape) == 1:
+
+        #not an empty 1D array
+        if quant.shape[0]:
+
+            p = sec.create_property(name, [qu2Val(x) for x in quant])
+
+        else:
+            raise(ValueError('Quantity passed must be either scalar or 1 dimensional'))
+
+    else:
+            raise(ValueError('Quantity passed must be either scalar or 1 dimensional'))
+
+    p.unit = quUnitStr(quant)
+
+    return p
+
+#***********************************************************************************************************************
+
+def createPosDA(name, pos, blk):
+    '''
+    Create a data_array of type 'nix.positions' with the pos data in the block blk
+    :param name: string, name of the data_array to create
+    :param pos: iterable of floats, data to be added to the created data_array
+    :param blk: nix.block, the block in which the data_array is to be created
+    :return: positions, nix.data_array, the newly created data_array
+    '''
+
+    positions = blk.create_data_array(name, 'nix.positions', data=pos)
+    positions.append_set_dimension()
+    positions.append_set_dimension()
+
+    return positions
+
+#***********************************************************************************************************************
+
+def createExtDA(name, ext, blk):
+    '''
+   Create a data_array of type 'nix.extents' with the pos data in the block blk
+   :param name: string, name of the data_array to create
+   :param ext: iterable of floats, data to be added to the created data_array
+   :param blk: nix.block, the block in which the data_array is to be created
+   :return: extents, nix.data_array, the newly created data_array
+   '''
+
+    extents = blk.create_data_array(name, 'nix.extents', data=ext)
+    extents.append_set_dimension()
+    extents.append_set_dimension()
+
+    return extents
+
+#***********************************************************************************************************************
+
+def tag2AnalogSignal(tag, refInd):
+    '''
+    Create a neo.analogsignal from the snippet of data represented by a nix.tag and its reference at index refInd
+    :param tag: nix.tag
+    :param refInd: the index of the reference among those of the tag to use
+    :return: neo.analogsignal with the snipped of reference data tagged by tag.
+    '''
+
+    ref = tag.references[refInd]
+    dim = ref.dimensions[0]
+    offset = dim.offset
+    ts = dim.sampling_interval
+    nSamples = ref[:].shape[0]
+
+    startInd = max(0, int(np.floor((tag.position[0] - offset) / ts)))
+    endInd = min(startInd + int(np.floor(tag.extent[0] / ts)) + 1, nSamples)
+    trace = ref[startInd:endInd]
+
+    analogSignal = neo.AnalogSignal(signal=trace,
+                                    units=ref.unit,
+                                    sampling_period=qu.Quantity(ts, units=dim.unit),
+                                    t_start=qu.Quantity(offset + startInd * ts, units=dim.unit))
+
+    analogSignal = analogSignal.reshape((analogSignal.shape[0],))
+    # trace = tag.retrieve_data(refInd)[:]
+    # tVec = tag.position[0] + np.linspace(0, tag.extent[0], trace.shape[0])
+
+    return analogSignal
+
+#***********************************************************************************************************************
+
+def getTagPosExt(tag):
+
+    position = tag.position[0] * qu.Quantity(1, units=tag.units[0])
+    extent = tag.extent[0] * qu.Quantity(1, units=tag.units[0])
+
+    return position, extent
+
+
+
+#***********************************************************************************************************************
+def multiTag2SpikeTrain(tag, tStart, tStop):
+    '''
+    Create a neo.spiketrain from nix.multitag
+    :param tag: nix.multitag
+    :param tStart: float, time of start of the spike train in units of the multitag
+    :param tStop: float, time of stop of the spike train in units of the multitag
+    :return: neo.spiketrain
+    '''
+
+
+    if len(tag.positions):
+        sp = neo.SpikeTrain(times=tag.positions[:], t_start=tStart, t_stop=tStop, units=tag.units[0])
+    else:
+        sp = neo.SpikeTrain(times=[], t_start=tStart, t_stop=tStop, units=qu.s)
+
+    return sp
+
+
+#***********************************************************************************************************************
+
+def addMultiTag(name, type, positions, blk, refs, metadata=None, extents=None):
+    '''
+    Add a multi_tag to one or more data_arrays
+    :param name: string, name of the multi_tag
+    :param type: string, type of the multi_tag
+    :param positions: quantities.Quantity, positions of the multi_tag
+    :param blk: nix.Block, the block in which the multi_tag is to be created
+    :param refs: list, list of nix.data_array objects, to which the multi_tag refers
+    :param metadata: nix.Section, to which the the multi_tag refers
+    :param extents: nix.data_array, extents of the multi_tag
+    :return: nix.multi_tag, the newly created multi_tag
+    '''
+
+    refUnits0 = refs[0].dimensions[0].unit
+    for ref in refs:
+        assert len(ref.dimensions) == 1, 'Only 1D refs are supported for now.'
+        assert ref.dimensions[0].unit == refUnits0, 'refs must have same time units'
+
+    positionsUnitsNormed = simpleFloat(positions / qu.Quantity(1, units=refUnits0))
+    positionsDA = createPosDA('{}_DA'.format(name), positionsUnitsNormed, blk)
+    tag = blk.create_multi_tag(name, type, positionsDA)
+    tag.units = [str(refUnits0)]
+
+    if extents is not None:
+        tag.extents = extents
+
+    for ref in refs:
+        tag.references.append(ref)
+
+    if metadata is not None:
+        tag.metadata = metadata
+
+#***********************************************************************************************************************
+
+def addTag(name, type, position, blk, refs, metadata=None, extent=None):
+    '''
+    Add a tag to one or more data_arrays
+    :param name: string, name of the tag
+    :param type: string, type of the tag
+    :param position: float, position of the tag
+    :param blk: nix.Block, the block in which the multi_tag is to be created
+    :param refs: list, list of nix.data_array objects, to which the multi_tag refers
+    :param metadata: nix.Section, to which the the multi_tag refers
+    :param extent: float, extent of the multi_tag
+    :return: nix.tag, the newly created tag
+    '''
+    tag = blk.create_tag(name, type, [position])
+
+
+
+    if extent is not None:
+        tag.extent = [extent]
+
+    for ref in refs:
+        tag.references.append(ref)
+        tag.units = [str(ref.dimensions[0].unit)]
+
+    if metadata is not None:
+        tag.metadata = metadata
+
+
+#***********************************************************************************************************************
+
+def simpleFloat(quant):
+    '''
+    Float or List of float(s) of simplified version of a quantity that can be
+    effectively represented as a float or list of floats.
+    :param quant: a quantity.Quantity or an iterable of quantity.Quantity objects
+    :return: float or iterable of floats depending on the argument quant
+    '''
+
+    # one element quantity
+    if quant.shape == ():
+
+        return float(quant.simplified)
+
+    # 1D quantity
+    elif len(quant.shape) == 1:
+
+        if quant.shape[0]:
+
+            return quant.simplified.magnitude.tolist()
+
+        else:
+
+            return []
+
+    # 2D quantity
+    elif len(quant.shape) == 2:
+
+        if quant.shape[0]:
+
+            # 2D column quantity
+            if quant.shape[1] == 1:
+                return quant.simplified.magnitude[:, 0].tolist()
+
+            # 2D row quantity
+            if quant.shape[0] == 1:
+                return quant.simplified.magnitude[0, :].tolist()
+
+            else:
+                raise (TypeError('simpleFloat only supports scalar, '
+                                 '1D, 2D row and 2D column quantities'))
+        else:
+            return []
+
+    else:
+
+        raise(TypeError('simpleFloat only supports scalar, '
+                        '1D, 2D row and 2D column quantities'))
+
+#***********************************************************************************************************************

+ 309 - 0
paramLists/AdExpPars.py

@@ -0,0 +1,309 @@
+# Most of these parameters are part of the work by Aynur Makhsutov
+# during AMGEN program 2016 at Wachtlerlab, LMU. The last few parameters sets
+# that start with "DLInt" have been newly added.
+
+
+from brian2 import nA, mV, ms, nS, pF, nF, uA, uF
+
+
+resonator = {
+    "b": 0.0805 * nA,
+    "V":-70.4*mV,
+    "sF": 2 * mV,
+    "tau": 144 * ms,
+    "EL": -70.6 * mV,
+    "gL": 20 * nS,
+    "C": 2810 * pF,
+    "a": 8 * nS
+}
+
+integrator = {
+    "b": 0.0805 * nA,
+    "V":-70.4*mV,
+    "sF": 2 * mV,
+    "tau": 144 * ms,
+    "EL": -70.6 * mV,
+    "gL": 20 * nS,
+    "C": 12 * nF,
+    "a": 4 * nS
+}
+
+rebound = {
+    "w": 0 * uA,
+    "Vr": -60 * mV,  # -48.5*mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 720 * ms,
+    "EL": -60 * mV,
+    "gL": 30 * nS,
+    "C": 281 * pF,
+    "a": 80 * nS
+}
+
+bursting = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -70.4 * mV,
+    "sF": 2 * mV,
+    "tau": 144 * ms,
+    "EL": -70.6 * mV,
+    "gL": 30 * nS,
+    "C": 281 * pF,
+    "a": 4 * nS
+}
+
+bursting_rebound = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 720 * ms,
+    "EL": -60 * mV,
+    "gL": 30 * nS,
+    "C": 281 * pF,
+    "a": 80 * nS
+}
+
+bursting_rebound_low = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 720 * ms,
+    "EL": -60 * mV,
+    "gL": 30 * nS,
+    "C": 281 * pF,
+    "a": 30 * nS
+}
+
+bursting_rebound_high = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 720 * ms,
+    "EL": -60 * mV,
+    "gL": 30 * nS,
+    "C": 281 * pF,
+    "a": 150 * nS
+}
+
+
+perc = {
+    "Vr": 0.1,
+    "Vt": 0.1,
+    "b": 0.99,
+    "sF": 0.2,
+    "tau": 0.6,
+    "gL": 0.01,
+    "C": 0.2,
+    "a": 0.4
+}
+
+hopf_resonator = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 120 * ms,
+    "EL": -60 * mV,
+    "gL": 30 * nS,
+    "C": 681 * pF,
+    "a": 80 * nS
+}
+
+hopf_resonator2 = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 120 * ms,
+    "EL": -60 * mV,
+    "gL": 6 * nS,
+    "C": 1200 * pF,
+    "a": 80 * nS
+}
+
+saddle_resonator = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 12 * ms,
+    "EL": -60 * mV,
+    "gL": 30 * nS,
+    "C": 800 * pF,
+    "a": 30 * nS
+}
+
+saddle_resonator2 = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 12 * ms,
+    "EL": -60 * mV,
+    "gL": 3 * nS,
+    "C": 800 * pF,
+    "a": 30 * nS
+}
+
+saddle_integrator = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 12 * ms,
+    "EL": -60 * mV,
+    "gL": 40 * nS,
+    "C": 1200 * pF,
+    "a": 3 * nS
+}
+
+saddle_mixed = {
+    "w": 0 * uA,
+    "Vr": -47.4 * mV,
+    "Vt": -50.4 * mV,
+    "b": 0.0805 * nA,
+    "V": -60 * mV,
+    "sF": 2 * mV,
+    "tau": 12 * ms,
+    "EL": -60 * mV,
+    "gL": 80 * nS,
+    "C": 300 * pF,
+    "a": 10 * nS
+}
+
+result13 = {
+    "w": 0 * uA,
+    "Vr": -62.8 * mV,
+    "Vt": -49.2 * mV,
+    "b": 1.41 * nA,
+    "V": -60 * mV,
+    "sF": 7.2 * mV,
+    "tau": 600 * ms,
+    "EL": -60 * mV,
+    "gL": 80 * nS,
+    "C": 276 * pF,
+    "a": 1037 * nS
+}
+
+mean_24_08_2016 = {
+    "w": 0 * uA,
+    "Vr": -55.56 * mV,
+    "Vt": -49.82 * mV,
+    "b": 1.85 * nA,
+    "V": -60 * mV,
+    "sF": 6.69 * mV,
+    "tau": 617.8 * ms,
+    "EL": -60 * mV,
+    "gL": 411.7 * nS,
+    "C": 5242.8 * pF,
+    "a": 923 * nS
+}
+
+std_inits = {
+            "w": 0*uA,
+            "Vr": -70.6 * mV,#-48.5*mV,
+            "Vt": -50.4 * mV,
+            "b": 0.0805 * nA,
+            "V":-70.4 * mV,
+            "sF": 2 * mV,
+            "tau": 144 * ms,
+            "EL": -70.6 * mV,
+            "gL": 30 * nS,
+            "C": 281 * pF,
+            "a": 4 * nS,
+            "Vp": -25 * mV,
+    "I": 0 * nA
+}
+
+DLInt2Try1 = {
+    "b": 0.0805 * nA,
+    "V": -30*mV,
+    "sF": 2 * mV,
+    "tau": 5 * ms,
+    "EL": -30 * mV,
+    "gL": 200000 * nS,
+    "C": 0.5 * uF,
+    "a": 4 * nS,
+    "Vr": -30 * mV,
+    "Vt": -20 * mV,
+    "Vp": -10 * mV
+}
+
+DLInt1Try1 = {
+    "b": 0.0805 * nA,
+    "V": -30*mV,
+    "sF": 2 * mV,
+    "tau": 1 * ms,
+    "EL": -30 * mV,
+    "gL": 200000 * nS,
+    "C": 0.5 * uF,
+    "a": 200000 * nS,
+    "Vr": -30 * mV,
+    "Vt": -15 * mV,
+    "Vp": -5 * mV
+}
+
+DLInt1Try2 = {
+    "b": 1.367 * nA,
+    "V": -30*mV,
+    "sF": 6 * mV,
+    "tau": 100 * ms,
+    "EL": -30 * mV,
+    "gL": 200000 * nS,
+    "C": 0.5 * uF,
+    "a": 400000 * nS,
+    "Vr": -30 * mV,
+    "Vt": -25 * mV,
+    "Vp": 0 * mV
+}
+
+DLInt1Aynur = {
+    "b": 1 * nA,
+    "V": -30 * mV,
+    "sF": 6 * mV,
+    "tau": 180 * ms,
+    "EL": -30 * mV,
+    "gL": 500 * nS,
+    "C": 0.125 * nF,
+    "a": 500 * nS,
+    "Vr": -31 * mV,
+    "Vt": -27.5 * mV,
+    "Vp": 0 * mV
+}
+
+DLInt2Try2 = {
+    "b": 1 * nA,
+    "V": -30 * mV,
+    "sF": 6 * mV,
+    "tau": 0.08 * ms,
+    "EL": -30 * mV,
+    "gL": 500 * nS,
+    "C": 0.125 * nF,
+    "a": 500 * nS,
+    "Vr": -31 * mV,
+    "Vt": -27.5 * mV,
+    "Vp": 0 * mV
+}

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 @@
+from brian2 import units, array
+from brian2.units.fundamentalunits import Quantity
+import numpy as np
+
+period265 = (1 / 265)
+
+onePulse = dict(sinPulseStarts=array([0]) * units.ms,
+                sinPulseDurs=array([0.9 * period265]) * units.second)
+twoPulse = dict(sinPulseStarts=array([0]) * units.ms,
+                sinPulseDurs=array([1.9 * period265]) * units.second)
+threePulse = dict(sinPulseStarts=array([0]) * units.ms,
+                sinPulseDurs=array([2.9 * period265]) * units.second)
+
+tenMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
+                sinPulseDurs=array([10]) * units.ms)
+twentyMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
+                sinPulseDurs=array([20]) * units.ms)
+thirtyMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
+                sinPulseDurs=array([30]) * units.ms)
+fortyMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
+                sinPulseDurs=array([40]) * units.ms)
+fiftyMSPulse = dict(sinPulseStarts=array([0]) * units.ms,
+                sinPulseDurs=array([50]) * units.ms)
+
+
+
+oneSecondPulse = dict(sinPulseStarts=array([0]) * units.ms,
+                sinPulseDurs=array([1]) * units.second)
+
+def getPulseTrainInputPars(pulseDur: Quantity, pulseInt: Quantity,
+                           stimDur: Quantity) -> dict:
+    pulseDurF = float(pulseDur)
+    pulseIntF = float(pulseInt)
+    stimDurF = float(stimDur)
+
+    sinPulseStarts = (np.arange(0, stimDurF, pulseIntF)) * units.second
+    sinPulseDurs = ([pulseDurF] * len(sinPulseStarts)) * units.second
+
+    return dict(sinPulseStarts=sinPulseStarts,
+                sinPulseDurs=sinPulseDurs)
+
+pulseTrainInt20Dur10 = getPulseTrainInputPars(pulseDur=10*units.ms, pulseInt=20*units.ms,
+                                              stimDur=1*units.second)
+pulseTrainInt20Dur16 = getPulseTrainInputPars(pulseDur=16*units.ms, pulseInt=20*units.ms,
+                                              stimDur=1*units.second)
+pulseTrainInt33Dur10 = getPulseTrainInputPars(pulseDur=10*units.ms, pulseInt=33*units.ms,
+                                              stimDur=1*units.second)
+pulseTrainInt33Dur16 = getPulseTrainInputPars(pulseDur=16*units.ms, pulseInt=33*units.ms,
+                                              stimDur=1*units.second)
+pulseTrainInt50Dur10 = getPulseTrainInputPars(pulseDur=10*units.ms, pulseInt=50*units.ms,
+                                              stimDur=1*units.second)
+pulseTrainInt50Dur16 = getPulseTrainInputPars(pulseDur=16*units.ms, pulseInt=50*units.ms,
+                                              stimDur=1*units.second)
+pulseTrainInt50Dur20 = getPulseTrainInputPars(pulseDur=20*units.ms, pulseInt=50*units.ms,
+                                              stimDur=1*units.second)
+pulseTrainInt50Dur30 = getPulseTrainInputPars(pulseDur=30*units.ms, pulseInt=50*units.ms,
+                                              stimDur=1*units.second)
+pTShortInt20Dur10 = getPulseTrainInputPars(pulseDur=10 * units.ms, pulseInt=20 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt20Dur16 = getPulseTrainInputPars(pulseDur=16 * units.ms, pulseInt=20 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt33Dur10 = getPulseTrainInputPars(pulseDur=10 * units.ms, pulseInt=33 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt33Dur16 = getPulseTrainInputPars(pulseDur=16 * units.ms, pulseInt=33 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt33Dur20 = getPulseTrainInputPars(pulseDur=20 * units.ms, pulseInt=33 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt50Dur10 = getPulseTrainInputPars(pulseDur=10 * units.ms, pulseInt=50 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt50Dur16 = getPulseTrainInputPars(pulseDur=16 * units.ms, pulseInt=50 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt50Dur20 = getPulseTrainInputPars(pulseDur=20 * units.ms, pulseInt=50 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt100Dur10 = getPulseTrainInputPars(pulseDur=10 * units.ms, pulseInt=100 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt100Dur16 = getPulseTrainInputPars(pulseDur=16 * units.ms, pulseInt=100 * units.ms,
+                                           stimDur=250 * units.ms)
+pTShortInt100Dur20 = getPulseTrainInputPars(pulseDur=20 * units.ms, pulseInt=100 * units.ms,
+                                           stimDur=250 * units.ms)

+ 31 - 0
paramLists/synapsePropsList.py

@@ -0,0 +1,31 @@
+from brian2 import units
+
+DLInt1_syn_try1 = dict(wSyn=[5000, 400] * units.usiemens,
+                    Esyn=[0, -80] * units.mvolt,
+                    tau1=[4, 4] * units.ms, tau2=[4.5, 8] * units.ms,
+                    delay=[6, 10] * units.ms)
+
+DLInt1_syn_try2 = dict(wSyn=[15000, 1500] * units.nsiemens,
+                    Esyn=[0, -80] * units.mvolt,
+                    tau1=[4, 4] * units.ms, tau2=[4.5, 8] * units.ms,
+                    delay=[6, 18] * units.ms)
+
+DLInt1_syn_try2_e = dict(wSyn=25 * units.nsiemens,
+                    Esyn=0 * units.mvolt,
+                    tau1=0.5 * units.ms, tau2=2 * units.ms,
+                    delay=5 * units.ms)
+
+DLInt1_syn_try2_i = dict(wSyn=160 * units.nsiemens,
+                    Esyn=-80 * units.mvolt,
+                    tau1=12 * units.ms, tau2=15 * units.ms,
+                    delay=10 * units.ms)
+
+DLInt2_syn_try2 = dict(wSyn=75 * units.nsiemens,
+                    Esyn=0 * units.mvolt,
+                    tau1=0.5 * units.ms, tau2=2 * units.ms,
+                    delay=5 * units.ms)
+
+DLInt1_DLInt2_try1 = dict(wSyn=500 * units.nsiemens,
+                    Esyn=-80 * units.mvolt,
+                    tau1=7 * units.ms, tau2=8 * units.ms,
+                    delay=3 * units.ms)

+ 182 - 0
plotDLInt1DLInt2SynEffect.py

@@ -0,0 +1,182 @@
+import nixio
+from matplotlib import pyplot as plt
+from brian2 import units
+from dirDefs import homeFolder
+import os
+from neoNIXIO import dataArray2AnalogSignal, multiTag2SpikeTrain, simpleFloat
+from mplPars import mplPars
+import seaborn as sns
+import quantities as qu
+
+sns.set(rc=mplPars)
+
+
+simSettleTime = 600 * units.ms
+
+simStepSize = 0.1 * units.ms
+simDuration = 450 * units.ms
+totalSimDur = simSettleTime + simDuration
+IntDurs = [
+    (20, 10),
+    (20, 16),
+    (33, 10),
+    (33, 16),
+    (33, 20),
+    (50, 10),
+    (50, 16),
+    (50, 20),
+    (100, 10),
+    (100, 16),
+    (100, 20)
+]
+
+pulseInts = sorted(set([x[0] for x in IntDurs]))
+pulseDurs = sorted(set([x[1] for x in IntDurs]))
+
+showBefore = 75 * units.ms
+showAfter = -30 * units.ms
+
+DLInt1ModelProps = "DLInt1Aynur"
+
+
+DLInt2ModelProps = "DLInt2Try2"
+
+
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
+# DLInt1SynapsePropsE = ""
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
+# DLInt1SynapsePropsI = ""
+
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+DLInt2SynapseProps = 'DLInt2_syn_try2'
+# DLInt2SynapseProps = ""
+
+
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
+# DLInt1DLInt2SynProps = ""
+
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
+                     DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps)
+
+fig1, axs1 = plt.subplots(nrows=len(pulseDurs), ncols=len(pulseInts),
+                          figsize=(14, 11.2), sharex='col')
+fig2, axs2 = plt.subplots(nrows=len(pulseDurs), ncols=len(pulseInts),
+                          figsize=(14, 11.2), sharex='col')
+
+for IntDur in IntDurs:
+
+    pulseInt = IntDur[0]
+    pulseDur = IntDur[1]
+    inputParsName = 'pTShortInt{:2d}Dur{:2d}'.format(pulseInt, pulseDur)
+    opDirWith = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
+                         inputParsName)
+    OPNixFileWith = os.path.join(opDirWith, 'SimResults.h5')
+
+    opDirWithout = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
+                             DLInt1SynapseProps + DLInt2SynapseProps,
+                             inputParsName)
+    OPNixFileWithout = os.path.join(opDirWithout, 'SimResults.h5')
+
+    nixFile = nixio.File.open(OPNixFileWith, nixio.FileMode.ReadOnly)
+    blk = nixFile.blocks["Simulation Traces"]
+    dlint1MemV = blk.data_arrays["DLInt1 MemV"]
+    dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
+    dlint2MemV = blk.data_arrays["DLInt2 MemV"]
+    dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
+    sinInput = blk.data_arrays["Input Vibration Signal"]
+    joSpikesMT = blk.multi_tags["JO Spikes"]
+
+    dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
+    dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
+    sinInputAS = dataArray2AnalogSignal(sinInput)
+    dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+    dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+    joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+
+    nixFileWithout = nixio.File.open(OPNixFileWithout, nixio.FileMode.ReadOnly)
+    blkWithout = nixFileWithout.blocks["Simulation Traces"]
+    dlint2MemVWithout = blkWithout.data_arrays["DLInt2 MemV"]
+    dlint2SpikesMTWithout = blkWithout.multi_tags["DLInt2 Spikes"]
+    dlint2MemVASWithout = dataArray2AnalogSignal(dlint2MemVWithout)
+    dlint2SpikesSTWithout = multiTag2SpikeTrain(dlint2SpikesMTWithout,
+                                                sinInputAS.t_start, sinInputAS.t_stop)
+
+
+    rowInd = pulseDurs.index(pulseDur)
+    colInd = pulseInts.index(pulseInt)
+
+    axs1[rowInd, colInd].plot(simpleFloat(dlint1MemVAS.times / qu.ms),
+                              simpleFloat(dlint1MemVAS / qu.mV), 'b-', lw=1)
+    # mew needs setting for seaborn. https://github.com/mwaskom/seaborn/issues/644
+    axs1[rowInd, colInd].plot(simpleFloat(dlint1SpikesST.times / qu.ms),
+                              [4] * dlint1SpikesST.shape[0],
+                              'b|', ms=8, mew=1)
+    axs1[rowInd, colInd].plot(simpleFloat(sinInputAS.times / qu.ms),
+                              simpleFloat(-50 + (sinInputAS * 5) / qu.um)
+                              , 'k-', lw=1)
+    axs1[rowInd, colInd].set_xlim([(simSettleTime - showBefore) / units.ms,
+                                   (totalSimDur + showAfter) / units.ms])
+
+
+    axs2[rowInd, colInd].plot(simpleFloat(dlint2MemVAS.times / qu.ms),
+                              simpleFloat(dlint2MemVAS / qu.mV), 'b-', lw=1)
+    axs2[rowInd, colInd].plot(simpleFloat(dlint2MemVASWithout.times / qu.ms),
+                              simpleFloat(-45 + (dlint2MemVASWithout / qu.mV)),
+                              'r-', lw=1)
+    axs2[rowInd, colInd].plot(simpleFloat(dlint2SpikesST.times / qu.ms),
+                              [12] * dlint2SpikesST.shape[0],
+                            'b|', ms=8, mew=1)
+    axs2[rowInd, colInd].plot(simpleFloat(dlint2SpikesSTWithout.times / qu.ms),
+                              [6] * dlint2SpikesSTWithout.shape[0],
+                              'r|', ms=8, mew=1)
+    axs2[rowInd, colInd].plot(simpleFloat(sinInputAS.times / qu.ms),
+                              simpleFloat(-105 + (sinInputAS * 7.5) / qu.um)
+                              , 'k-', lw=1)
+    axs2[rowInd, colInd].set_xlim([(simSettleTime - showBefore) / units.ms,
+                                   (totalSimDur + showAfter) / units.ms])
+
+
+for rowInd in range(axs1.shape[0]):
+    for colInd in range(axs1.shape[1]):
+        ax = axs1[rowInd, colInd]
+        ax.set_ylim([-60, 10])
+        ax.yaxis.tick_right()
+        ax.set_yticklabels([""] * len(ax.get_yticks()))
+        ax.set_xticklabels([""] * len(ax.get_xticks()))
+
+for rowInd in range(axs2.shape[0]):
+    for colInd in range(axs2.shape[1]):
+        ax = axs2[rowInd, colInd]
+        ax.set_ylim([-120, 20])
+        ax.yaxis.tick_right()
+        ax.set_yticklabels([""] * len(ax.get_yticks()))
+        ax.set_xticklabels([""] * len(ax.get_xticks()))
+
+for ind, val in enumerate(pulseInts):
+
+    axs1[0, ind].set_title(str(val))
+    axs2[0, ind].set_title(str(val))
+
+for ind, val in enumerate(pulseDurs):
+
+    axs1[ind, 0].set_ylabel(str(val))
+    axs2[ind, 0].set_ylabel(str(val))
+
+fig1.tight_layout()
+fig2.tight_layout()
+
+fig1.savefig(os.path.join(opDir, 'DLInt1Summary.png'), dpi=150)
+fig2.savefig(os.path.join(opDir, 'DLInt2Summary.png'), dpi=150)
+
+
+
+
+
+
+
+
+

+ 125 - 0
plotMemVs.py

@@ -0,0 +1,125 @@
+import nixio
+from dirDefs import homeFolder
+import os
+import seaborn as sns
+from mplPars import mplPars
+from brian2 import units
+from matplotlib import pyplot as plt
+from neoNIXIO import multiTag2SpikeTrain, dataArray2AnalogSignal, simpleFloat
+import quantities as qu
+
+mplPars["axes.titlesize"] = 14
+mplPars["font.size"] = 14
+mplPars["xtick.labelsize"] = 12
+mplPars["ytick.labelsize"] = 12
+mplPars["legend.fontsize"] = 12
+sns.set(rc=mplPars)
+
+
+simSettleTime = 600 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 150 * units.ms
+# # inputParsName = 'onePulse'
+# # inputParsName = 'twoPulse'
+# # inputParsName = 'threePulse'
+# inputParsName = "thirtyMSPulse"
+# # inputParsName = "fortyMSPulse"
+#
+# showBefore = 50 * units.ms
+# showAfter = 0 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 450 * units.ms
+# # inputParsName = "pTShortInt20Dur10"
+# # inputParsName = "pTShortInt20Dur16"
+# # inputParsName = "pTShortInt33Dur10"
+# # inputParsName = "pTShortInt33Dur16"
+# # inputParsName = "pTShortInt33Dur20"
+# # inputParsName = "pTShortInt50Dur10"
+# # inputParsName = "pTShortInt50Dur16"
+# # inputParsName = "pTShortInt50Dur20"
+# inputParsName = "pTShortInt100Dur10"
+# # inputParsName = "pTShortInt100Dur16"
+# # inputParsName = "pTShortInt100Dur20"
+#
+# showBefore = 100 * units.ms
+# showAfter = 100 * units.ms
+
+simStepSize = 0.1 * units.ms
+simDuration = 1500 * units.ms
+inputParsName = 'oneSecondPulse'
+# inputParsName = 'pulseTrainInt20Dur10'
+# inputParsName = 'pulseTrainInt20Dur16'
+# inputParsName = 'pulseTrainInt33Dur10'
+# inputParsName = 'pulseTrainInt33Dur16'
+
+showBefore = 500 * units.ms
+showAfter = 0 * units.ms
+
+DLInt1ModelProps = "DLInt1Aynur"
+
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
+# DLInt1SynapsePropsE = ""
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
+# DLInt1SynapsePropsI = ""
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+DLInt2ModelProps = "DLInt2Try2"
+
+DLInt2SynapseProps = 'DLInt2_syn_try2'
+
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
+
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
+                         inputParsName)
+OPNixFile = os.path.join(opDir, 'SimResults.h5')
+
+
+totalSimDur = simDuration + simSettleTime
+
+nixFile = nixio.File.open(OPNixFile, nixio.FileMode.ReadOnly)
+blk = nixFile.blocks["Simulation Traces"]
+dlint1MemV = blk.data_arrays["DLInt1 MemV"]
+dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
+dlint2MemV = blk.data_arrays["DLInt2 MemV"]
+dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
+sinInput = blk.data_arrays["Input Vibration Signal"]
+joSpikesMT = blk.multi_tags["JO Spikes"]
+
+dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
+dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
+sinInputAS = dataArray2AnalogSignal(sinInput)
+dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+
+fig1, axs1 = plt.subplots(nrows=2, figsize=(7, 4.375), sharex='col')
+axs1[0].plot(simpleFloat(dlint1MemVAS.times / qu.ms),
+                simpleFloat(dlint1MemVAS / qu.mV), 'b-', lw=0.5)
+axs1[0].plot(simpleFloat(sinInputAS.times / qu.ms),
+                simpleFloat((sinInputAS * 2.5 - 55 * qu.um) / qu.um),
+               'k-', lw=0.5)
+axs1[0].set_ylabel("DL-Int-1")
+axs1[0].set_ylim([-60, 10])
+
+axs1[1].plot(simpleFloat(dlint2MemVAS.times / qu.ms),
+                simpleFloat(dlint2MemVAS / qu.mV), 'b-', lw=0.5)
+
+axs1[1].plot(simpleFloat(sinInputAS.times / qu.ms),
+                simpleFloat((sinInputAS * 2.5 - 55 * qu.um) / qu.um),
+               'k-', lw=0.5)
+axs1[1].set_ylabel("DL-Int-2")
+# axs1[1].set_xlabel("Time (ms)")
+
+axs1[1].set_xlim([(simSettleTime - showBefore) / units.ms,
+                     (totalSimDur + showAfter) / units.ms])
+axs1[0].set_yticklabels([""] * len(axs1[1].get_yticks()))
+axs1[1].set_yticklabels([""] * len(axs1[1].get_yticks()))
+axs1[1].set_xticklabels([""] * len(axs1[1].get_xticks()))
+
+for fig in [fig1]:
+    fig.tight_layout()
+
+fig1.savefig(os.path.join(opDir, "Traces.png"), dpi=300)

+ 126 - 0
plotShortStims.py

@@ -0,0 +1,126 @@
+from brian2 import units
+from matplotlib import pyplot as plt
+import seaborn as sns
+import os
+from dirDefs import homeFolder
+import nixio
+from neoNIXIO import multiTag2SpikeTrain, dataArray2AnalogSignal, simpleFloat
+import quantities as qu
+from mplPars import mplPars
+
+sns.set(rc=mplPars)
+sns.axes_style('whitegrid')
+
+simSettleTime = 600 * units.ms
+#
+simStepSize = 0.1 * units.ms
+simDuration = 150 * units.ms
+inputParsNames = {
+                     10: "tenMSPulse",
+                     20: "twentyMSPulse",
+                     30: "thirtyMSPulse",
+                     40: "fortyMSPulse"
+                     }
+showBefore = 50 * units.ms
+showAfter = 50 * units.ms
+
+totalSimDur = simSettleTime + simDuration
+
+DLInt1ModelProps = "DLInt1Aynur"
+
+
+DLInt2ModelProps = "DLInt2Try2"
+
+
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
+# DLInt1SynapsePropsE = ""
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
+# DLInt1SynapsePropsI = ""
+
+DLInt2SynapseProps = 'DLInt2_syn_try2'
+# DLInt2SynapseProps = ""
+
+
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
+# DLInt1DLInt2SynProps = ""
+
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
+                     DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps)
+
+fig, axs = plt.subplots(nrows=2, ncols=len(inputParsNames), figsize=(14, 11.2),
+                        sharex='col')
+
+for ipInd, (ipVal, ipName) in enumerate(inputParsNames.items()):
+
+    nixFile = os.path.join(opDir, ipName, 'SimResults.h5')
+    nixFile = nixio.File.open(nixFile, nixio.FileMode.ReadOnly)
+    blk = nixFile.blocks["Simulation Traces"]
+    dlint1MemV = blk.data_arrays["DLInt1 MemV"]
+    dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
+    dlint2MemV = blk.data_arrays["DLInt2 MemV"]
+    dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
+    sinInput = blk.data_arrays["Input Vibration Signal"]
+    joSpikesMT = blk.multi_tags["JO Spikes"]
+
+    dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
+    dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
+    sinInputAS = dataArray2AnalogSignal(sinInput)
+    dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+    dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+    joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+
+    axs[0, ipInd].plot(simpleFloat(dlint1MemVAS.times / qu.ms),
+                              simpleFloat(dlint1MemVAS / qu.mV), 'b-')
+    # mew needs setting for seaborn. https://github.com/mwaskom/seaborn/issues/644
+    axs[0, ipInd].plot(simpleFloat(dlint1SpikesST.times / qu.ms),
+                              [4] * dlint1SpikesST.shape[0],
+                              'b|', ms=8, mew=1)
+    markerline, stemlines, baseline \
+        = axs[0, ipInd].stem(simpleFloat(joSpikesST.times / qu.ms),
+                      [-40] * joSpikesST.shape[0],
+                      linefmt='r-.', markerfmt='None', basefmt='None',
+                      bottom=-60)
+    plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+    axs[0, ipInd].plot(simpleFloat(sinInputAS.times / qu.ms),
+                              simpleFloat(((5 * qu.um * sinInputAS) - 50 * qu.um) / qu.um)
+                              , 'k-')
+    # axs[0, ipInd].set_xlim([(simSettleTime - showBefore) / units.ms,
+    #                                (totalSimDur + showAfter) / units.ms])
+    axs[0, ipInd].set_ylim([-60, 10])
+    axs[0, ipInd].yaxis.tick_right()
+
+
+    axs[1, ipInd].plot(simpleFloat(dlint2MemVAS.times / qu.ms),
+                       simpleFloat(dlint2MemVAS / qu.mV), 'b-')
+    # mew needs setting for seaborn. https://github.com/mwaskom/seaborn/issues/644
+    axs[1, ipInd].plot(simpleFloat(dlint2SpikesST.times / qu.ms),
+                       [4] * dlint2SpikesST.shape[0],
+                       'b|', ms=8, mew=1)
+    markerline, stemlines, baseline \
+        = axs[1, ipInd].stem(simpleFloat(joSpikesST.times / qu.ms),
+                             [-40] * joSpikesST.shape[0],
+                             linefmt='r-.', markerfmt='None', basefmt='None',
+                             bottom=-60)
+    plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+    axs[1, ipInd].plot(simpleFloat(sinInputAS.times / qu.ms),
+                       simpleFloat(((5 * qu.um * sinInputAS) - 50 * qu.um) / qu.um)
+                       , 'k-')
+    axs[1, ipInd].set_xlim([(simSettleTime - showBefore) / units.ms,
+                            (totalSimDur + showAfter) / units.ms])
+    axs[1, ipInd].set_ylim([-60, 10])
+    axs[1, ipInd].yaxis.tick_right()
+
+for ind in range(len(inputParsNames) - 1):
+    axs[0, ind].set_yticks([])
+    axs[1, ind].set_yticks([])
+
+for ipInd, (ipVal, ipName) in enumerate(inputParsNames.items()):
+    axs[0, ipInd].set_title(ipVal)
+
+axs[0, 0].set_ylabel("DL-Int-1")
+axs[1, 0].set_ylabel("DL-Int-2")
+
+fig.tight_layout()
+fig.savefig(os.path.join(opDir, "shortStims.png"), dpi=300)

+ 203 - 0
plotSynCurrents.py

@@ -0,0 +1,203 @@
+import nixio
+from dirDefs import homeFolder
+import os
+import seaborn as sns
+from mplPars import mplPars
+from brian2 import units
+from matplotlib import pyplot as plt
+from neoNIXIO import multiTag2SpikeTrain, dataArray2AnalogSignal, simpleFloat
+import quantities as qu
+
+sns.set(rc=mplPars)
+
+
+simSettleTime = 600 * units.ms
+
+simStepSize = 0.1 * units.ms
+simDuration = 150 * units.ms
+# inputParsName = 'onePulse'
+# inputParsName = 'twoPulse'
+# inputParsName = 'threePulse'
+inputParsName = "thirtyMSPulse"
+# inputParsName = "fortyMSPulse"
+
+showBefore = 50 * units.ms
+showAfter = 0 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 450 * units.ms
+# # inputParsName = "pTShortInt20Dur10"
+# # inputParsName = "pTShortInt20Dur16"
+# # inputParsName = "pTShortInt33Dur10"
+# # inputParsName = "pTShortInt33Dur16"
+# # inputParsName = "pTShortInt33Dur20"
+# # inputParsName = "pTShortInt50Dur10"
+# # inputParsName = "pTShortInt50Dur16"
+# # inputParsName = "pTShortInt50Dur20"
+# inputParsName = "pTShortInt100Dur10"
+# # inputParsName = "pTShortInt100Dur16"
+# # inputParsName = "pTShortInt100Dur20"
+#
+# showBefore = 100 * units.ms
+# showAfter = 100 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 1500 * units.ms
+# # inputParsName = 'oneSecondPulse'
+# # inputParsName = 'pulseTrainInt20Dur10'
+# inputParsName = 'pulseTrainInt20Dur16'
+# # inputParsName = 'pulseTrainInt33Dur10'
+# # inputParsName = 'pulseTrainInt33Dur16'
+# showBefore = 500 * units.ms
+# showAfter = 500 * units.ms
+
+DLInt1ModelProps = "DLInt1Aynur"
+
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
+# DLInt1SynapsePropsE = ""
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
+# DLInt1SynapsePropsI = ""
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+DLInt2ModelProps = "DLInt2Try2"
+
+DLInt2SynapseProps = 'DLInt2_syn_try2'
+
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
+
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
+                         inputParsName)
+OPNixFile = os.path.join(opDir, 'simResWithSynCurrents.h5')
+
+
+totalSimDur = simDuration + simSettleTime
+
+nixFile = nixio.File.open(OPNixFile, nixio.FileMode.ReadOnly)
+blk = nixFile.blocks["Simulation Traces"]
+dlint1MemV = blk.data_arrays["DLInt1 MemV"]
+isynEDLInt1 = blk.data_arrays["DL-Int-1 input EPSC"]
+isynIDLInt1 = blk.data_arrays["DL-Int-1 input IPSC"]
+dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
+dlint2MemV = blk.data_arrays["DLInt2 MemV"]
+isynEDLInt2 = blk.data_arrays["DL-Int-2 input EPSC"]
+isynIDLInt2 = blk.data_arrays["DL-Int-2 input IPSC"]
+dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
+sinInput = blk.data_arrays["Input Vibration Signal"]
+joSpikesMT = blk.multi_tags["JO Spikes"]
+
+dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
+isynEASDLInt1 = dataArray2AnalogSignal(isynEDLInt1)
+isynIASDLInt1 = dataArray2AnalogSignal(isynIDLInt1)
+dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
+isynEASDLInt2 = dataArray2AnalogSignal(isynEDLInt2)
+isynIASDLInt2 = dataArray2AnalogSignal(isynIDLInt2)
+sinInputAS = dataArray2AnalogSignal(sinInput)
+dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
+
+fig1, ax1 = plt.subplots(nrows=2, ncols=2, figsize=(14, 11.2), sharex='col')
+ax1[0, 0].plot(simpleFloat(dlint1MemVAS.times / qu.ms),
+            simpleFloat(dlint1MemVAS / qu.mV), 'b-')
+markerline, stemlines, baseline \
+    = ax1[0, 0].stem(simpleFloat(joSpikesST.times / qu.ms),
+                     [dlint1MemVAS.magnitude.min()] * joSpikesST.shape[0],
+                     linefmt='r-.', markerfmt='None', basefmt='None',
+                     bottom=-52.5)
+plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+markerline, stemlines, baseline \
+    = ax1[0, 0].stem(simpleFloat(joSpikesST.times / qu.ms),
+                     [10] * joSpikesST.shape[0],
+                     linefmt='r-.', markerfmt='None', basefmt='None',
+                     bottom=dlint1MemVAS.magnitude.max())
+plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+
+ax1[0, 0].plot(simpleFloat(sinInputAS.times / qu.ms),
+               simpleFloat((sinInputAS * 2.5 - 55 * qu.um) / qu.um),
+               'k-')
+
+ax1[0, 1].plot(simpleFloat(isynEASDLInt1.times / qu.ms),
+               simpleFloat(isynEASDLInt1 / qu.nA), color=[0, 0.6, 0],
+               ls='-', marker='None')
+ax1[0, 1].plot(simpleFloat(isynIASDLInt1.times / qu.ms),
+            simpleFloat(isynIASDLInt1 / qu.nA), color=[1, 0, 0],
+            ls='-', marker='None')
+markerline, stemlines, baseline \
+    = ax1[0, 1].stem(simpleFloat(joSpikesST.times / qu.ms),
+                  [isynIASDLInt1.magnitude.min()] * joSpikesST.shape[0],
+                  linefmt='r-.', markerfmt='None', basefmt='None',
+                  bottom=-5.125)
+plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+
+markerline, stemlines, baseline \
+    = ax1[0, 1].stem(simpleFloat(joSpikesST.times / qu.ms),
+                     [5] * joSpikesST.shape[0],
+                     linefmt='r-.', markerfmt='None', basefmt='None',
+                     bottom=isynEASDLInt1.magnitude.max())
+plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+
+ax1[0, 1].plot(simpleFloat(sinInputAS.times / qu.ms),
+               simpleFloat((sinInputAS * 0.375 - 5.5 * qu.um) / qu.um),
+               'k-')
+
+ax1[1, 0].plot(simpleFloat(dlint2MemVAS.times / qu.ms),
+            simpleFloat(dlint2MemVAS / qu.mV), 'b-')
+markerline, stemlines, baseline \
+    = ax1[1, 0].stem(simpleFloat(joSpikesST.times / qu.ms),
+                  [dlint2MemVAS.magnitude.min()] * joSpikesST.shape[0],
+                  linefmt='r-.', markerfmt='None', basefmt='None',
+                  bottom=-52.5)
+plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+
+markerline, stemlines, baseline \
+    = ax1[1, 0].stem(simpleFloat(joSpikesST.times / qu.ms),
+                     [10] * joSpikesST.shape[0],
+                     linefmt='r-.', markerfmt='None', basefmt='None',
+                     bottom=dlint2MemVAS.magnitude.max())
+plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+
+ax1[1, 0].plot(simpleFloat(sinInputAS.times / qu.ms),
+               simpleFloat((sinInputAS * 2.5 - 55 * qu.um) / qu.um),
+               'k-')
+
+ax1[1, 1].plot(simpleFloat(isynEASDLInt2.times / qu.ms),
+            simpleFloat(isynEASDLInt2 / qu.nA), color=[0, 0.6, 0],
+            ls='-', marker='None')
+ax1[1, 1].plot(simpleFloat(isynIASDLInt2.times / qu.ms),
+            simpleFloat(isynIASDLInt2 / qu.nA), color=[1, 0, 0],
+            ls='-', marker='None')
+markerline, stemlines, baseline \
+    = ax1[1, 1].stem(simpleFloat(joSpikesST.times / qu.ms),
+                  [isynIASDLInt2.magnitude.min()] * joSpikesST.shape[0],
+                  linefmt='r-.', markerfmt='None', basefmt='None',
+                  bottom=-5.125)
+plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+
+markerline, stemlines, baseline \
+    = ax1[1, 1].stem(simpleFloat(joSpikesST.times / qu.ms),
+                  [5] * joSpikesST.shape[0],
+                  linefmt='r-.', markerfmt='None', basefmt='None',
+                  bottom=isynEASDLInt2.magnitude.max())
+plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
+
+ax1[1, 1].plot(simpleFloat(sinInputAS.times / qu.ms),
+               simpleFloat((sinInputAS * 0.375 - 5.5 * qu.um) / qu.um),
+               'k-')
+
+ax1[1, 0].set_xlim([(simSettleTime - showBefore) / units.ms,
+                     (totalSimDur + showAfter) / units.ms])
+
+ax1[1, 1].set_xlim([(simSettleTime - showBefore) / units.ms,
+                     (totalSimDur + showAfter) / units.ms])
+
+for ax in ax1.flat:
+    ax.set_xticklabels([""] * len(ax.get_xticks()))
+    ax.set_yticklabels([""] * len(ax.get_yticks()))
+
+
+for fig in [fig1]:
+    fig.tight_layout()
+
+fig1.savefig(os.path.join(opDir, "DLInt-1_2memVSynCurrents.png"), dpi=150)
+

+ 78 - 0
runJODLInt1DLInt2Multiple.py

@@ -0,0 +1,78 @@
+from JODLInt1DLInt2 import runJODLInt1DLInt2
+from brian2 import units
+
+simSettleTime = 600 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 150 * units.ms
+# inputParsNames = [
+#     'onePulse',
+#     'twoPulse',
+#     'threePulse',
+#     "tenMSPulse",
+#     "twentyMSPulse",
+#     "thirtyMSPulse",
+#     "fortyMSPulse",
+# ]
+# showBefore = 50 * units.ms
+# showAfter = 50 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 450 * units.ms
+# inputParsNames = [
+#     "pTShortInt20Dur10",
+#     "pTShortInt20Dur16",
+#     "pTShortInt33Dur10",
+#     "pTShortInt33Dur16",
+#     "pTShortInt33Dur20",
+#     "pTShortInt50Dur10",
+#     "pTShortInt50Dur16",
+#     "pTShortInt50Dur20",
+#     "pTShortInt100Dur10",
+#     "pTShortInt100Dur16",
+#     "pTShortInt100Dur20",
+# ]
+# showBefore = 100 * units.ms
+# showAfter = 100 * units.ms
+
+simStepSize = 0.1 * units.ms
+simDuration = 1500 * units.ms
+inputParsNames = [
+    'oneSecondPulse',
+    # 'pulseTrainInt33Dur10',
+    # 'pulseTrainInt33Dur16',
+    # 'pulseTrainInt20Dur10',
+    # 'pulseTrainInt20Dur16',
+    # 'pulseTrainInt50Dur10',
+    # 'pulseTrainInt50Dur16',
+    # 'pulseTrainInt50Dur20',
+]
+showBefore = 500 * units.ms
+showAfter = 500 * units.ms
+
+DLInt1ModelProps = "DLInt1Aynur"
+
+
+DLInt2ModelProps = "DLInt2Try2"
+
+
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
+# DLInt1SynapsePropsE = ""
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
+# DLInt1SynapsePropsI = ""
+
+DLInt2SynapseProps = 'DLInt2_syn_try2'
+# DLInt2SynapseProps = ""
+
+
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
+# DLInt1DLInt2SynProps = ""
+
+for inputParsName in inputParsNames:
+    runJODLInt1DLInt2(simStepSize, simDuration, simSettleTime,
+                      inputParsName, showBefore, showAfter,
+                      DLInt1ModelProps, DLInt2ModelProps,
+                      DLInt1SynapsePropsE, DLInt1SynapsePropsI,
+                      DLInt2SynapseProps, DLInt1DLInt2SynProps,
+                      askReplace=False
+                      )

+ 16 - 0
setup.py

@@ -0,0 +1,16 @@
+from setuptools import setup, find_packages
+setup(
+        name="hb_pac_disNet",
+        use_scm_version=True,
+        setup_requires=['setuptools_scm'],
+        packages=find_packages(exclude=["^\."]),
+        exclude_package_data={'': ["Readme.md", "tests"]},
+        install_requires=["numpy>=1.11.2",
+                          "matplotlib>=1.5.3",
+                          "seaborn>=0.7.1",
+                          "neo>=0.5.0",
+                          "nixio>=1.3",
+                          "brian2>=2.0.1",
+                          "ipython>=6.1"],
+        python_requires=">=3.5",
+    )

+ 389 - 0
simSynCurrents.py

@@ -0,0 +1,389 @@
+import os
+import sys
+
+import seaborn as sns
+from brian2 import defaultclock, units, StateMonitor
+from matplotlib import pyplot as plt
+from brian2.core.network import Network
+from dirDefs import homeFolder
+from models.neuronModels import VSNeuron, JOSpikes265, getSineInput
+from models.neurons import AdExp
+from models.synapses import exp2Syn, exp2SynStateInits
+from mplPars import mplPars
+from paramLists import synapsePropsList, inputParsList, AdExpPars
+
+
+from neo import AnalogSignal
+import nixio
+from neoNIXIO import addAnalogSignal2Block, addMultiTag
+import quantities as qu
+from brianUtils import addBrianQuantity2Section
+sns.set(style="whitegrid", rc=mplPars)
+
+
+simSettleTime = 600 * units.ms
+
+simStepSize = 0.1 * units.ms
+simDuration = 150 * units.ms
+# inputParsName = 'onePulse'
+# inputParsName = 'twoPulse'
+# inputParsName = 'threePulse'
+inputParsName = "thirtyMSPulse"
+# inputParsName = "fortyMSPulse"
+showBefore = 50 * units.ms
+showAfter = 50 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 450 * units.ms
+# # inputParsName = "pTShortInt20Dur10"
+# # inputParsName = "pTShortInt20Dur16"
+# # inputParsName = "pTShortInt33Dur10"
+# # inputParsName = "pTShortInt33Dur16"
+# # inputParsName = "pTShortInt33Dur20"
+# # inputParsName = "pTShortInt50Dur10"
+# # inputParsName = "pTShortInt50Dur16"
+# # inputParsName = "pTShortInt50Dur20"
+# inputParsName = "pTShortInt100Dur10"
+# # inputParsName = "pTShortInt100Dur16"
+# # inputParsName = "pTShortInt100Dur20"
+#
+# showBefore = 100 * units.ms
+# showAfter = 100 * units.ms
+
+# simStepSize = 0.1 * units.ms
+# simDuration = 1500 * units.ms
+# # inputParsName = 'oneSecondPulse'
+# # inputParsName = 'pulseTrainInt20Dur10'
+# inputParsName = 'pulseTrainInt20Dur16'
+# # inputParsName = 'pulseTrainInt33Dur10'
+# # inputParsName = 'pulseTrainInt33Dur16'
+# showBefore = 500 * units.ms
+# showAfter = 500 * units.ms
+
+DLInt1ModelProps = "DLInt1Aynur"
+
+DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
+# DLInt1SynapsePropsE = ""
+DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
+# DLInt1SynapsePropsI = ""
+DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
+
+DLInt2ModelProps = "DLInt2Try2"
+
+DLInt2SynapseProps = 'DLInt2_syn_try2'
+
+DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
+
+opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
+                         DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
+                         inputParsName)
+opFileDLInt1 = os.path.join(opDir, 'SynCurrentTracesDLInt1.png')
+opFileDLInt2 = os.path.join(opDir, 'SynCurrentTracesDLInt2.png')
+OPNixFile = os.path.join(opDir, 'simResWithSynCurrents.h5')
+if os.path.isfile(OPNixFile):
+    ch = input('Results already exist at {}. Delete?(y/n):'.format(OPNixFile))
+    if ch == 'y':
+        os.remove(OPNixFile)
+        if os.path.isfile(opFileDLInt1):
+            os.remove(opFileDLInt1)
+        if os.path.isfile(opFileDLInt2):
+            os.remove(opFileDLInt2)
+    else:
+        sys.exit('User Abort!')
+
+elif not os.path.isdir(opDir):
+    os.makedirs(opDir)
+
+inputPars = getattr(inputParsList, inputParsName)
+
+
+net = Network()
+JO = JOSpikes265(nOutputs=1, simSettleTime=simSettleTime, **inputPars)
+net.add(JO.JOSGG)
+
+DLInt1PropsDict = getattr(AdExpPars, DLInt1ModelProps)
+dlint1 = VSNeuron(**AdExp, inits=DLInt1PropsDict, name='dlint1')
+dlint1.recordSpikes()
+dlint1.recordMembraneV()
+
+if DLInt1SynapsePropsE:
+    synPropsEDLInt1 = getattr(synapsePropsList, DLInt1SynapsePropsE)
+    dlint1.addSynapse(synName="ExiJO", sourceNG=JO.JOSGG, **exp2Syn,
+                          synParsInits=synPropsEDLInt1,
+                          synStateInits=exp2SynStateInits,
+                          sourceInd=0, destInd=0
+                          )
+if DLInt1SynapsePropsI:
+    synPropsIDLInt1 = getattr(synapsePropsList, DLInt1SynapsePropsI)
+    dlint1.addSynapse(synName="InhJO", sourceNG=JO.JOSGG, **exp2Syn,
+                          synParsInits=synPropsIDLInt1,
+                          synStateInits=exp2SynStateInits,
+                          sourceInd=0, destInd=0
+                          )
+
+dlint1.addToNetwork(net)
+
+if DLInt1SynapsePropsE:
+    gEMonitorDLInt1 = StateMonitor(dlint1.incomingSynapses["ExiJO"], "g_ExiJO", record=True)
+    net.add(gEMonitorDLInt1)
+
+if DLInt1SynapsePropsI:
+    gIMonitorDLInt1 = StateMonitor(dlint1.incomingSynapses["InhJO"], "g_InhJO", record=True)
+    net.add(gIMonitorDLInt1)
+
+DLInt2PropsDict = getattr(AdExpPars, DLInt2ModelProps)
+dlint2 = VSNeuron(**AdExp, inits=DLInt2PropsDict, name='dlint2')
+dlint2.recordMembraneV()
+dlint2.recordSpikes()
+
+if DLInt2SynapseProps:
+    synPropsEDLInt2 = getattr(synapsePropsList, DLInt2SynapseProps)
+    dlint2.addSynapse(synName="ExiJO", sourceNG=JO.JOSGG, **exp2Syn,
+                          synParsInits=synPropsEDLInt2,
+                          synStateInits=exp2SynStateInits,
+                          sourceInd=0, destInd=0
+                          )
+
+if DLInt1DLInt2SynProps:
+    synPropsIDLInt2 = getattr(synapsePropsList, DLInt1DLInt2SynProps)
+    dlint2.addSynapse(synName="DLInt1", sourceNG=dlint1.ng, **exp2Syn,
+                          synParsInits=synPropsIDLInt2,
+                          synStateInits=exp2SynStateInits,
+                          sourceInd=0, destInd=0
+                          )
+
+
+dlint2.addToNetwork(net)
+
+if DLInt2SynapseProps:
+    gEMonitorDLInt2 = StateMonitor(dlint2.incomingSynapses["ExiJO"], "g_ExiJO", record=True)
+    net.add(gEMonitorDLInt2)
+
+if DLInt1DLInt2SynProps:
+    gIMonitorDLInt2 = StateMonitor(dlint2.incomingSynapses["DLInt1"], "g_DLInt1", record=True)
+    net.add(gIMonitorDLInt2)
+
+defaultclock.dt = simStepSize
+totalSimDur = simDuration + simSettleTime
+net.run(totalSimDur, report='text')
+
+simT, DLInt2memV = dlint2.getMemVTrace()
+DLInt2spikeTimes = dlint2.getSpikes()
+
+dlint2MemVAS = AnalogSignal(signal=DLInt2memV / units.mV,
+                            sampling_period=(simStepSize / units.ms) * qu.ms,
+                            t_start=0 * qu.mV,
+                            units="mV",
+                            name="DLInt2 MemV")
+
+dlint2SpikesQU = (DLInt2spikeTimes / units.ms) * qu.ms
+
+simT, DLInt1memV = dlint1.getMemVTrace()
+DLInt1spikeTimes = dlint1.getSpikes()
+
+dlint1MemVAS = AnalogSignal(signal=DLInt1memV / units.mV,
+                            sampling_period=(simStepSize / units.ms) * qu.ms,
+                            t_start=0 * qu.mV,
+                            units="mV",
+                            name="DLInt1 MemV")
+
+dlint1SpikesQU = (DLInt1spikeTimes / units.ms) * qu.ms
+
+
+joSpikesQU = (JO.spikeTimes / units.ms) * qu.ms
+
+sineInput = getSineInput(simDur=simDuration, simStepSize=simStepSize,
+                         sinPulseDurs=inputPars['sinPulseDurs'],
+                         sinPulseStarts=inputPars['sinPulseStarts'],
+                         freq=265 * units.Hz, simSettleTime=simSettleTime)
+
+inputAS = AnalogSignal(signal=sineInput,
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
+                                t_start=0 * qu.mV,
+                                units="um",
+                                name="Input Vibration Signal")
+
+fig, axs = plt.subplots(nrows=3, figsize=(10, 6.25), sharex='col')
+axs[0].plot(simT / units.ms, DLInt2memV / units.mV)
+spikesY = DLInt2memV.min() + 1.05 * (DLInt2memV.max() - DLInt2memV.min())
+axs[0].plot(DLInt2spikeTimes / units.ms, [spikesY / units.mV] * DLInt2spikeTimes.shape[0], 'k^')
+axs[0].set_ylabel('DLInt2\nMembrane\nPotential\n(mV)')
+axs[0].set_xlim([(simSettleTime - showBefore) / units.ms,
+                     (totalSimDur + showAfter) / units.ms])
+
+fig1, axs1 = plt.subplots(nrows=3, figsize=(10, 6.25), sharex='col')
+axs1[0].plot(simT / units.ms, DLInt1memV / units.mV)
+spikesY = DLInt1memV.min() + 1.05 * (DLInt1memV.max() - DLInt1memV.min())
+axs1[0].plot(DLInt1spikeTimes / units.ms, [spikesY / units.mV] * DLInt1spikeTimes.shape[0], 'k^')
+axs1[0].set_ylabel('DLInt1\nMembrane\nPotential\n(mV)')
+axs1[0].set_xlim([(simSettleTime - showBefore) / units.ms,
+                     (totalSimDur + showAfter) / units.ms])
+
+if DLInt2SynapseProps:
+    gSynEDLInt2 = gEMonitorDLInt2.g_ExiJO[0]
+    iSynEDLInt2 = -gSynEDLInt2 * (DLInt2memV - synPropsEDLInt2['Esyn'])
+    axs[1].plot(simT / units.ms,
+                iSynEDLInt2 / units.nA, 'm-', label=r'$I_{synE}$')
+    iSynEASDLInt2 = AnalogSignal(signal=iSynEDLInt2 / units.nA,
+                           sampling_period=(simStepSize / units.ms) * qu.ms,
+                           t_start=0 * qu.mV,
+                           units="nA",
+                           name="DL-Int-2 input EPSC")
+
+if DLInt1DLInt2SynProps:
+    gSynI = gIMonitorDLInt2.g_DLInt1[0]
+    iSynI = -gSynI * (DLInt2memV - synPropsIDLInt2['Esyn'])
+    axs[1].plot(simT / units.ms,
+                iSynI / units.nA, 'c-', label=r'$I_{synI}$')
+    iSynIASDLInt2 = AnalogSignal(signal=iSynI / units.nA,
+                           sampling_period=(simStepSize / units.ms) * qu.ms,
+                           t_start=0 * qu.mV,
+                           units="nA",
+                           name="DL-Int-2 input IPSC")
+
+axs[1].legend(loc='center right')
+axs[1].set_ylabel("Synaptic\ncurrents\n(nA)")
+
+axs[2].plot(simT / units.ms, sineInput,
+            color=[130. / 255, 72. / 255, 7. / 255], ls='-', marker='None',
+            label='Vibration Input')
+axs[2].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
+        label='JO Spikes')
+axs[2].legend(loc='center right')
+axs[2].set_xlabel('time (ms)')
+axs[2].set_ylabel('Input')
+fig.tight_layout()
+fig.canvas.draw()
+# plt.show()
+fig.savefig(opFileDLInt2, dpi=150)
+
+if DLInt1SynapsePropsE:
+    gSynEDLInt1 = gEMonitorDLInt1.g_ExiJO[0]
+    iSynEDLInt1 = -gSynEDLInt1 * (DLInt1memV - synPropsEDLInt1['Esyn'])
+    axs1[1].plot(simT / units.ms,
+                iSynEDLInt1 / units.nA, 'r-', label=r'$I_{synE}$')
+    iSynEASDLInt1 = AnalogSignal(signal=iSynEDLInt1 / units.nA,
+                                sampling_period=(simStepSize / units.ms) * qu.ms,
+                                t_start=0 * qu.mV,
+                                units="nA",
+                                name="DL-Int-1 input EPSC")
+
+if DLInt1SynapsePropsI:
+    gSynIDLInt1 = gIMonitorDLInt1.g_InhJO[0]
+    iSynIDLInt1 = -gSynIDLInt1 * (DLInt1memV - synPropsIDLInt1['Esyn'])
+    axs1[1].plot(simT / units.ms,
+                iSynIDLInt1 / units.nA, 'g-', label=r'$I_{synI}$')
+    iSynIASDLInt1 = AnalogSignal(signal=iSynIDLInt1 / units.nA,
+                           sampling_period=(simStepSize / units.ms) * qu.ms,
+                           t_start=0 * qu.mV,
+                           units="nA",
+                           name="DL-Int-1 input IPSC")
+
+
+axs1[1].legend(loc='center right')
+axs1[1].set_ylabel("Synaptic\ncurrents\n(nA)")
+
+axs1[2].plot(simT / units.ms, sineInput,
+            color=[130. / 255, 72. / 255, 7. / 255], ls='-', marker='None',
+            label='Vibration Input')
+axs1[2].plot(JO.spikeTimes / units.ms, [sineInput.max() * 1.05] * len(JO.spikeTimes), 'k^',
+        label='JO Spikes')
+axs1[2].legend(loc='center right')
+axs1[2].set_xlabel('time (ms)')
+axs1[2].set_ylabel('Input')
+fig1.tight_layout()
+fig1.canvas.draw()
+# plt.show()
+fig1.savefig(opFileDLInt1, dpi=150)
+
+nixFile = nixio.File.open(OPNixFile, mode=nixio.FileMode.ReadWrite)
+neuronModels = nixFile.create_section("Neuron Models", "Model Parameters")
+
+DLInt1PropsSec = neuronModels.create_section("DL-Int-1", "AdExp")
+
+for propName, propVal in DLInt1PropsDict.items():
+    addBrianQuantity2Section(DLInt1PropsSec, propName, propVal)
+
+DLInt2PropsSec = neuronModels.create_section("DL-Int-2", "AdExp")
+
+for propName, propVal in DLInt2PropsDict.items():
+    addBrianQuantity2Section(DLInt2PropsSec, propName, propVal)
+
+inputSec = nixFile.create_section("Input Parameters", "Sinusoidal Pulses")
+
+for parName, parVal in inputPars.items():
+    addBrianQuantity2Section(inputSec, parName, parVal)
+
+addBrianQuantity2Section(inputSec, "simSettleTime", simSettleTime)
+
+brianSimSettingsSec = nixFile.create_section("Simulation Parameters", "Brian Simulation")
+addBrianQuantity2Section(brianSimSettingsSec, "simStepSize", simStepSize)
+addBrianQuantity2Section(brianSimSettingsSec, "totalSimDuration", totalSimDur)
+brianSimSettingsSec.create_property("method", nixio.Value("euler"))
+
+
+synPropsSec = nixFile.create_section("Synapse Models", "Model Parameters")
+
+if DLInt1SynapsePropsE:
+
+    JODLInt1SynESec = synPropsSec.create_section("JODLInt1Exi", "DoubleExpSyn")
+    JODLInt1SynEDict = getattr(synapsePropsList, DLInt1SynapsePropsE)
+
+    for propName, propVal in JODLInt1SynEDict.items():
+        addBrianQuantity2Section(JODLInt1SynESec, propName, propVal)
+
+    JODLInt1SynESec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
+    JODLInt1SynESec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
+
+
+if DLInt1SynapsePropsI:
+
+    JODLInt1SynISec = synPropsSec.create_section("JODLInt1Inh", "DoubleExpSyn")
+    JODLInt1SynIDict = getattr(synapsePropsList, DLInt1SynapsePropsI)
+
+    for propName, propVal in JODLInt1SynIDict.items():
+        addBrianQuantity2Section(JODLInt1SynISec, propName, propVal)
+    JODLInt1SynISec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
+    JODLInt1SynISec.create_property("PostSynaptic Neuron", nixio.Value("DLInt1"))
+
+if DLInt2SynapseProps:
+
+    JODLInt2SynESec = synPropsSec.create_section("JODLInt2Exi", "DoubleExpSyn")
+    JODLInt2SynEDict = getattr(synapsePropsList, DLInt2SynapseProps)
+
+    for propName, propVal in JODLInt2SynEDict.items():
+        addBrianQuantity2Section(JODLInt2SynESec, propName, propVal)
+    JODLInt2SynESec.create_property("PreSynaptic Neuron", nixio.Value("JO"))
+    JODLInt2SynESec.create_property("PostSynaptic Neuron", nixio.Value("DLInt2"))
+
+if DLInt1DLInt2SynProps:
+
+    DLInt1DLInt2SynSec = synPropsSec.create_section("DLInt1DLInt2Inh", "DoubleExpSyn")
+    DLInt1DLInt2SynDict = getattr(synapsePropsList, DLInt1DLInt2SynProps)
+
+    for propName, propVal in DLInt1DLInt2SynDict.items():
+        addBrianQuantity2Section(DLInt1DLInt2SynSec, propName, propVal)
+    DLInt1DLInt2SynSec.create_property("PreSynaptic Neuron", nixio.Value("DLInt1"))
+    DLInt1DLInt2SynSec.create_property("PostSynaptic Neuron", nixio.Value("DLInt2"))
+
+blk = nixFile.create_block("Simulation Traces", "Brian Output")
+DLInt2DA = addAnalogSignal2Block(blk, dlint2MemVAS)
+DLInt1DA = addAnalogSignal2Block(blk, dlint1MemVAS)
+inputDA = addAnalogSignal2Block(blk, inputAS)
+if DLInt1SynapsePropsE:
+    epscAS = addAnalogSignal2Block(blk, iSynEASDLInt1)
+if DLInt1SynapsePropsI:
+    ipscAS = addAnalogSignal2Block(blk, iSynIASDLInt1)
+if DLInt2SynapseProps:
+    epscAS = addAnalogSignal2Block(blk, iSynEASDLInt2)
+if DLInt1DLInt2SynProps:
+    ipscAS = addAnalogSignal2Block(blk, iSynIASDLInt2)
+
+addMultiTag("DLInt2 Spikes", type="Spikes", positions=dlint2SpikesQU,
+            blk=blk, refs=[DLInt2DA])
+addMultiTag("DLInt1 Spikes", type="Spikes", positions=dlint1SpikesQU,
+            blk=blk, refs=[DLInt2DA])
+addMultiTag("JO Spikes", type="Spikes", positions=joSpikesQU,
+            blk=blk, refs=[inputDA])
+
+nixFile.close()