plotSynCurrents.py 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import nixio
  2. from dirDefs import homeFolder
  3. import os
  4. import seaborn as sns
  5. from mplPars import mplPars
  6. from brian2 import units
  7. from matplotlib import pyplot as plt
  8. from neoNIXIO import multiTag2SpikeTrain, dataArray2AnalogSignal, simpleFloat
  9. import quantities as qu
  10. sns.set(rc=mplPars)
  11. simSettleTime = 600 * units.ms
  12. simStepSize = 0.1 * units.ms
  13. simDuration = 150 * units.ms
  14. # inputParsName = 'onePulse'
  15. # inputParsName = 'twoPulse'
  16. # inputParsName = 'threePulse'
  17. inputParsName = "thirtyMSPulse"
  18. # inputParsName = "fortyMSPulse"
  19. showBefore = 50 * units.ms
  20. showAfter = 0 * units.ms
  21. # simStepSize = 0.1 * units.ms
  22. # simDuration = 450 * units.ms
  23. # # inputParsName = "pTShortInt20Dur10"
  24. # # inputParsName = "pTShortInt20Dur16"
  25. # # inputParsName = "pTShortInt33Dur10"
  26. # # inputParsName = "pTShortInt33Dur16"
  27. # # inputParsName = "pTShortInt33Dur20"
  28. # # inputParsName = "pTShortInt50Dur10"
  29. # # inputParsName = "pTShortInt50Dur16"
  30. # # inputParsName = "pTShortInt50Dur20"
  31. # inputParsName = "pTShortInt100Dur10"
  32. # # inputParsName = "pTShortInt100Dur16"
  33. # # inputParsName = "pTShortInt100Dur20"
  34. #
  35. # showBefore = 100 * units.ms
  36. # showAfter = 100 * units.ms
  37. # simStepSize = 0.1 * units.ms
  38. # simDuration = 1500 * units.ms
  39. # # inputParsName = 'oneSecondPulse'
  40. # # inputParsName = 'pulseTrainInt20Dur10'
  41. # inputParsName = 'pulseTrainInt20Dur16'
  42. # # inputParsName = 'pulseTrainInt33Dur10'
  43. # # inputParsName = 'pulseTrainInt33Dur16'
  44. # showBefore = 500 * units.ms
  45. # showAfter = 500 * units.ms
  46. DLInt1ModelProps = "DLInt1Aynur"
  47. DLInt1SynapsePropsE = 'DLInt1_syn_try2_e'
  48. # DLInt1SynapsePropsE = ""
  49. DLInt1SynapsePropsI = 'DLInt1_syn_try2_i'
  50. # DLInt1SynapsePropsI = ""
  51. DLInt1SynapseProps = "".join((DLInt1SynapsePropsE, DLInt1SynapsePropsI))
  52. DLInt2ModelProps = "DLInt2Try2"
  53. DLInt2SynapseProps = 'DLInt2_syn_try2'
  54. DLInt1DLInt2SynProps = "DLInt1_DLInt2_try1"
  55. opDir = os.path.join(homeFolder, DLInt1ModelProps + DLInt2ModelProps,
  56. DLInt1SynapseProps + DLInt2SynapseProps + DLInt1DLInt2SynProps,
  57. inputParsName)
  58. OPNixFile = os.path.join(opDir, 'simResWithSynCurrents.h5')
  59. totalSimDur = simDuration + simSettleTime
  60. nixFile = nixio.File.open(OPNixFile, nixio.FileMode.ReadOnly)
  61. blk = nixFile.blocks["Simulation Traces"]
  62. dlint1MemV = blk.data_arrays["DLInt1 MemV"]
  63. isynEDLInt1 = blk.data_arrays["DL-Int-1 input EPSC"]
  64. isynIDLInt1 = blk.data_arrays["DL-Int-1 input IPSC"]
  65. dlint1SpikesMT = blk.multi_tags["DLInt1 Spikes"]
  66. dlint2MemV = blk.data_arrays["DLInt2 MemV"]
  67. isynEDLInt2 = blk.data_arrays["DL-Int-2 input EPSC"]
  68. isynIDLInt2 = blk.data_arrays["DL-Int-2 input IPSC"]
  69. dlint2SpikesMT = blk.multi_tags["DLInt2 Spikes"]
  70. sinInput = blk.data_arrays["Input Vibration Signal"]
  71. joSpikesMT = blk.multi_tags["JO Spikes"]
  72. dlint1MemVAS = dataArray2AnalogSignal(dlint1MemV)
  73. isynEASDLInt1 = dataArray2AnalogSignal(isynEDLInt1)
  74. isynIASDLInt1 = dataArray2AnalogSignal(isynIDLInt1)
  75. dlint2MemVAS = dataArray2AnalogSignal(dlint2MemV)
  76. isynEASDLInt2 = dataArray2AnalogSignal(isynEDLInt2)
  77. isynIASDLInt2 = dataArray2AnalogSignal(isynIDLInt2)
  78. sinInputAS = dataArray2AnalogSignal(sinInput)
  79. dlint1SpikesST = multiTag2SpikeTrain(dlint1SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
  80. dlint2SpikesST = multiTag2SpikeTrain(dlint2SpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
  81. joSpikesST = multiTag2SpikeTrain(joSpikesMT, sinInputAS.t_start, sinInputAS.t_stop)
  82. fig1, ax1 = plt.subplots(nrows=2, ncols=2, figsize=(14, 11.2), sharex='col')
  83. ax1[0, 0].plot(simpleFloat(dlint1MemVAS.times / qu.ms),
  84. simpleFloat(dlint1MemVAS / qu.mV), 'b-')
  85. markerline, stemlines, baseline \
  86. = ax1[0, 0].stem(simpleFloat(joSpikesST.times / qu.ms),
  87. [dlint1MemVAS.magnitude.min()] * joSpikesST.shape[0],
  88. linefmt='r-.', markerfmt='None', basefmt='None',
  89. bottom=-52.5)
  90. plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
  91. markerline, stemlines, baseline \
  92. = ax1[0, 0].stem(simpleFloat(joSpikesST.times / qu.ms),
  93. [10] * joSpikesST.shape[0],
  94. linefmt='r-.', markerfmt='None', basefmt='None',
  95. bottom=dlint1MemVAS.magnitude.max())
  96. plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
  97. ax1[0, 0].plot(simpleFloat(sinInputAS.times / qu.ms),
  98. simpleFloat((sinInputAS * 2.5 - 55 * qu.um) / qu.um),
  99. 'k-')
  100. ax1[0, 1].plot(simpleFloat(isynEASDLInt1.times / qu.ms),
  101. simpleFloat(isynEASDLInt1 / qu.nA), color=[0, 0.6, 0],
  102. ls='-', marker='None')
  103. ax1[0, 1].plot(simpleFloat(isynIASDLInt1.times / qu.ms),
  104. simpleFloat(isynIASDLInt1 / qu.nA), color=[1, 0, 0],
  105. ls='-', marker='None')
  106. markerline, stemlines, baseline \
  107. = ax1[0, 1].stem(simpleFloat(joSpikesST.times / qu.ms),
  108. [isynIASDLInt1.magnitude.min()] * joSpikesST.shape[0],
  109. linefmt='r-.', markerfmt='None', basefmt='None',
  110. bottom=-5.125)
  111. plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
  112. markerline, stemlines, baseline \
  113. = ax1[0, 1].stem(simpleFloat(joSpikesST.times / qu.ms),
  114. [5] * joSpikesST.shape[0],
  115. linefmt='r-.', markerfmt='None', basefmt='None',
  116. bottom=isynEASDLInt1.magnitude.max())
  117. plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
  118. ax1[0, 1].plot(simpleFloat(sinInputAS.times / qu.ms),
  119. simpleFloat((sinInputAS * 0.375 - 5.5 * qu.um) / qu.um),
  120. 'k-')
  121. ax1[1, 0].plot(simpleFloat(dlint2MemVAS.times / qu.ms),
  122. simpleFloat(dlint2MemVAS / qu.mV), 'b-')
  123. markerline, stemlines, baseline \
  124. = ax1[1, 0].stem(simpleFloat(joSpikesST.times / qu.ms),
  125. [dlint2MemVAS.magnitude.min()] * joSpikesST.shape[0],
  126. linefmt='r-.', markerfmt='None', basefmt='None',
  127. bottom=-52.5)
  128. plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
  129. markerline, stemlines, baseline \
  130. = ax1[1, 0].stem(simpleFloat(joSpikesST.times / qu.ms),
  131. [10] * joSpikesST.shape[0],
  132. linefmt='r-.', markerfmt='None', basefmt='None',
  133. bottom=dlint2MemVAS.magnitude.max())
  134. plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
  135. ax1[1, 0].plot(simpleFloat(sinInputAS.times / qu.ms),
  136. simpleFloat((sinInputAS * 2.5 - 55 * qu.um) / qu.um),
  137. 'k-')
  138. ax1[1, 1].plot(simpleFloat(isynEASDLInt2.times / qu.ms),
  139. simpleFloat(isynEASDLInt2 / qu.nA), color=[0, 0.6, 0],
  140. ls='-', marker='None')
  141. ax1[1, 1].plot(simpleFloat(isynIASDLInt2.times / qu.ms),
  142. simpleFloat(isynIASDLInt2 / qu.nA), color=[1, 0, 0],
  143. ls='-', marker='None')
  144. markerline, stemlines, baseline \
  145. = ax1[1, 1].stem(simpleFloat(joSpikesST.times / qu.ms),
  146. [isynIASDLInt2.magnitude.min()] * joSpikesST.shape[0],
  147. linefmt='r-.', markerfmt='None', basefmt='None',
  148. bottom=-5.125)
  149. plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
  150. markerline, stemlines, baseline \
  151. = ax1[1, 1].stem(simpleFloat(joSpikesST.times / qu.ms),
  152. [5] * joSpikesST.shape[0],
  153. linefmt='r-.', markerfmt='None', basefmt='None',
  154. bottom=isynEASDLInt2.magnitude.max())
  155. plt.setp(stemlines, color=(0.5, 0.5, 0.5), lw=2)
  156. ax1[1, 1].plot(simpleFloat(sinInputAS.times / qu.ms),
  157. simpleFloat((sinInputAS * 0.375 - 5.5 * qu.um) / qu.um),
  158. 'k-')
  159. ax1[1, 0].set_xlim([(simSettleTime - showBefore) / units.ms,
  160. (totalSimDur + showAfter) / units.ms])
  161. ax1[1, 1].set_xlim([(simSettleTime - showBefore) / units.ms,
  162. (totalSimDur + showAfter) / units.ms])
  163. for ax in ax1.flat:
  164. ax.set_xticklabels([""] * len(ax.get_xticks()))
  165. ax.set_yticklabels([""] * len(ax.get_yticks()))
  166. for fig in [fig1]:
  167. fig.tight_layout()
  168. fig1.savefig(os.path.join(opDir, "DLInt-1_2memVSynCurrents.png"), dpi=150)