This commit is contained in:
efish 2018-11-16 17:51:42 +01:00
parent 7c9aa5eb92
commit 4bb17bc0bc
2 changed files with 54 additions and 55 deletions

View File

@ -5,39 +5,71 @@ import numpy as np
from IPython import embed
data_dir = "../data"
dataset = "2018-11-09-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")
spikes = read_chirp_spikes(os.path.join(data_dir, dataset))
dataset = "2018-11-09-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")
#for dataset in data:
eod = read_chirp_eod(os.path.join(data_dir, dataset))
times = read_chirp_times(os.path.join(data_dir, dataset))
df_map = {}
for k in spikes.keys():
df_map = {} #Keys werden nach df sortiert ausgegeben
for k in eod.keys():
df = k[1]
ch = k[3]
if df in df_map.keys():
df_map[df].append(k)
else:
df_map[df] = [k]
print(df_map.keys())
e1 = eod[0, '-50Hz', '20%', '100Hz']
#plt.plot(e1[1])
#plt.show()
plt.title('EOD chirps')
plt.xlabel('Frequency')
plt.ylabel('Amplitude')
plt.plot(e1[0],e1[1])
plt.show()
ct = times[0, '-50Hz', '20%', '100Hz']
#plt.scatter(ct*1000, np.ones(len(ct)))
plt.scatter(np.asarray(ct)*1000, np.ones(len(ct)))
print(ch) #die Chirphöhe wird ausgegeben, um zu bestimmen, ob Chirps oder Chirps large benutzt wurde
#die äußere Schleife geht für alle Keys durch und somit durch alle dfs
#die innnere Schleife bildet die 16 Wiederholungen einer Frequenz in 4 Subplots ab
for idx in df_map.keys():
freq = list(df_map[idx])
fig,axs = plt.subplots(2, 2, sharex = True, sharey = True)
for idx, k in enumerate(freq):
ct = times[k]
e1 = eod[k]
zeit = e1[0]
eods = e1[1]
if idx <= 3:
axs[0, 0].plot(zeit, eods, color= 'blue', linewidth = 0.25)
axs[0, 0].scatter(np.asarray(ct), np.ones(len(ct))*3, color = 'green', s= 22)
elif 4<= idx <= 7:
axs[0, 1].plot(zeit, eods, color= 'blue', linewidth = 0.25)
axs[0, 1].scatter(np.asarray(ct), np.ones(len(ct))*3, color = 'green', s= 22)
elif 8<= idx <= 11:
axs[1, 0].plot(zeit, eods, color= 'blue', linewidth = 0.25)
axs[1, 0].scatter(np.asarray(ct), np.ones(len(ct))*3, color = 'green', s= 22)
else:
axs[1, 1].plot(zeit, eods, color= 'blue', linewidth = 0.25)
axs[1, 1].scatter(np.asarray(ct), np.ones(len(ct))*3, color = 'green', s= 22)
fig.suptitle('EOD for chirps', fontsize = 16)
plt.show()
#plt.scatter(spikes[0, '-50Hz', '20%', '100Hz'][0, 0.614])
#print(len(spikes))
#print(len(eod))
#print(len(times))
#Problem: axs hat keine label-Funktion, also müsste axes nochmal definiert werden. Momentan erscheint Schrift nur auf einem der Subplots
#ax = plt.gca()
#ax.set_ylabel('Time [ms]')
#ax.set_xlabel('Amplitude [mV]')
#ax.label_outer()
#next Step: relative Amplitudenmodulation berechnen, Max und Min der Amplitude bestimmen, EOD und Chirps zuordnen, Unterschied berechnen

View File

@ -1,33 +0,0 @@
import numpy as np
import matplotlib.pyplot as plt
freq = 800
freq2 = 820
dt = 0.00001
x = np.arange(0.0, 1.0, dt)
eod = np.sin(x * 2 * np.pi * freq) + np.sin(x * 2 * np.pi * freq * 2) * 0.5
eod2 = np.sin(x * 2 * np.pi * freq2) + np.sin(x * 2 * np.pi * freq2 * 2) * 0.5
fig = plt.figure(figsize=(5., 7.5))
ax= fig.add_subplot(311)
ax.plot(x, eod, color="darkgreen", linewidth = 1.0)
ax.set_xlim(0.0, 0.1)
ax.set_ylabel("voltage [mV]")
ax= fig.add_subplot(312)
ax.plot(x, eod2, color="crimson", linewidth = 1.0)
ax.set_xlim(0.0, 0.1)
ax.set_ylabel("voltage [mV]")
ax= fig.add_subplot(313)
ax.plot(x, eod + eod2 * 0.05, color="lightblue", linewidth = 1.0)
ax.set_xlim(0.0, 0.1)
ax.set_xlabel("time [s]")
ax.set_ylabel("voltage [mV]")
plt.tight_layout()
plt.savefig("eods.pdf")
plt.show()