-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotDLInt1DLInt2SynEffect.py
182 lines (135 loc) · 6.42 KB
/
plotDLInt1DLInt2SynEffect.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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)