movingcomb/raster_plot.py

49 lines
1.7 KiB
Python

# ---------------------------------------------------------------------------------------------------------------------
# Name: Firing Rate and Fourier Script (moving comb repro)
# Purpose: Takes nixio spike data from moving comb repro and plots firing rate and power spectrum density graph
# Usage: python3 analysis_graphs.py average
# Author: Carolin Sachgau, University of Tuebingen
# Created: 20/09/2018
# ---------------------------------------------------------------------------------------------------------------------
from open_nixio import *
import numpy as np
import matplotlib.pyplot as plt
from IPython import embed
import sys
colorCodes = np.array([[0, 1, 1],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[1, 0, 1]])
sampling_rate = 20000
sigma = 0.01 # for Gaussian
delay = 1.5 # delay in seconds after comb reaches one end, before commencing movement again
cell_name = sys.argv[1].split('/')[-2]
curr_comb, intervals_dict = open_nixio(sys.argv[1], sys.argv[2])
for (speed, direct, comb) in intervals_dict:
s_trials = intervals_dict[(speed, direct, comb)]
spike_repeats = []
for trial in intervals_dict[(speed, direct, comb)]:
spike_train = trial[1]
spike_train = spike_train - spike_train[0] # changing spike train to start at 0 (subtracting baseline)
spike_repeats.append(spike_train)
fig, ax = plt.subplots()
plt.eventplot(spike_repeats, linelengths = 0.05, lineoffsets = 0.05)
ax.set_title('Raster Plot of ' + str((speed, direct)) + ' comb = ' + str(comb) + '\n')
ax.set_xlabel('Time (s)')
ax.set_ylabel('Trials')
plt.show()
plt.close