finally
This commit is contained in:
parent
ff2167a686
commit
ca4185a64a
@ -12,67 +12,78 @@ cut_window = 100
|
|||||||
cut_range = np.arange(-cut_window * sampling_rate, 0, 1)
|
cut_range = np.arange(-cut_window * sampling_rate, 0, 1)
|
||||||
window = 1
|
window = 1
|
||||||
inch_factor = 2.54
|
inch_factor = 2.54
|
||||||
#dataset = "2018-11-13-ad-invivo-1"
|
datasets = ["2018-11-13-ad-invivo-1", "2018-11-13-aj-invivo-1", \
|
||||||
#dataset = "2018-11-13-aj-invivo-1"
|
"2018-11-13-ak-invivo-1", "2018-11-14-ad-invivo-1"]
|
||||||
#dataset = "2018-11-13-ak-invivo-1" #al
|
# dataset = "2018-11-20-af-invivo-1"
|
||||||
#dataset = "2018-11-14-ad-invivo-1"
|
|
||||||
dataset = "2018-11-20-af-invivo-1"
|
|
||||||
|
|
||||||
base_spikes = read_baseline_spikes(os.path.join(data_dir, dataset))
|
fig = plt.figure()
|
||||||
base_spikes = base_spikes[1000:2000]
|
# figsize=(5 / inch_factor, 2.5 / inch_factor))
|
||||||
spikerate = len(base_spikes) / base_spikes[-1]
|
fig.set_size_inches((35/inch_factor, 15/inch_factor))
|
||||||
print(spikerate)
|
axes = []
|
||||||
|
axes.append(fig.add_subplot(221))
|
||||||
|
axes.append(fig.add_subplot(222))
|
||||||
|
axes.append(fig.add_subplot(223))
|
||||||
|
axes.append(fig.add_subplot(224))
|
||||||
|
|
||||||
# read spikes during chirp stimulation
|
for dataset, ax in zip(datasets, axes):
|
||||||
spikes = read_chirp_spikes(os.path.join(data_dir, dataset))
|
base_spikes = read_baseline_spikes(os.path.join(data_dir, dataset))
|
||||||
df_map = map_keys(spikes)
|
base_spikes = base_spikes[1000:2000]
|
||||||
|
spikerate = len(base_spikes) / base_spikes[-1]
|
||||||
|
print(spikerate)
|
||||||
|
|
||||||
rates = {}
|
# read spikes during chirp stimulation
|
||||||
# iterate over df
|
spikes = read_chirp_spikes(os.path.join(data_dir, dataset))
|
||||||
for deltaf in df_map.keys():
|
df_map = map_keys(spikes)
|
||||||
rates[deltaf] = {}
|
|
||||||
beat_duration = int(abs(1 / deltaf) * 1000)
|
|
||||||
beat_window = 0
|
|
||||||
while beat_window + beat_duration <= cut_window/2:
|
|
||||||
beat_window = beat_window + beat_duration
|
|
||||||
for x, repetition in enumerate(df_map[deltaf]):
|
|
||||||
for phase in spikes[repetition]:
|
|
||||||
# get spikes some ms before the chirp first chirp
|
|
||||||
spikes_to_cut = np.asarray(spikes[repetition][phase])
|
|
||||||
spikes_cut = spikes_to_cut[(spikes_to_cut > -cut_window) & (spikes_to_cut < 0)]
|
|
||||||
spikes_idx = np.round(spikes_cut * sampling_rate)
|
|
||||||
# also save as binary, 0 no spike, 1 spike
|
|
||||||
binary_spikes = np.isin(cut_range, spikes_idx) * 1
|
|
||||||
smoothed_data = smooth(binary_spikes, window, 1 / sampling_rate)
|
|
||||||
#train = smoothed_data[window*sampling_rate:beat_window*sampling_rate+window*sampling_rate]
|
|
||||||
modulation = np.std(smoothed_data)
|
|
||||||
rates[deltaf][x] = modulation
|
|
||||||
break
|
|
||||||
|
|
||||||
plt.close()
|
rates = {}
|
||||||
fig = plt.figure()
|
# iterate over df
|
||||||
#figsize=(5 / inch_factor, 2.5 / inch_factor))
|
for deltaf in df_map.keys():
|
||||||
fig.set_size_inches((5, 2.5))
|
rates[deltaf] = {}
|
||||||
ax = fig.add_subplot(111)
|
beat_duration = int(abs(1 / deltaf) * 1000)
|
||||||
for i, df in enumerate(sorted(rates.keys())):
|
beat_window = 0
|
||||||
max_rep = len(sorted(rates[df].keys()))-1
|
while beat_window + beat_duration <= cut_window/2:
|
||||||
for j, rep in enumerate(rates[df].keys()):
|
beat_window = beat_window + beat_duration
|
||||||
if j == max_rep:
|
for x, repetition in enumerate(df_map[deltaf]):
|
||||||
farbe = 'royalblue'
|
for phase in spikes[repetition]:
|
||||||
gro = 8
|
# get spikes some ms before the chirp first chirp
|
||||||
else:
|
spikes_to_cut = np.asarray(spikes[repetition][phase])
|
||||||
farbe = 'k'
|
spikes_cut = spikes_to_cut[(spikes_to_cut > -cut_window) & (spikes_to_cut < 0)]
|
||||||
gro = 6
|
spikes_idx = np.round(spikes_cut * sampling_rate)
|
||||||
ax.plot(df, rates[df][rep], marker='o', color=farbe, ms=gro)
|
# also save as binary, 0 no spike, 1 spike
|
||||||
|
binary_spikes = np.isin(cut_range, spikes_idx) * 1
|
||||||
|
smoothed_data = smooth(binary_spikes, window, 1 / sampling_rate)
|
||||||
|
modulation = np.std(smoothed_data)
|
||||||
|
rates[deltaf][x] = modulation
|
||||||
|
break
|
||||||
|
|
||||||
#ax.set_xlabel('difference frequency [Hz]', fontsize=20)
|
for i, df in enumerate(sorted(rates.keys())):
|
||||||
ax.set_ylabel('firing modulation', fontsize=16)
|
max_rep = len(sorted(rates[df].keys()))-1
|
||||||
ax.set_xlabel('$\Delta$f [Hz]', fontsize=16)
|
for j, rep in enumerate(rates[df].keys()):
|
||||||
|
if j == max_rep:
|
||||||
|
farbe = 'royalblue'
|
||||||
|
gro = 8
|
||||||
|
else:
|
||||||
|
farbe = 'k'
|
||||||
|
gro = 6
|
||||||
|
ax.plot(df, rates[df][rep], marker='o', color=farbe, ms=gro)
|
||||||
|
ax.set_xlim(-450, 800)
|
||||||
|
ax.set_ylim(0.1, 0.3)
|
||||||
|
ax.set_xticks(np.arange(-400, 810, 100))
|
||||||
|
ax.yaxis.set_tick_params(labelsize=18)
|
||||||
|
ax.xaxis.set_tick_params(labelsize=18)
|
||||||
|
ax.spines["top"].set_visible(False)
|
||||||
|
ax.spines["right"].set_visible(False)
|
||||||
|
|
||||||
ax.yaxis.set_tick_params(labelsize=14)
|
axes[0].set_ylabel('Firing rate modulation', fontsize=22)
|
||||||
ax.xaxis.set_tick_params(labelsize=14)
|
axes[0].yaxis.set_label_coords(-0.15, -.125)
|
||||||
|
axes[2].set_xlabel('$\Delta$f [Hz]', fontsize=22)
|
||||||
|
axes[3].set_xlabel('$\Delta$f [Hz]', fontsize=22)
|
||||||
|
axes[1].set_yticklabels([])
|
||||||
|
axes[3].set_yticklabels([])
|
||||||
|
axes[0].set_xticklabels([])
|
||||||
|
axes[1].set_xticklabels([])
|
||||||
|
axes[2].set_xticklabels(['-400', '', '-200', '', '0', '', '200', '', '400', '', '600', '', '800'], rotation=45)
|
||||||
|
axes[3].set_xticklabels(['-400', '', '-200', '', '0', '', '200', '', '400', '', '600', '', '800'], rotation=45)
|
||||||
|
|
||||||
ax.spines["top"].set_visible(False)
|
fig.subplots_adjust(left=0.09, bottom=0.175, right=0.975, top=0.95)
|
||||||
ax.spines["right"].set_visible(False)
|
|
||||||
fig.tight_layout()
|
|
||||||
fig.savefig('spikes_beat_20af.png')
|
fig.savefig('spikes_beat_20af.png')
|
||||||
|
@ -93,10 +93,21 @@ for df in df_phase_binary.keys():
|
|||||||
upper_limit = np.max(sorted(csi_rates.keys()))+30
|
upper_limit = np.max(sorted(csi_rates.keys()))+30
|
||||||
lower_limit = np.min(sorted(csi_rates.keys()))-30
|
lower_limit = np.min(sorted(csi_rates.keys()))-30
|
||||||
|
|
||||||
fig, ax = plt.subplots()
|
inch_factor = 2.54
|
||||||
|
|
||||||
|
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
|
||||||
ax.plot([lower_limit, upper_limit], np.zeros(2), 'silver', linewidth=2, linestyle='--')
|
ax.plot([lower_limit, upper_limit], np.zeros(2), 'silver', linewidth=2, linestyle='--')
|
||||||
for i, df in enumerate(sorted(csi_rates.keys())):
|
for i, df in enumerate(sorted(csi_rates.keys())):
|
||||||
for j, phase in enumerate(sorted(csi_rates[df].keys())):
|
for j, phase in enumerate(sorted(csi_rates[df].keys())):
|
||||||
ax.plot(df, csi_rates[df][phase], 'o', color=colors[j], ms=sizes[j])
|
ax.plot(df, csi_rates[df][phase], 'o', color=colors[j], ms=sizes[j])
|
||||||
|
|
||||||
|
|
||||||
|
plt.xlabel("$\Delta$f", fontsize = 22)
|
||||||
|
plt.xticks(fontsize = 18)
|
||||||
|
plt.ylabel("CSI", fontsize = 22)
|
||||||
|
plt.yticks(fontsize = 18)
|
||||||
|
ax.spines["top"].set_visible(False)
|
||||||
|
ax.spines["right"].set_visible(False)
|
||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
plt.show()
|
#plt.show()
|
||||||
|
plt.savefig('CSI.png')
|
Loading…
Reference in New Issue
Block a user