-
Notifications
You must be signed in to change notification settings - Fork 0
/
justDLInt1.py
130 lines (101 loc) · 4.07 KB
/
justDLInt1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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)