Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

singleNeuronDynamics.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #
  2. # singleNeuronDynamics.py
  3. #
  4. # This file is part of the SpiNNaker Izhikevich polychronization model implementation.
  5. #
  6. # Copyright (C) 2018, Author: G. Trensch
  7. #
  8. # The SpiNNaker Izhikevich polychronization model implementation is free software:
  9. # you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # It is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this application. If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  23. # = Plot the individual neuron dynamics, i.e., v(t), for a regular spiking (RS type) and a fast spiking
  24. # = (FS type) Izhikevich neuron, that is stimulated with an external current of 5.0pA.
  25. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  26. import spynnaker8 as sim
  27. from pyNN.utility.plotting import Figure, Panel
  28. import pylab
  29. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  30. # = Simulation time and resolution
  31. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  32. SIM_TIME = 1000 # [ms]
  33. sim.setup( timestep = 1.0 )
  34. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  35. # = Neuron model and Izhikevich neuron parameters
  36. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  37. NEURON_MODEL = sim.Izhikevich
  38. # Regular spiking type Izhikevich neuron
  39. NEURON_PARAMS_RS = { 'a': 0.02
  40. , 'b': 0.2
  41. , 'c': -65.0
  42. , 'd': 8.0
  43. , 'v_init': -75.0
  44. , 'u_init': 0.0
  45. , 'i_offset': 5.0
  46. }
  47. # Fast spiking type Izhikevich neuron
  48. NEURON_PARAMS_FS = { 'a': 0.1
  49. , 'b': 0.2
  50. , 'c': -65.0
  51. , 'd': 2.0
  52. , 'v_init': -75.0
  53. , 'u_init': 0.0
  54. , 'i_offset': 5.0
  55. }
  56. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  57. # = Func: record membrane voltages to file in a printable ASCII format
  58. # =
  59. # = t [ms] v
  60. # = 000 -75.0 mV
  61. # = 001 -77.9880371094 mV
  62. # = 002 -78.662109375 mV
  63. # = 003 -78.6662902832 mV
  64. # = 004 -78.4951477051 mV
  65. # = ...
  66. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  67. def writeVtoDisk( population, fileName ):
  68. outFile = open(fileName, 'w')
  69. x = population.get_data('v')
  70. v = x.segments[0].filter(name='v')[0]
  71. for i in range(len(v)):
  72. time = str('{:03d}'.format(i))
  73. voltage = str(v[i][0])
  74. line = ' '.join([time, voltage, "\n"])
  75. outFile.writelines(line)
  76. outFile.close()
  77. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  78. # = Create an RS-type and FS-type Izhikevich neuron
  79. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  80. neuron_RS = sim.Population( 1, NEURON_MODEL(**NEURON_PARAMS_RS) )
  81. neuron_FS = sim.Population( 1, NEURON_MODEL(**NEURON_PARAMS_FS) )
  82. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  83. # = Set up recording of the membrane voltages for both neurons
  84. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  85. neuron_RS.record('v')
  86. neuron_FS.record('v')
  87. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  88. # = Run simulation
  89. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  90. sim.run( SIM_TIME )
  91. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  92. # = Retrieve and plot data, and write data to disk
  93. # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  94. v_neuron_RS = neuron_RS.get_data('v').segments[0].filter(name='v')[0]
  95. v_neuron_FS = neuron_FS.get_data('v').segments[0].filter(name='v')[0]
  96. writeVtoDisk( neuron_RS, "v(t)_RS_type.dat")
  97. writeVtoDisk( neuron_FS, "v(t)_FS_type.dat")
  98. Figure( Panel(v_neuron_RS, xticks = True, yticks = True, markersize = 2.0, xlabel = "regular spiking")
  99. , Panel(v_neuron_FS, xticks = True, yticks = True, markersize = 2.0, xlabel = "fast spiking")
  100. , annotations="Simulated with {}".format(sim.name())
  101. )
  102. sim.end()
  103. pylab.show()