Skip to content

Instantly share code, notes, and snippets.

@prabhant
Created March 15, 2018 11:46
Show Gist options
  • Save prabhant/c4573de7d8ea410a9ee69c10f497ca0f to your computer and use it in GitHub Desktop.
Save prabhant/c4573de7d8ea410a9ee69c10f497ca0f to your computer and use it in GitHub Desktop.
raster plot for neuron spikes with python
import matplotlib.pyplot as plt
import numpy as np
from numpy import genfromtxt
#genfromtxt('my_file.csv', delimiter=',')
# Set the random seed for data generation
np.random.seed(2)
# Create rows of random data with 50 data points simulating rows of spike trains
data = genfromtxt('02-Data Analysis/data/lgn/plain/neuron_06_stimulus_07.csv', delimiter=',')
z=0
i=0
j=0
for i in range(10):
for j in range(4500):
if(data[i,j] == 1):
x1 = [i,i+0.5]
x2 = [j,j]
plt.plot(x2,x1,color = 'black')
else:
z= z+1
# # Provide the title for the spike raster plot
plt.title('raster plot Neuron-5-Stimulus-7')
# # Give x axis label for the spike raster plot
fig = plt.gcf()
fig.set_size_inches(18.5, 10.5)
fig.savefig('test1png.png', dpi=100)
# # Give y axis label for the spike raster plot
plt.ylabel('trial')
# # Display the spike raster plot
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment