zwischendrin

This commit is contained in:
efish 2018-11-29 16:47:30 +01:00
parent 3db401a3ea
commit b618c2d9ca
7 changed files with 96 additions and 57 deletions

View File

@ -8,7 +8,7 @@ from IPython import embed
data_dir = "../data" data_dir = "../data"
dataset = "2018-11-13-ah-invivo-1" dataset = "2018-11-13-ad-invivo-1"
data = ["2018-11-09-ad-invivo-1", "2018-11-09-ae-invivo-1", "2018-11-09-ag-invivo-1", "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", "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", "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-09-ad-invivo-1", "2018-11-09-ae-invivo-1", "2018-11-09-ag-invivo-1", "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", "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", "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"]
@ -41,7 +41,9 @@ for i in sort_df:
chirp_spikes = read_chirp_spikes(os.path.join(data_dir, dataset)) chirp_spikes = read_chirp_spikes(os.path.join(data_dir, dataset))
df_map = map_keys(chirp_spikes) df_map = map_keys(chirp_spikes)
sort_df = sorted(df_map.keys()) sort_df = sorted(df_map.keys())
dct_phase = plot_std_chirp(sort_df, df_map, chirp_spikes, chirp_mods) example = [-50, 200, 400]
dct_phase = plot_std_chirp(example, df_map, chirp_spikes, chirp_mods)
plt.show() plt.show()
plt.close('all') plt.close('all')

View File

@ -14,10 +14,16 @@ time,eod = read_baseline_eod(os.path.join(data_dir, dataset))
zeit = np.asarray(time) zeit = np.asarray(time)
plt.plot(zeit[0:1000], eod[0:1000])
plt.title('A.lepto EOD', fontsize = 18)#Plottitelk inch_factor = 2.54
plt.xlabel('time [ms]', fontsize = 16)#Achsentitel fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
plt.ylabel('amplitude[mv]', fontsize = 16)#Achsentitel
plt.xticks(fontsize = 14) plt.plot(zeit[0:1000], eod[0:1000], color = 'darkblue')
plt.yticks(fontsize = 14) plt.title('A.lepto EOD', fontsize = 24)#Plottitel
plt.xlabel('time [ms]', fontsize = 22)#Achsentitel
plt.ylabel('amplitude[mv]', fontsize = 22)#Achsentitel
plt.tick_params(axis='both', which='major', labelsize = 22)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
fig.tight_layout()
plt.show() plt.show()

View File

@ -12,25 +12,28 @@ data_base = ("2018-11-09-ab-invivo-1", "2018-11-09-ad-invivo-1", "2018-11-13-aa-
data_chirps = ("2018-11-09-ad-invivo-1", "2018-11-09-ae-invivo-1", "2018-11-09-ag-invivo-1", "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", "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", "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_chirps = ("2018-11-09-ad-invivo-1", "2018-11-09-ae-invivo-1", "2018-11-09-ag-invivo-1", "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", "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", "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")
dataset = "2018-11-13-ad-invivo-1" dataset = "2018-11-13-ad-invivo-1"
inch_factor = 2.54
#for dataset in data_base: #for dataset in data_base:
spike_times = read_baseline_spikes(os.path.join(data_dir, dataset)) spike_times = read_baseline_spikes(os.path.join(data_dir, dataset))
spike_iv = np.diff(spike_times) spike_iv = np.diff(spike_times)
x = np.arange(0.001, 0.01, 0.0001) x = np.arange(0.001, 0.01, 0.0001)
plt.hist(spike_iv,x)
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
plt.hist(spike_iv,x, color = 'darkblue')
mu = np.mean(spike_iv) mu = np.mean(spike_iv)
sigma = np.std(spike_iv) sigma = np.std(spike_iv)
cv = sigma/mu cv = sigma/mu
plt.title('A.lepto ISI Histogramm', fontsize = 18) plt.title('A.lepto ISI Histogramm', fontsize = 24)
plt.xlabel('duration ISI[ms]', fontsize = 16) plt.xlabel('duration ISI[ms]', fontsize = 22)
plt.ylabel('number of ISI', fontsize = 16) plt.ylabel('number of ISI', fontsize = 22)
plt.tick_params(axis='both', which='major', labelsize = 22)
plt.xticks(fontsize = 14) ax.spines['right'].set_visible(False)
plt.yticks(fontsize = 14) ax.spines['top'].set_visible(False)
plt.tight_layout()
plt.show() plt.show()
@ -47,6 +50,7 @@ sort_df = sorted(df_map.keys())
dct_rate, over_r = spike_rates(sort_df, df_map, chirp_spikes) dct_rate, over_r = spike_rates(sort_df, df_map, chirp_spikes)
plt.figure() plt.figure()
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
ls_mean = plot_df_spikes(sort_df, dct_rate) ls_mean = plot_df_spikes(sort_df, dct_rate)
plt.show() plt.show()
@ -54,14 +58,17 @@ plt.show()
#mittlere Feuerrate einer Frequenz auf Frequenz: #mittlere Feuerrate einer Frequenz auf Frequenz:
plt.figure() fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
plt.plot(np.arange(0,len(ls_mean),1),ls_mean) plt.plot(np.arange(0,len(ls_mean),1),ls_mean, color = 'darkblue')
plt.scatter(np.arange(0,len(ls_mean),1), np.ones(len(ls_mean))*over_r, color = 'green') plt.scatter(np.arange(0,len(ls_mean),1), np.ones(len(ls_mean))*over_r, color = 'green')
plt.title('Mean firing rate of a cell for a range of frequency differences', fontsize = 18) plt.title('Mean firing rate of a cell for a range of frequency differences', fontsize = 24)
plt.xticks(np.arange(1,len(sort_df),1), (sort_df)) plt.xticks(np.arange(1,len(sort_df),1), (sort_df))
plt.xlabel('Range of frequency differences [Hz]', fontsize = 16) plt.xlabel('Range of frequency differences [Hz]', fontsize = 22)
plt.ylabel('Mean firing rate of the cell', fontsize = 16) plt.ylabel('Mean firing rate of the cell', fontsize = 22)
plt.tick_params(axis='both', which='major', labelsize = 14) plt.tick_params(axis='both', which='major', labelsize = 18)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.tight_layout()
plt.show() plt.show()
@ -70,12 +77,15 @@ plt.show()
#wie viel Prozent der Anfangsrate macht die Adaption von Zellen aus? #wie viel Prozent der Anfangsrate macht die Adaption von Zellen aus?
adapt = adaptation_df(sort_df, dct_rate) adapt = adaptation_df(sort_df, dct_rate)
plt.figure() fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
plt.boxplot(adapt) plt.boxplot(adapt)
plt.title('Adaptation of cell firing rate during a trial', fontsize = 18) plt.title('Adaptation of cell firing rate during a trial', fontsize = 24)
plt.xlabel('Cell', fontsize = 16) plt.xlabel('Cell', fontsize = 22)
plt.ylabel('Adaptation size [Hz]', fontsize = 16) plt.ylabel('Adaptation size [Hz]', fontsize = 22)
plt.tick_params(axis='both', which='major', labelsize = 14) plt.tick_params(axis='both', which='major', labelsize = 18)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.tight_layout()
plt.show() plt.show()

View File

@ -2,8 +2,10 @@ from read_baseline_data import *
from read_chirp_data import * from read_chirp_data import *
from utility import * from utility import *
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import math
import numpy as np import numpy as np
inch_factor = 2.54
def chirp_eod_plot(df_map, eod, times): def chirp_eod_plot(df_map, eod, times):
#die äußere Schleife geht für alle Keys durch und somit durch alle dfs #die äußere Schleife geht für alle Keys durch und somit durch alle dfs
@ -11,7 +13,7 @@ def chirp_eod_plot(df_map, eod, times):
for i in df_map.keys(): for i in df_map.keys():
freq = list(df_map[i]) freq = list(df_map[i])
fig,axs = plt.subplots(2, 2, sharex = True, sharey = True) fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
for idx, k in enumerate(freq): for idx, k in enumerate(freq):
ct = times[k] ct = times[k]
@ -19,22 +21,28 @@ def chirp_eod_plot(df_map, eod, times):
zeit = e1[0] zeit = e1[0]
eods = e1[1] eods = e1[1]
if idx <= 3: if idx <= 1:
axs[0, 0].plot(zeit, eods, color= 'blue', linewidth = 0.25) ax.plot(zeit, eods, color= 'darkblue')
axs[0, 0].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22) ax.scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22)
elif 4<= idx <= 7: #elif 4<= idx <= 7:
axs[0, 1].plot(zeit, eods, color= 'blue', linewidth = 0.25) # axs[0, 1].plot(zeit, eods, color= 'blue', linewidth = 0.25)
axs[0, 1].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22) # axs[0, 1].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22)
elif 8<= idx <= 11: #elif 8<= idx <= 11:
axs[1, 0].plot(zeit, eods, color= 'blue', linewidth = 0.25) # axs[1, 0].plot(zeit, eods, color= 'blue', linewidth = 0.25)
axs[1, 0].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22) # axs[1, 0].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22)
else: else:
axs[1, 1].plot(zeit, eods, color= 'blue', linewidth = 0.25) continue
axs[1, 1].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22) #axs[1, 1].plot(zeit, eods, color= 'blue', linewidth = 0.25)
#axs[1, 1].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22)
ax.set_ylabel('Amplitude [mV]', fontsize = 22)
ax.set_xlabel('Time [ms]', fontsize = 22)
ax.tick_params(axis='both', which='major', labelsize = 18)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
fig.suptitle('EOD for chirps', fontsize = 24)
fig.tight_layout()
axs[0,1].set_ylabel('Amplitude [mV]')
axs[1,0].set_xlabel('Time [ms]')
fig.suptitle('EOD for chirps', fontsize = 16)
@ -69,7 +77,7 @@ def cut_chirps(freq, eod, times):
def plot_std_chirp(sort_df, df_map, chirp_spikes, chirp_mods): def plot_std_chirp(sort_df, df_map, chirp_spikes, chirp_mods):
plt.figure() fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
dct_phase = {} dct_phase = {}
num_bin = 12 num_bin = 12
phase_vec = np.arange(0, 1+1/num_bin, 1/num_bin) phase_vec = np.arange(0, 1+1/num_bin, 1/num_bin)
@ -82,10 +90,13 @@ def plot_std_chirp(sort_df, df_map, chirp_spikes, chirp_mods):
dct_phase[i].append(phase[1]) dct_phase[i].append(phase[1])
for i in sort_df: for i in sort_df:
plt.scatter(dct_phase[i], chirp_mods[i], label = i) norm = np.asarray(dct_phase[i]) *2*math.pi
plt.title('Change of std depending on the phase where the chirp occured') plt.scatter(norm, chirp_mods[i], label = i, s = 22)
plt.xlabel('Phase') plt.title('Change of std depending on the phase where the chirp occured', fontsize = 24)
plt.ylabel('Standard deviation of the amplitude modulation') plt.xlabel('Phase', fontsize = 22)
plt.ylabel('Standard deviation of the amplitude modulation', fontsize = 22)
plt.xticks([0, math.pi/2, math.pi, math.pi*1.5, math.pi*2], ('0', '$\pi$ /2', '$\pi$', '1.5 $\pi$', '2$\pi$'))
plt.tick_params(axis='both', which='major', labelsize = 18)
plt.legend() plt.legend()
return(dct_phase) return(dct_phase)

View File

@ -43,6 +43,8 @@ def spike_rates(sort_df, df_map, chirp_spikes):
def plot_df_spikes(sort_df, dct_rate): def plot_df_spikes(sort_df, dct_rate):
#gibt die Feuerrate gegen die Frequenz aufgetragen #gibt die Feuerrate gegen die Frequenz aufgetragen
inch_factor = 2.54
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
ls_mean = [] ls_mean = []
for h in sort_df: for h in sort_df:
mean = np.mean(dct_rate[h]) mean = np.mean(dct_rate[h])
@ -50,10 +52,13 @@ def plot_df_spikes(sort_df, dct_rate):
plt.plot(np.arange(0,len(dct_rate[h]),1),dct_rate[h], label = h) plt.plot(np.arange(0,len(dct_rate[h]),1),dct_rate[h], label = h)
plt.legend() plt.legend()
plt.title('Firing rate of the cell for all trials, sorted by df', fontsize = 18) plt.title('Firing rate of the cell for all trials, sorted by df', fontsize = 24)
plt.xlabel('# of trials', fontsize = 16) plt.xlabel('# of trials', fontsize = 22)
plt.ylabel('Instant firing rate of the cell', fontsize = 16) plt.ylabel('Instant firing rate of the cell', fontsize = 22)
plt.tick_params(axis='both', which='major', labelsize = 14) plt.tick_params(axis='both', which='major', labelsize = 18)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.tight_layout()
return(ls_mean) return(ls_mean)

View File

@ -12,6 +12,7 @@ data_chirps = ("2018-11-09-ad-invivo-1", "2018-11-09-ae-invivo-1", "2018-11-09-a
inch_factor = 2.54
data_rate_dict = {} data_rate_dict = {}
for dataset in data_chirps: for dataset in data_chirps:
@ -31,14 +32,17 @@ for dataset in data_chirps:
rate = len(spikes)/ 1.2 rate = len(spikes)/ 1.2
data_rate_dict[dataset].append(rate) data_rate_dict[dataset].append(rate)
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
for dataset in data_rate_dict: for dataset in data_rate_dict:
plt.plot(data_rate_dict[dataset]) plt.plot(data_rate_dict[dataset])
plt.title('Test for sequence effects', fontsize = 20)
plt.xlabel('Number of stimulus presentations', fontsize = 18)
plt.ylabel('Firing rates of cells', fontsize = 18)
plt.tick_params(axis='both', which='major', labelsize = 16)
plt.title('Test for sequence effects', fontsize = 24)
plt.xlabel('Number of stimulus presentations', fontsize = 22)
plt.ylabel('Firing rates of cells', fontsize = 22)
plt.tick_params(axis='both', which='major', labelsize = 22)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
fig.tight_layout()
plt.show() plt.show()

View File

@ -17,6 +17,7 @@ interspikeintervals = np.diff(spikes)*1000
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor)) 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='darkblue')
#Titel fehlt!!
plt.xlabel("time [ms]", fontsize = 22) plt.xlabel("time [ms]", fontsize = 22)
plt.xticks(fontsize = 18) plt.xticks(fontsize = 18)
plt.ylabel("Number of \n Interspikeinterval", fontsize = 22) plt.ylabel("Number of \n Interspikeinterval", fontsize = 22)