crazy analysis stuff
This commit is contained in:
parent
b1fb771d52
commit
9bb8d66478
@ -9,11 +9,14 @@ sampling_rate = 40 #kHz
|
|||||||
data_dir = "../data"
|
data_dir = "../data"
|
||||||
dataset = "2018-11-09-ad-invivo-1"
|
dataset = "2018-11-09-ad-invivo-1"
|
||||||
# parameters for binning, smoothing and plotting
|
# parameters for binning, smoothing and plotting
|
||||||
|
chirp_size = 14 #ms
|
||||||
|
neuronal_delay = 5 #ms
|
||||||
|
chirp_start = int((-chirp_size/2+neuronal_delay+50)*sampling_rate)
|
||||||
|
chirp_end = int((chirp_size/2+neuronal_delay+51)*sampling_rate)
|
||||||
num_bin = 12
|
num_bin = 12
|
||||||
window = 1
|
window = 1 #ms
|
||||||
time_axis = np.arange(-50, 50, 1/sampling_rate)
|
time_axis = np.arange(-50, 50, 1/sampling_rate) #steps
|
||||||
bin_size = 1
|
spike_bins = np.arange(-50, 51) #ms
|
||||||
spike_bins = np.arange(-50, 50+bin_size, bin_size)
|
|
||||||
|
|
||||||
# read data from files
|
# read data from files
|
||||||
spikes = read_chirp_spikes(os.path.join(data_dir, dataset))
|
spikes = read_chirp_spikes(os.path.join(data_dir, dataset))
|
||||||
@ -66,28 +69,33 @@ for deltaf in df_map.keys():
|
|||||||
for df in df_phase_time.keys():
|
for df in df_phase_time.keys():
|
||||||
for phase in df_phase_time[df].keys():
|
for phase in df_phase_time[df].keys():
|
||||||
|
|
||||||
# plot
|
trials_binary = df_phase_binary[df][phase]
|
||||||
plot_trials = df_phase_time[df][phase]
|
|
||||||
plot_trials_binary = np.mean(df_phase_binary[df][phase], axis=0)
|
|
||||||
|
|
||||||
# calculation
|
|
||||||
overall_spikerate = (np.sum(plot_trials_binary)/len(plot_trials_binary))*sampling_rate*1000
|
|
||||||
|
|
||||||
'''
|
sr_chirp = np.zeros(len(trials_binary))
|
||||||
spike_rate = np.zeros(len(spike_bins)-1)
|
sr_beat = np.zeros(len(trials_binary))
|
||||||
for idx in range(len(spike_bins)-1):
|
for i, trial in enumerate(trials_binary):
|
||||||
bin_start = spike_bins[idx]*sampling_rate
|
smoothed_trial = smooth(trial, window, 1/sampling_rate)
|
||||||
bin_end = spike_bins[idx+1]*sampling_rate
|
sr_chirp[i] = np.mean(smoothed_trial[chirp_start:chirp_end])
|
||||||
spike_rate[idx] = np.sum(plot_trials_binary[bin_start:bin_end])/bin_size*sampling_rate
|
sr_beat[i] = np.mean(smoothed_trial[0:chirp_start])
|
||||||
|
|
||||||
print(np.std(spike_rate))
|
for rate_chirp in sr_chirp:
|
||||||
plt.plot(spike_rate)
|
for rate_beat in sr_beat:
|
||||||
plt.show()
|
r = np.corrcoef(rate_chirp, rate_beat)
|
||||||
|
print(r)
|
||||||
|
|
||||||
embed()
|
embed()
|
||||||
exit()
|
exit()
|
||||||
'''
|
|
||||||
|
|
||||||
|
#csi = (spikerate_chirp-spikerate_befor)/(spikerate_chirp+spikerate_befor)
|
||||||
|
|
||||||
|
# plot
|
||||||
|
#plot_trials = df_phase_time[df][phase]
|
||||||
|
#plot_trials_binary = np.mean(df_phase_binary[df][phase], axis=0)
|
||||||
|
|
||||||
|
# calculation
|
||||||
|
#overall_spikerate = (np.sum(plot_trials_binary)/len(plot_trials_binary))*sampling_rate*1000
|
||||||
|
|
||||||
|
'''
|
||||||
smoothed_spikes = smooth(plot_trials_binary, window, 1./sampling_rate)
|
smoothed_spikes = smooth(plot_trials_binary, window, 1./sampling_rate)
|
||||||
|
|
||||||
fig, ax = plt.subplots(2, 1, sharex=True)
|
fig, ax = plt.subplots(2, 1, sharex=True)
|
||||||
@ -100,5 +108,17 @@ for df in df_phase_time.keys():
|
|||||||
|
|
||||||
ax[1].set_xlabel('time [ms]', fontsize=12)
|
ax[1].set_xlabel('time [ms]', fontsize=12)
|
||||||
ax[1].set_ylabel('firing rate [Hz]', fontsize=12)
|
ax[1].set_ylabel('firing rate [Hz]', fontsize=12)
|
||||||
print(overall_spikerate)
|
|
||||||
plt.show()
|
plt.show()
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
for trial in range(len(trials_binary)):
|
||||||
|
spike_rate = np.zeros(len(spike_bins)-1)
|
||||||
|
for idx in range(len(spike_bins)-1):
|
||||||
|
bin_start = spike_bins[idx]*sampling_rate
|
||||||
|
bin_end = spike_bins[idx+1]*sampling_rate
|
||||||
|
spike_rate[idx] = np.sum(trials_binary[trial][bin_start:bin_end])
|
||||||
|
embed()
|
||||||
|
exit()
|
||||||
|
'''
|
Loading…
Reference in New Issue
Block a user