buh
This commit is contained in:
commit
b9573c6563
@ -21,7 +21,7 @@ spikes = read_baseline_spikes(os.path.join(data_dir, dataset))
|
||||
interspikeintervals = np.diff(spikes)
|
||||
|
||||
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
|
||||
plt.hist(interspikeintervals, bins=np.arange(0, np.max(interspikeintervals), 0.0001), color='darkblue')
|
||||
plt.hist(interspikeintervals, bins=np.arange(0, np.max(interspikeintervals), 0.0001), color='royalblue')
|
||||
plt.xlabel("time [ms]", fontsize = 22)
|
||||
plt.xticks(fontsize = 18)
|
||||
plt.ylabel("number of \n interspikeintervals", fontsize = 22)
|
||||
@ -83,10 +83,10 @@ plt.yticks(fontsize=18)
|
||||
ax1.spines['top'].set_visible(False)
|
||||
|
||||
ax2 = ax1.twinx()
|
||||
ax2.fill_between(time_axis, mu_eod+std_eod, mu_eod-std_eod, color='royalblue', alpha=0.5)
|
||||
ax2.fill_between(time_axis, mu_eod+std_eod, mu_eod-std_eod, color='navy', alpha=0.5)
|
||||
ax2.plot(time_axis, mu_eod, color='black', lw=2)
|
||||
ax2.set_ylabel('voltage [mV]', fontsize=22)
|
||||
ax2.tick_params(axis='y', labelcolor='darkblue')
|
||||
ax2.tick_params(axis='y', labelcolor='navy')
|
||||
ax2.spines['top'].set_visible(False)
|
||||
|
||||
plt.yticks(fontsize=18)
|
||||
|
@ -8,7 +8,7 @@ from IPython import embed
|
||||
# define sampling rate and data path
|
||||
sampling_rate = 40 #kHz
|
||||
data_dir = "../data"
|
||||
dataset = "2018-11-13-aj-invivo-1"
|
||||
dataset = "2018-11-14-al-invivo-1"
|
||||
inch_factor = 2.54
|
||||
# parameters for binning, smoothing and plotting
|
||||
cut_window = 60
|
||||
@ -23,8 +23,8 @@ spike_bins = np.arange(-cut_window, cut_window+1) #ms
|
||||
|
||||
# read data from files
|
||||
spikes = read_chirp_spikes(os.path.join(data_dir, dataset))
|
||||
eod = read_chirp_eod(os.path.join(data_dir, dataset))
|
||||
chirp_times = read_chirp_times(os.path.join(data_dir, dataset))
|
||||
#eod = read_chirp_eod(os.path.join(data_dir, dataset))
|
||||
#chirp_times = read_chirp_times(os.path.join(data_dir, dataset))
|
||||
|
||||
# make a delta f map for the quite more complicated keys
|
||||
df_map = map_keys(spikes)
|
||||
@ -42,12 +42,16 @@ for deltaf in df_map.keys():
|
||||
df_phase_time[deltaf] = {}
|
||||
df_phase_binary[deltaf] = {}
|
||||
for rep in df_map[deltaf]:
|
||||
chirp_size = int(rep[-1].strip('Hz'))
|
||||
# print(chirp_size)
|
||||
if chirp_size == 150:
|
||||
continue
|
||||
for phase in spikes[rep]:
|
||||
for idx in np.arange(num_bin):
|
||||
# check the phase
|
||||
if phase[1] > phase_vec[idx] and phase[1] < phase_vec[idx+1]:
|
||||
|
||||
# get spikes between 50 ms befor and after the chirp
|
||||
# get spikes between 60 ms before and after the chirp
|
||||
spikes_to_cut = np.asarray(spikes[rep][phase])
|
||||
spikes_cut = spikes_to_cut[(spikes_to_cut > -cut_window) & (spikes_to_cut < cut_window)]
|
||||
spikes_idx = np.round(spikes_cut*sampling_rate)
|
||||
@ -98,5 +102,5 @@ for df in df_phase_time.keys():
|
||||
fig.tight_layout()
|
||||
#plt.show()
|
||||
#exit()
|
||||
namefigure = '../figures/%s_%i_%i_firingrate.pdf' %(dataset, df, index_phase)
|
||||
plt.savefig(namefigure)
|
||||
namefigure = '../figures/%s_%i_%i_firingrate.png' %(dataset, df, index_phase)
|
||||
plt.savefig(namefigure)
|
||||
|
@ -1,30 +1,72 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import scipy.stats as ss
|
||||
from read_chirp_data import *
|
||||
from utility import *
|
||||
from IPython import embed
|
||||
|
||||
# define sampling rate and data path
|
||||
sampling_rate = 40 #kHz
|
||||
# define data path and important parameters
|
||||
data_dir = "../data"
|
||||
cut_window = 20
|
||||
sampling_rate = 40 #kHz
|
||||
cut_window = 40
|
||||
cut_range = np.arange(-cut_window * sampling_rate, 0, 1)
|
||||
window = 1
|
||||
|
||||
data = ["2018-11-13-aa-invivo-1", "2018-11-13-ac-invivo-1", "2018-11-13-ad-invivo-1", "2018-11-13-ah-invivo-1",
|
||||
'''
|
||||
# norm: -150, 150, 300
|
||||
data = ["2018-11-13-aa-invivo-1", "2018-11-13-ac-invivo-1","2018-11-13-ad-invivo-1", "2018-11-13-ah-invivo-1",
|
||||
"2018-11-13-ai-invivo-1", "2018-11-13-aj-invivo-1", "2018-11-13-ak-invivo-1", "2018-11-13-al-invivo-1"]
|
||||
|
||||
# norm: -50
|
||||
data = ["2018-11-20-aa-invivo-1", "2018-11-20-ab-invivo-1", "2018-11-20-ac-invivo-1","2018-11-20-ad-invivo-1",
|
||||
"2018-11-20-ae-invivo-1", "2018-11-20-af-invivo-1", "2018-11-20-ag-invivo-1", "2018-11-20-ah-invivo-1",
|
||||
"2018-11-20-ai-invivo-1"]
|
||||
|
||||
'''
|
||||
data = ["2018-11-14-aa-invivo-1", "2018-11-14-ac-invivo-1", "2018-11-14-ad-invivo-1", "2018-11-14-af-invivo-1",
|
||||
"2018-11-14-ag-invivo-1", "2018-11-14-ah-invivo-1", "2018-11-14-ai-invivo-1", "2018-11-14-ak-invivo-1",
|
||||
"2018-11-14-al-invivo-1", "2018-11-14-am-invivo-1", "2018-11-14-an-invivo-1"]
|
||||
|
||||
rates = {}
|
||||
|
||||
for dataset in data:
|
||||
spikes = read_chirp_spikes(os.path.join(data_dir, dataset))
|
||||
df_map = map_keys(spikes)
|
||||
print(dataset)
|
||||
for df in df_map.keys():
|
||||
beat_duration = 1/df
|
||||
'''
|
||||
if df == 50:
|
||||
pass
|
||||
else:
|
||||
continue
|
||||
'''
|
||||
|
||||
print(df)
|
||||
rep_rates = []
|
||||
beat_duration = int(abs(1 / df) * 1000)
|
||||
beat_window = 0
|
||||
while beat_window + beat_duration <= cut_window:
|
||||
while beat_window + beat_duration <= cut_window/2:
|
||||
beat_window = beat_window + beat_duration
|
||||
for rep in df_map[df]:
|
||||
for phase in spikes[rep]:
|
||||
response = spikes[rep][phase]
|
||||
# get spikes 40 ms before the chirp first chirp
|
||||
spikes_to_cut = np.asarray(spikes[rep][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:beat_window+window]
|
||||
rep_rates.append(np.std(train))
|
||||
break
|
||||
#cut = response[response[]]
|
||||
df_rate = np.mean(rep_rates)
|
||||
if df in rates.keys():
|
||||
rates[df].append(df_rate)
|
||||
else:
|
||||
rates[df] = [df_rate]
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
for i, k in enumerate(sorted(rates.keys())):
|
||||
ax.plot(np.ones(len(rates[k]))*k, rates[k], 'o')
|
||||
#ax.legend(sorted(rates.keys()), loc='upper left', bbox_to_anchor=(1.04, 1))
|
||||
fig.tight_layout()
|
||||
plt.show()
|
||||
|
@ -71,7 +71,7 @@ for dataset in data:
|
||||
# check the phase
|
||||
if phase[1] > phase_vec[idx] and phase[1] < phase_vec[idx+1]:
|
||||
|
||||
# get spikes between 50 ms before and after the chirp
|
||||
# get spikes between 40 ms before and after the chirp
|
||||
spikes_to_cut = np.asarray(spikes[rep][phase])
|
||||
spikes_cut = spikes_to_cut[(spikes_to_cut > -cut_window*2) & (spikes_to_cut < cut_window*2)]
|
||||
spikes_idx = np.round(spikes_cut*sampling_rate)
|
||||
|
@ -40,8 +40,8 @@ ax1 = fig.add_subplot(211)
|
||||
plt.yticks(fontsize=18)
|
||||
ax2 = fig.add_subplot(212, sharex=ax1)
|
||||
plt.setp(ax1.get_xticklabels(), visible=False)
|
||||
ax1.plot(time*1000, signal, color = 'royalblue', lw = 1)
|
||||
ax2.plot(time*1000, freq, color = 'royalblue', lw = 3)
|
||||
ax1.plot(time*1000, signal, color = 'midnightblue', lw = 1)
|
||||
ax2.plot(time*1000, freq, color = 'midnightblue', lw = 3)
|
||||
|
||||
ax1.set_ylabel("field [mV]", fontsize = 22)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user