Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. '''
  2. Record the spikes at a synapse with Brian 2. Note that you cannot use
  3. SpikeMonitor for this task, as it is only meant to record from a NeuronGroup
  4. (or another SpikeSource such as PoissonGroup).
  5. '''
  6. from brian2 import *
  7. # The record_spikes function only works with the numpy target
  8. prefs.codegen.target = 'numpy'
  9.  
  10. synapse_spikes = []
  11. @check_units(i=1, j=1, k=1, t=second, result=1)
  12. def record_spikes(i, j, k, t):
  13. for i, j, k in zip(i, j, k):
  14. synapse_spikes.append((i, j, k, t/second))
  15. return 0.0 # dummy result
  16.  
  17. G = NeuronGroup(2, 'dv/dt = 100*Hz : 1', threshold='v>1', reset='v=0')
  18. G.v = [0, 0.5]
  19. G2 = NeuronGroup(2, 'v:1')
  20. S = Synapses(G, G2, pre='dummy=record_spikes(i, j, k, t)',
  21. multisynaptic_index='k')
  22. S.connect('i==j', n=5)
  23. S.delay = 'k*1*ms'
  24. run(20*ms)
  25. # Transform to a 2D array (one row per spike)
  26. synapse_spikes = np.array(synapse_spikes)
  27. print(synapse_spikes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement