plotMemVs.py 4.1 KB

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