Advertisement
Guest User

Orn_model.py

a guest
Feb 25th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. import nengo
  2. import numpy as np
  3. from random import *
  4. import csv
  5.  
  6.  
  7.  
  8. # Constants
  9. NUM_ORNS = 40
  10. DELTA = 0.01   # presentation_time
  11.  
  12.  
  13. # Read in list of 40 spike trains (40 lines in csv)
  14. with open('spike_trains.csv') as f:
  15.     reader = csv.reader(f)
  16.     spike_trains = np.array([[int(element) if element.isdigit() else element for element in sub] for sub in list(reader)])
  17.  
  18. # Spike trains to input
  19. spiked_neurons = [None]*NUM_ORNS
  20.  
  21.  
  22. # Init nengo model
  23. model = nengo.Network()
  24. with model:
  25.    
  26.     # Initialize one PRN that combines ORN inputs
  27.     prn = nengo.Ensemble(n_neurons=2, dimensions=1)
  28.    
  29.     # Iterate through each ORN and connect with PRN
  30.     for orn in range(NUM_ORNS):
  31.         # Initialize ORN
  32.         spiked_neurons[orn] = nengo.Node(nengo.processes.PresentInput(np.array(spike_trains[orn]), DELTA))
  33.        
  34.         # Connect ORN_orn to PRN
  35.         nengo.Connection(spiked_neurons[orn], prn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement