我必须做1个神经元的光栅图,有10个数据试验,时间是4500毫秒。
import numpy as np
import matplotlib.pyplot as plt
#Plotting 1 neuron with 12 trials of info
maatriks = []
for i in range(1,14):
if i<10:
string = 'C:\\Users\\latel\\Desktop\\kool\\Neuro\\prax3\\data\\lgn\\plain\\neuron_01_stimulus_0'+str(i)+'.csv'
else:
string = 'C:\\Users\\latel\\Desktop\\kool\\Neuro\\prax3\\data\\lgn\\plain\\neuron_01_stimulus_'+str(i)+'.csv'
data_in = np.genfromtxt(string,dtype = 'int', delimiter = ',' or '\n')
maatriks.append(data_in)
data = np.array(maatriks)
print data.shape
spikes = np.array(data[8])
print spikes.shape
nonzeros = 0
for i,item in enumerate(spikes):
nonzeros += np.count_nonzero(item)
plt.scatter(item, i*np.ones(item.shape), marker = '|')
print nonzeros
plt.ylim(-1,len(spikes))
plt.xlim(0,len(spikes[0]))
plt.xlabel("Time is seconds")
plt.ylabel("Trial number")
plt.tight_layout()
plt.show()
这输出我(打印):
(13L,10L,4501L)
(10L,4501L)
55
但情节是空的,我无法理解为什么情节是空的。我认为应该有55行...
编辑:搞定了。添加了此代码。
for row in spikes:
for i in range(len(row)):
if (row[i] == 1):
row[i] = i
因为数据只有0或1.
任何人都知道怎么做得更短?