-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspike_train.py
37 lines (24 loc) · 959 Bytes
/
spike_train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
######################################################## README #############################################################
# This file generates rate based spike train from the potential map.
############################################################################################################################
import numpy as np
from numpy import interp
import math
from parameters import *
def encode(pot):
#initializing spike train
train = []
for l in range(pixel_x):
for m in range(pixel_x):
temp = np.zeros([(T+1),])
#calculating firing rate proportional to the membrane potential
freq = interp(pot[l][m], [np.min(pot),np.max(pot)], [1,50])
time_period = math.ceil(T/freq)
#generating spikes according to the firing rate
time_of_spike = time_period
if(pot[l][m]>0):
while time_of_spike<(T+1):
temp[int(time_of_spike)] = 1
time_of_spike+= time_period
train.append(temp)
return train