From 477fa15dc430b3d9c42ac3e40c59d67b3075c007 Mon Sep 17 00:00:00 2001 From: efish Date: Thu, 15 Nov 2018 10:30:29 +0100 Subject: [PATCH 01/18] liste erstellt --- code/liste.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 code/liste.py diff --git a/code/liste.py b/code/liste.py new file mode 100644 index 0000000..cba7d05 --- /dev/null +++ b/code/liste.py @@ -0,0 +1,43 @@ +# 9.11.18 + +aa: quality: poor, depth: -1341 +ab: quality: poor, depth: -1341 +ac: quality: good, depth: -1341 +ad: quality: good, depth: -200 +ae: quality: good, depth: -200 +af: quality: good, depth: -200 +ag: no info.dat + + +# 13.11.18 + +aa: good, -30 µm, maybe no reaction +ab: good, -309 µm +ac: poor, -309 µm +ad: fair, -360 µm +ae: fair, -350 µm +af: good, -440 µm, bursting +ag: fair, -174 µm +ah: good, -209 µm +ai: good, -66.9 µm +aj: good, -132 µm +ak: good, -284 µm +al: good, -286 µm + + +# 14.11.18 + +aa: good, -184 µm +ab: fair, -279 µm, no reaction +ac: fair, -60 µm +ad: good, -357 µm +ae: fair, -357 µm +af: fair, -527 µm, only baseline +ag: fair, -533 µm +ah: poor, -505 µm +ai: good, -500 µm, still same cell 3x +aj: poor, -314 µm,no modulation +ak: good, -140 µm +al: good, -280 µm +am: good, -320 µm +an: good, -434 µm From b2c3a99a3ba1d131972bd066509dc4e6f2ccfdda Mon Sep 17 00:00:00 2001 From: Ramona Date: Thu, 15 Nov 2018 10:57:49 +0100 Subject: [PATCH 02/18] analysis --- code/analysis_rs.py | 44 +++++++++++++++++++++++++------------------- code/eod_sim_rs.py | 0 2 files changed, 25 insertions(+), 19 deletions(-) delete mode 100644 code/eod_sim_rs.py diff --git a/code/analysis_rs.py b/code/analysis_rs.py index 3a3cdf8..ddefae4 100644 --- a/code/analysis_rs.py +++ b/code/analysis_rs.py @@ -2,21 +2,22 @@ import numpy as np import matplotlib.pyplot as plt from read_baseline_data import * from IPython import embed +from NixFrame import * inch_factor = 2.54 data_dir = '../data' dataset = '2018-11-09-ad-invivo-1' time, eod = read_baseline_eod(os.path.join(data_dir, dataset)) -fig = plt.figure(figsize=(12/inch_factor, 8/inch_factor)) -ax = fig.add_subplot(111) -ax.plot(time[:1000], eod[:1000]) -ax.set_xlabel('time [ms]', fontsize=12) -ax.set_ylabel('voltage [mV]', fontsize=12) -plt.xticks(fontsize = 8) -plt.yticks(fontsize = 8) -fig.tight_layout() -plt.savefig('eod.pdf') +#fig = plt.figure(figsize=(12/inch_factor, 8/inch_factor)) +#ax = fig.add_subplot(111) +#ax.plot(time[:1000], eod[:1000]) +#ax.set_xlabel('time [ms]', fontsize=12) +#ax.set_ylabel('voltage [mV]', fontsize=12) +#plt.xticks(fontsize = 8) +#plt.yticks(fontsize = 8) +#fig.tight_layout() +#plt.savefig('eod.pdf') #interspikeintervalhistogram, windowsize = 1 ms #plt.hist @@ -26,14 +27,14 @@ plt.savefig('eod.pdf') spikes = read_baseline_spikes(os.path.join(data_dir, dataset)) interspikeintervals = np.diff(spikes) -fig = plt.figure() -plt.hist(interspikeintervals, bins=np.arange(0, np.max(interspikeintervals), 0.0001)) -plt.show() +#fig = plt.figure() +#plt.hist(interspikeintervals, bins=np.arange(0, np.max(interspikeintervals), 0.0001)) +#plt.show() mu = np.mean(interspikeintervals) sigma = np.std(interspikeintervals) cv = sigma/mu -print(cv) +#print(cv) # calculate zero crossings of the eod # plot mean of eod circles @@ -47,10 +48,15 @@ eod_times = time[(eod >= threshold) & (shift_eod < threshold)] sampling_rate = 40000.0 eod_idx = eod_times*sampling_rate -fig = plt.figure() -for i, idx in enumerate(eod_idx): - #embed() - #exit() - plt.plot(time[int(idx):int(eod_idx[i+1])], eod[int(idx):int(eod_idx[i+1])]) -plt.show() +#fig = plt.figure() +eod_cuts = []; +#for i, idx in enumerate(eod_idx)-1: + #eod_cuts.append(eod[int(idx):int(eod_idx[i+1])]) + #time_cut = time[int(idx):int(eod_idx[i+1])] + #plt.plot(time[int(idx):int(eod_idx[i+1])], eod[int(idx):int(eod_idx[i+1])]) +#plt.show() +data = NixToFrame(data_dir) + +embed() +exit() diff --git a/code/eod_sim_rs.py b/code/eod_sim_rs.py deleted file mode 100644 index e69de29..0000000 From 67353f5c0b4cb2de4be1f2d9f7530996a68d8a3c Mon Sep 17 00:00:00 2001 From: efish Date: Thu, 15 Nov 2018 14:33:11 +0100 Subject: [PATCH 03/18] bug fixes --- code/read_baseline_data.py | 16 ++++++++++++++-- code/read_chirp_data.py | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/code/read_baseline_data.py b/code/read_baseline_data.py index 6b3cd29..9e951a9 100644 --- a/code/read_baseline_data.py +++ b/code/read_baseline_data.py @@ -7,7 +7,13 @@ def read_baseline_eod(dataset): base = dataset.split(os.path.sep)[-1] + ".nix" nix_file = nix.File.open(os.path.join(dataset, base), nix.FileMode.ReadOnly) b = nix_file.blocks[0] - t = b.tags["BaselineActivity_1"] + if 'BaselineActivity_1' in b.tags: + t = b.tags["BaselineActivity_1"] + elif "BaselineActivity_2" in b.tags: + t = b.tags["BaselineActivity_2"] + else: + f.close() + return [],[] eod_da = b.data_arrays["LocalEOD-1"] eod = t.retrieve_data("LocalEOD-1")[:] time = np.asarray(eod_da.dimensions[0].axis(len(eod))) @@ -19,7 +25,13 @@ def read_baseline_spikes(dataset): base = dataset.split(os.path.sep)[-1] + ".nix" nix_file = nix.File.open(os.path.join(dataset, base), nix.FileMode.ReadOnly) b = nix_file.blocks[0] - t = b.tags["BaselineActivity_1"] + if 'BaselineActivity_1' in b.tags: + t = b.tags["BaselineActivity_1"] + elif "BaselineActivity_2" in b.tags: + t = b.tags["BaselineActivity_2"] + else: + f.close() + return [],[] spikes_da = b.data_arrays["Spikes-1"] spike_times = spikes_da[:spikes_da.shape[0]-5000] baseline_spikes = spike_times[(spike_times > t.position[0]) & (spike_times < (t.position[0] + t.extent[0]))] diff --git a/code/read_chirp_data.py b/code/read_chirp_data.py index 4283c48..4b84139 100644 --- a/code/read_chirp_data.py +++ b/code/read_chirp_data.py @@ -2,7 +2,7 @@ import numpy as np import os -def load_chirp_spikes(dataset): +def read_chirp_spikes(dataset): spikes_file = os.path.join(dataset, "chirpspikess1.dat") if not os.path.exists(spikes_file): print("found no chirps!") @@ -32,7 +32,7 @@ def load_chirp_spikes(dataset): return spikes -def load_chirp_eod(dataset): +def read_chirp_eod(dataset): eod_file = os.path.join(dataset, "chirpeodampls.dat") if not os.path.exists(eod_file): print("found no chirpeodampls.dat!") @@ -60,7 +60,7 @@ def load_chirp_eod(dataset): return chirp_eod -def load_chirp_times(dataset): +def read_chirp_times(dataset): chirp_times_file = os.path.join(dataset, "chirpss.dat") if not os.path.exists(chirp_times_file): print("found no chirpss.dat!") From 4bff151b3a0afb03cfde2a824f8c9b39f463040b Mon Sep 17 00:00:00 2001 From: Ramona Date: Thu, 15 Nov 2018 15:05:36 +0100 Subject: [PATCH 04/18] mambo nr 5 --- code/analysis_rs.py | 56 ++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/code/analysis_rs.py b/code/analysis_rs.py index 8ff3b5a..356d461 100644 --- a/code/analysis_rs.py +++ b/code/analysis_rs.py @@ -48,28 +48,46 @@ eod_times = time[(eod >= threshold) & (shift_eod < threshold)] sampling_rate = 40000.0 eod_idx = eod_times*sampling_rate -<<<<<<< HEAD -#fig = plt.figure() -eod_cuts = []; -#for i, idx in enumerate(eod_idx)-1: - #eod_cuts.append(eod[int(idx):int(eod_idx[i+1])]) - #time_cut = time[int(idx):int(eod_idx[i+1])] - #plt.plot(time[int(idx):int(eod_idx[i+1])], eod[int(idx):int(eod_idx[i+1])]) -#plt.show() -data = NixToFrame(data_dir) -======= -fig = plt.figure() -for i, idx in enumerate(eod_idx): - #embed() - #exit() - plt.plot(time[int(idx):int(eod_idx[i+1])], eod[int(idx):int(eod_idx[i+1])]) +max_cut = int(np.max(np.diff(eod_idx))) +eod_cuts = np.zeros([len(eod_idx)-1, max_cut]) +# eods 15 + 16 are to short +relative_times = [] +for i, idx in enumerate(eod_idx[:-1]): + eod_cut = eod[int(idx):int(eod_idx[i+1])] + eod_cuts[i, :len(eod_cut)] = eod_cut + eod_cuts[i, len(eod_cut):] = np.nan + time_cut = time[int(idx):int(eod_idx[i+1])] + spike_cut = spikes[(spikes > time_cut[0]) & (spikes < time_cut[-1])] + relative_time = spike_cut - time_cut[0] + if len(relative_time) > 0: + relative_times.append(relative_time[:][0]*1000) -plt.show() ->>>>>>> 477fa15dc430b3d9c42ac3e40c59d67b3075c007 +mu_eod = np.nanmean(eod_cuts, axis=0) +std_eod = np.nanstd(eod_cuts, axis=0)*3 +time_axis = np.arange(max_cut)/sampling_rate*1000 + +#fig = plt.figure(figsize=(12/inch_factor, 8/inch_factor)) +fig, ax1 = plt.subplots(figsize=(12/inch_factor, 8/inch_factor)) +ax1.hist(relative_times, color='crimson') +ax1.set_xlabel('time [ms]', fontsize=12) +ax1.set_ylabel('number', fontsize=12) +ax1.tick_params(axis='y', labelcolor='crimson') +plt.yticks(fontsize = 8) +ax1.spines['top'].set_visible(False) + +ax2 = ax1.twinx() + +ax2.fill_between(time_axis, mu_eod+std_eod, mu_eod-std_eod, color='dodgerblue', alpha=0.5) +ax2.plot(time_axis, mu_eod, color='black', lw=2) +ax2.set_ylabel('voltage [mV]', fontsize=12) +ax2.tick_params(axis='y', labelcolor='dodgerblue') + +plt.xticks(fontsize = 8) +plt.yticks(fontsize = 8) +fig.tight_layout() +plt.show() -embed() -exit() From fa56e2dc04bd0977e154d3fd7a2a41dfc41e3066 Mon Sep 17 00:00:00 2001 From: efish Date: Thu, 15 Nov 2018 15:06:47 +0100 Subject: [PATCH 05/18] read_chirps return chrip times in ms --- code/read_chirp_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/read_chirp_data.py b/code/read_chirp_data.py index 4b84139..e1181f3 100644 --- a/code/read_chirp_data.py +++ b/code/read_chirp_data.py @@ -81,7 +81,7 @@ def read_chirp_times(dataset): if "#Key" in l: chirp_times[(index, df, contrast, cs)] = [] if len(l.strip()) != 0 and "#" not in l: - chirp_times[(index, df, contrast, cs)].append(float(l.split()[1])) + chirp_times[(index, df, contrast, cs)].append(float(l.split()[1]) * 1000.) return chirp_times From 30215ef0b01536590be3e13f3e9981e1b3eb47e9 Mon Sep 17 00:00:00 2001 From: Ramona Date: Thu, 15 Nov 2018 15:24:53 +0100 Subject: [PATCH 06/18] small differences --- code/analysis_rs.py | 2 +- code/utility.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/analysis_rs.py b/code/analysis_rs.py index 356d461..106fb28 100644 --- a/code/analysis_rs.py +++ b/code/analysis_rs.py @@ -42,7 +42,7 @@ cv = sigma/mu # plot psth into the same plot # calculate vector strength -threshold = 0; +threshold = 0 shift_eod = np.roll(eod, 1) eod_times = time[(eod >= threshold) & (shift_eod < threshold)] sampling_rate = 40000.0 diff --git a/code/utility.py b/code/utility.py index 86f2407..0c1ce34 100644 --- a/code/utility.py +++ b/code/utility.py @@ -2,7 +2,7 @@ import numpy as np def zero_crossing(eod,time): - threshold = 0; + threshold = 0 shift_eod = np.roll(eod, 1) eod_times = time[(eod >= threshold) & (shift_eod < threshold)] sampling_rate = 40000.0 @@ -10,9 +10,9 @@ def zero_crossing(eod,time): return eod_idx -def vector_strength(spike_times, eod_durations) +def vector_strength(spike_times, eod_durations): alphas = spike_times/ eod_durations cs = (1/len(spike_times))*np.sum(np.cos(alphas))^2 sn = (1/len(spike_times))*np.sum(np.sin(alphas))^2 - vs = np.sprt(cs+sn) + vs = np.sqrt(cs+sn) return vs From cf4d63966af1031f3ec096f2173f557430a89268 Mon Sep 17 00:00:00 2001 From: Ramona Date: Thu, 15 Nov 2018 15:48:34 +0100 Subject: [PATCH 07/18] vector strength --- code/analysis_rs.py | 11 ++++++++++- code/utility.py | 10 ++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/code/analysis_rs.py b/code/analysis_rs.py index 106fb28..7a50853 100644 --- a/code/analysis_rs.py +++ b/code/analysis_rs.py @@ -3,6 +3,7 @@ import matplotlib.pyplot as plt from read_baseline_data import * from IPython import embed from NixFrame import * +from utility import * inch_factor = 2.54 data_dir = '../data' @@ -53,6 +54,7 @@ max_cut = int(np.max(np.diff(eod_idx))) eod_cuts = np.zeros([len(eod_idx)-1, max_cut]) # eods 15 + 16 are to short relative_times = [] +eod_durations = [] for i, idx in enumerate(eod_idx[:-1]): eod_cut = eod[int(idx):int(eod_idx[i+1])] @@ -63,14 +65,20 @@ for i, idx in enumerate(eod_idx[:-1]): relative_time = spike_cut - time_cut[0] if len(relative_time) > 0: relative_times.append(relative_time[:][0]*1000) + eod_durations.append(len(eod_cut)) mu_eod = np.nanmean(eod_cuts, axis=0) std_eod = np.nanstd(eod_cuts, axis=0)*3 -time_axis = np.arange(max_cut)/sampling_rate*1000 +vs = vector_strength(relative_times, eod_durations) +embed() +exit() + +#time_axis = np.arange(max_cut)/sampling_rate*1000 #fig = plt.figure(figsize=(12/inch_factor, 8/inch_factor)) +''' fig, ax1 = plt.subplots(figsize=(12/inch_factor, 8/inch_factor)) ax1.hist(relative_times, color='crimson') ax1.set_xlabel('time [ms]', fontsize=12) @@ -90,4 +98,5 @@ plt.xticks(fontsize = 8) plt.yticks(fontsize = 8) fig.tight_layout() plt.show() +''' diff --git a/code/utility.py b/code/utility.py index 0c1ce34..a83b5c2 100644 --- a/code/utility.py +++ b/code/utility.py @@ -11,8 +11,10 @@ def zero_crossing(eod,time): def vector_strength(spike_times, eod_durations): - alphas = spike_times/ eod_durations - cs = (1/len(spike_times))*np.sum(np.cos(alphas))^2 - sn = (1/len(spike_times))*np.sum(np.sin(alphas))^2 - vs = np.sqrt(cs+sn) + n = len(spike_times) + phase_times = np.zeros(n) + for i, idx in enumerate(spike_times): + phase_times[i]= spike_times[i]/eod_durations[i] + + vs = np.sqrt((1/n*sum(np.cos(phase_times)))**2 + (1/n*sum(np.sin(phase_times)))**2) return vs From c9bc805d0349267587c6aac85a50bda1497a162d Mon Sep 17 00:00:00 2001 From: Ramona Date: Thu, 15 Nov 2018 16:21:55 +0100 Subject: [PATCH 08/18] stuff for plotting --- code/analysis_rs.py | 84 ++++++++++++++++++++------------------------- code/utility.py | 7 ++-- 2 files changed, 40 insertions(+), 51 deletions(-) diff --git a/code/analysis_rs.py b/code/analysis_rs.py index 7a50853..1d6be94 100644 --- a/code/analysis_rs.py +++ b/code/analysis_rs.py @@ -1,59 +1,54 @@ import numpy as np import matplotlib.pyplot as plt from read_baseline_data import * -from IPython import embed from NixFrame import * from utility import * +from IPython import embed +# plot and data values inch_factor = 2.54 data_dir = '../data' dataset = '2018-11-09-ad-invivo-1' + +# read eod and time of baseline time, eod = read_baseline_eod(os.path.join(data_dir, dataset)) -#fig = plt.figure(figsize=(12/inch_factor, 8/inch_factor)) -#ax = fig.add_subplot(111) -#ax.plot(time[:1000], eod[:1000]) -#ax.set_xlabel('time [ms]', fontsize=12) -#ax.set_ylabel('voltage [mV]', fontsize=12) -#plt.xticks(fontsize = 8) -#plt.yticks(fontsize = 8) -#fig.tight_layout() +fig, ax = plt.subplots(figsize=(12/inch_factor, 8/inch_factor)) +ax.plot(time[:1000], eod[:1000]) +ax.set_xlabel('time [ms]', fontsize=12) +ax.set_ylabel('voltage [mV]', fontsize=12) +plt.xticks(fontsize=8) +plt.yticks(fontsize=8) +fig.tight_layout() #plt.savefig('eod.pdf') +plt.show() -#interspikeintervalhistogram, windowsize = 1 ms -#plt.hist -#coefficient of variation -#embed() -#exit() - +# read spikes during baseline activity spikes = read_baseline_spikes(os.path.join(data_dir, dataset)) +# calculate interpike intervals and plot them interspikeintervals = np.diff(spikes) -#fig = plt.figure() -#plt.hist(interspikeintervals, bins=np.arange(0, np.max(interspikeintervals), 0.0001)) -#plt.show() +fig, ax = plt.subplots(figsize=(12/inch_factor, 8/inch_factor)) +plt.hist(interspikeintervals, bins=np.arange(0, np.max(interspikeintervals), 0.0001)) +plt.show() + +# calculate coefficient of variation mu = np.mean(interspikeintervals) sigma = np.std(interspikeintervals) cv = sigma/mu -#print(cv) - -# calculate zero crossings of the eod -# plot mean of eod circles -# plot std of eod circles -# plot psth into the same plot -# calculate vector strength +print(cv) +# calculate eod times and indices by zero crossings threshold = 0 shift_eod = np.roll(eod, 1) eod_times = time[(eod >= threshold) & (shift_eod < threshold)] sampling_rate = 40000.0 eod_idx = eod_times*sampling_rate - +# align eods and spikes to eods max_cut = int(np.max(np.diff(eod_idx))) eod_cuts = np.zeros([len(eod_idx)-1, max_cut]) -# eods 15 + 16 are to short -relative_times = [] +spike_times = [] eod_durations = [] for i, idx in enumerate(eod_idx[:-1]): @@ -62,41 +57,36 @@ for i, idx in enumerate(eod_idx[:-1]): eod_cuts[i, len(eod_cut):] = np.nan time_cut = time[int(idx):int(eod_idx[i+1])] spike_cut = spikes[(spikes > time_cut[0]) & (spikes < time_cut[-1])] - relative_time = spike_cut - time_cut[0] - if len(relative_time) > 0: - relative_times.append(relative_time[:][0]*1000) - eod_durations.append(len(eod_cut)) + spike_time = spike_cut - time_cut[0] + if len(spike_time) > 0: + spike_times.append(spike_time[:][0]*1000) + eod_durations.append(len(eod_cut)/sampling_rate*1000) +# calculate vector strength +vs = vector_strength(spike_times, eod_durations) +# determine means and stds of eod for plot +# determine time axis mu_eod = np.nanmean(eod_cuts, axis=0) std_eod = np.nanstd(eod_cuts, axis=0)*3 +time_axis = np.arange(max_cut)/sampling_rate*1000 -vs = vector_strength(relative_times, eod_durations) -embed() -exit() - -#time_axis = np.arange(max_cut)/sampling_rate*1000 - -#fig = plt.figure(figsize=(12/inch_factor, 8/inch_factor)) -''' +# plot eod form and spike histogram fig, ax1 = plt.subplots(figsize=(12/inch_factor, 8/inch_factor)) -ax1.hist(relative_times, color='crimson') +ax1.hist(spike_times, color='crimson') ax1.set_xlabel('time [ms]', fontsize=12) ax1.set_ylabel('number', fontsize=12) ax1.tick_params(axis='y', labelcolor='crimson') -plt.yticks(fontsize = 8) +plt.yticks(fontsize=8) ax1.spines['top'].set_visible(False) ax2 = ax1.twinx() - ax2.fill_between(time_axis, mu_eod+std_eod, mu_eod-std_eod, color='dodgerblue', alpha=0.5) ax2.plot(time_axis, mu_eod, color='black', lw=2) ax2.set_ylabel('voltage [mV]', fontsize=12) ax2.tick_params(axis='y', labelcolor='dodgerblue') -plt.xticks(fontsize = 8) -plt.yticks(fontsize = 8) +plt.xticks(fontsize=8) +plt.yticks(fontsize=8) fig.tight_layout() plt.show() -''' - diff --git a/code/utility.py b/code/utility.py index a83b5c2..1ad9601 100644 --- a/code/utility.py +++ b/code/utility.py @@ -1,7 +1,7 @@ import numpy as np -def zero_crossing(eod,time): +def zero_crossing(eod, time): threshold = 0 shift_eod = np.roll(eod, 1) eod_times = time[(eod >= threshold) & (shift_eod < threshold)] @@ -12,9 +12,8 @@ def zero_crossing(eod,time): def vector_strength(spike_times, eod_durations): n = len(spike_times) - phase_times = np.zeros(n) + phase_times = np.zeros(len(spike_times)) for i, idx in enumerate(spike_times): - phase_times[i]= spike_times[i]/eod_durations[i] - + phase_times[i] = (spike_times[i] / eod_durations[i]) * 2 * np.pi vs = np.sqrt((1/n*sum(np.cos(phase_times)))**2 + (1/n*sum(np.sin(phase_times)))**2) return vs From 30e7413838125e894846ba85d3567653914c2c7f Mon Sep 17 00:00:00 2001 From: Ramona Date: Thu, 15 Nov 2018 16:49:21 +0100 Subject: [PATCH 09/18] bla --- code/analysis_rs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/analysis_rs.py b/code/analysis_rs.py index 1d6be94..950b572 100644 --- a/code/analysis_rs.py +++ b/code/analysis_rs.py @@ -90,3 +90,5 @@ plt.xticks(fontsize=8) plt.yticks(fontsize=8) fig.tight_layout() plt.show() + +#NixToFrame(data_dir) \ No newline at end of file From 73cdaf93afd8e25675cdfb5df71b798605e73440 Mon Sep 17 00:00:00 2001 From: efish Date: Fri, 16 Nov 2018 09:26:37 +0100 Subject: [PATCH 10/18] Strip blanks from keys --- code/read_chirp_data.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/read_chirp_data.py b/code/read_chirp_data.py index e1181f3..c3afe76 100644 --- a/code/read_chirp_data.py +++ b/code/read_chirp_data.py @@ -15,11 +15,11 @@ def read_chirp_spikes(dataset): if "index" in l and "chirp" not in l: index = int(l.split(":")[-1]) if "deltaf" in l and "true" not in l: - df = l.split(":")[-1] + df = l.split(":")[-1].strip() if "contrast" in l and "true" not in l: - contrast = l.split(":")[-1] + contrast = l.split(":")[-1].strip() if "chirpsize" in l: - cs = l.split(":")[-1] + cs = l.split(":")[-1].strip() if "#Key" in l: spikes[(index, df, contrast, cs)] = {} if "chirp index" in l: @@ -45,11 +45,11 @@ def read_chirp_eod(dataset): if "index" in l and "chirp" not in l: index = int(l.split(":")[-1]) if "deltaf" in l and "true" not in l: - df = l.split(":")[-1] + df = l.split(":")[-1].strip() if "contrast" in l and "true" not in l: - contrast = l.split(":")[-1] + contrast = l.split(":")[-1].strip() if "chirpsize" in l: - cs = l.split(":")[-1] + cs = l.split(":")[-1].strip() if "#Key" in l: chirp_eod[(index, df, contrast, cs)] = ([], []) if len(l.strip()) != 0 and "#" not in l: @@ -73,11 +73,11 @@ def read_chirp_times(dataset): if "index" in l and "chirp" not in l: index = int(l.split(":")[-1]) if "deltaf" in l and "true" not in l: - df = l.split(":")[-1] + df = l.split(":")[-1].strip() if "contrast" in l and "true" not in l: - contrast = l.split(":")[-1] + contrast = l.split(":")[-1].strip() if "chirpsize" in l: - cs = l.split(":")[-1] + cs = l.split(":")[-1].strip() if "#Key" in l: chirp_times[(index, df, contrast, cs)] = [] if len(l.strip()) != 0 and "#" not in l: From 317f90f1bc5733b24f6ca1e7790d06f4635467d0 Mon Sep 17 00:00:00 2001 From: efish Date: Fri, 16 Nov 2018 10:14:49 +0100 Subject: [PATCH 11/18] UptoDate --- code/base_chirps.py | 43 +++++++++++++++++++++++++++++++ code/liste.py | 62 ++++++++++++++++++++++----------------------- 2 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 code/base_chirps.py diff --git a/code/base_chirps.py b/code/base_chirps.py new file mode 100644 index 0000000..aa8f838 --- /dev/null +++ b/code/base_chirps.py @@ -0,0 +1,43 @@ +from read_chirp_data import * +#import nix_helpers as nh +import matplotlib.pyplot as plt +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)) +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 = k[1] + 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))) +plt.show() + +#plt.scatter(spikes[0, '-50Hz', '20%', '100Hz'][0, 0.614]) + +#print(len(spikes)) +#print(len(eod)) +#print(len(times)) diff --git a/code/liste.py b/code/liste.py index cba7d05..7a51eda 100644 --- a/code/liste.py +++ b/code/liste.py @@ -1,43 +1,43 @@ # 9.11.18 -aa: quality: poor, depth: -1341 -ab: quality: poor, depth: -1341 -ac: quality: good, depth: -1341 -ad: quality: good, depth: -200 -ae: quality: good, depth: -200 +aa: quality: poor, depth: -1341, base +ab: quality: poor, depth: -1341, base +ac: quality: good, depth: -1341, base +ad: quality: good, depth: -200, base, chirps +ae: quality: good, depth: -200, chirps af: quality: good, depth: -200 -ag: no info.dat +ag: no info.dat, chirps # 13.11.18 -aa: good, -30 µm, maybe no reaction -ab: good, -309 µm -ac: poor, -309 µm -ad: fair, -360 µm +aa: good, -30 µm, maybe no reaction, base, chirps +ab: good, -309 µm, base +ac: poor, -309 µm, chirps +ad: fair, -360 µm, base, chirps ae: fair, -350 µm -af: good, -440 µm, bursting -ag: fair, -174 µm -ah: good, -209 µm -ai: good, -66.9 µm -aj: good, -132 µm -ak: good, -284 µm -al: good, -286 µm +af: good, -440 µm, bursting, base +ag: fair, -174 µm, base +ah: good, -209 µm, base, chirps, FI, SAM +ai: good, -66.9 µm, base, chirps, SAM +aj: good, -132 µm, base, chirps +ak: good, -284 µm, base, chirps +al: good, -286 µm, base, chirps, SAM # 14.11.18 -aa: good, -184 µm -ab: fair, -279 µm, no reaction -ac: fair, -60 µm -ad: good, -357 µm -ae: fair, -357 µm -af: fair, -527 µm, only baseline -ag: fair, -533 µm -ah: poor, -505 µm -ai: good, -500 µm, still same cell 3x -aj: poor, -314 µm,no modulation -ak: good, -140 µm -al: good, -280 µm -am: good, -320 µm -an: good, -434 µm +aa: good, -184 µm, base, chirps, FI, SAM, noise +ab: fair, -279 µm, no reaction, base +ac: fair, -60 µm, base, chirps +ad: good, -357 µm, base, chirps +ae: fair, -357 µm, base +af: fair, -527 µm, base, (chirps) +ag: fair, -533 µm, base, chirps +ah: poor, -505 µm, chirps +ai: good, -500 µm, still same cell 3x, chirps, FI, noise +aj: poor, -314 µm, no modulation, base +ak: good, -140 µm, base, chirps, FI, SAM, noise +al: good, -280 µm, base, chirps, SAM +am: good, -320 µm, base, chirps, FI, SAM, noise +an: good, -434 µm, base, chirps, FI, SAM, noise From 606459c13bfadf50b872ab9facd31e142e7599d0 Mon Sep 17 00:00:00 2001 From: Ramona Date: Fri, 16 Nov 2018 11:27:00 +0100 Subject: [PATCH 12/18] spike analyse --- code/spikes_analysis.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 code/spikes_analysis.py diff --git a/code/spikes_analysis.py b/code/spikes_analysis.py new file mode 100644 index 0000000..9b00368 --- /dev/null +++ b/code/spikes_analysis.py @@ -0,0 +1,22 @@ +import matplotlib.pyplot as plt +import numpy as np +from read_chirp_data import * +from IPython import embed + +data_dir = "../data" +dataset = "2018-11-09-ad-invivo-1" + +spikes = read_chirp_spikes(os.path.join(data_dir, dataset)) +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 = k[1] + if df in df_map.keys(): + df_map[df].append(k) + else: + df_map[df] = [k] + +#plt.scatter(spikes[0, '-50Hz', '20%', '100Hz'][0, 0.614]) +#plt.show() \ No newline at end of file From f391261ceaeded996ac94335db427ec45e591719 Mon Sep 17 00:00:00 2001 From: Ramona Date: Fri, 16 Nov 2018 12:09:05 +0100 Subject: [PATCH 13/18] vorm essen --- code/spikes_analysis.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/spikes_analysis.py b/code/spikes_analysis.py index 9b00368..ffe8086 100644 --- a/code/spikes_analysis.py +++ b/code/spikes_analysis.py @@ -18,5 +18,8 @@ for k in spikes.keys(): else: df_map[df] = [k] -#plt.scatter(spikes[0, '-50Hz', '20%', '100Hz'][0, 0.614]) -#plt.show() \ No newline at end of file +embed() +exit() +plot_spikes = spikes[(0, '-50Hz', '20%', '100Hz')][(0, 0.789)] +plt.scatter(plot_spikes, np.ones(len(plot_spikes))) +plt.show() From 9952a13bf937b4de4813d601c6fbf13d10146be3 Mon Sep 17 00:00:00 2001 From: Ramona Date: Fri, 16 Nov 2018 16:20:01 +0100 Subject: [PATCH 14/18] gauss function --- code/spikes_analysis.py | 22 +++++++++++++++++++--- code/utility.py | 6 ++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/code/spikes_analysis.py b/code/spikes_analysis.py index ffe8086..d0b1867 100644 --- a/code/spikes_analysis.py +++ b/code/spikes_analysis.py @@ -18,8 +18,24 @@ for k in spikes.keys(): else: df_map[df] = [k] -embed() -exit() +spikes_mat = {} +for deltaf in df_map.keys(): + for rep in df_map[deltaf]: + for phase in spikes[rep]: + #print(phase) + spikes_one_chirp = spikes[rep][phase] + if deltaf == '-50Hz' and phase == (9, 0.54): + spikes_mat[deltaf, rep, phase] = spikes_one_chirp + +#embed() +#exit() + plot_spikes = spikes[(0, '-50Hz', '20%', '100Hz')][(0, 0.789)] -plt.scatter(plot_spikes, np.ones(len(plot_spikes))) +#hist_data = plt.hist(plot_spikes, bins=np.arange(-200, 400, 20)) +fig, ax = plt.subplots() +ax.scatter(plot_spikes, np.ones(len(plot_spikes))*10, marker='|', color='k') +#ax.plot(hist_data[1][:-1], hist_data[0]) plt.show() + +#embed() +#exit() diff --git a/code/utility.py b/code/utility.py index 1ad9601..68102d3 100644 --- a/code/utility.py +++ b/code/utility.py @@ -17,3 +17,9 @@ def vector_strength(spike_times, eod_durations): phase_times[i] = (spike_times[i] / eod_durations[i]) * 2 * np.pi vs = np.sqrt((1/n*sum(np.cos(phase_times)))**2 + (1/n*sum(np.sin(phase_times)))**2) return vs + + +def gaussian(x, mu, sig): + y = np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.))) + return y + From 7c9aa5eb9270d2d41cb861252cf0fae525e4fd73 Mon Sep 17 00:00:00 2001 From: Ramona Date: Fri, 16 Nov 2018 17:17:34 +0100 Subject: [PATCH 15/18] still fix smoothing --- code/spikes_analysis.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/code/spikes_analysis.py b/code/spikes_analysis.py index d0b1867..5ae3da4 100644 --- a/code/spikes_analysis.py +++ b/code/spikes_analysis.py @@ -1,6 +1,7 @@ import matplotlib.pyplot as plt import numpy as np from read_chirp_data import * +from utility import * from IPython import embed data_dir = "../data" @@ -18,6 +19,7 @@ for k in spikes.keys(): else: df_map[df] = [k] +# make phases together, 12 phases spikes_mat = {} for deltaf in df_map.keys(): for rep in df_map[deltaf]: @@ -27,15 +29,23 @@ for deltaf in df_map.keys(): if deltaf == '-50Hz' and phase == (9, 0.54): spikes_mat[deltaf, rep, phase] = spikes_one_chirp -#embed() -#exit() - plot_spikes = spikes[(0, '-50Hz', '20%', '100Hz')][(0, 0.789)] -#hist_data = plt.hist(plot_spikes, bins=np.arange(-200, 400, 20)) + +mu = 1 +sigma = 1 +time_gauss = np.arange(-4, 4, 1) +gauss = gaussian(time_gauss, mu, sigma) +# spikes during time vec (00010000001)? +smoothed_spikes = np.convolve(plot_spikes, gauss, 'same') +window = np.mean(np.diff(plot_spikes)) +time_vec = np.arange(plot_spikes[0], plot_spikes[-1]+window, window) + fig, ax = plt.subplots() ax.scatter(plot_spikes, np.ones(len(plot_spikes))*10, marker='|', color='k') -#ax.plot(hist_data[1][:-1], hist_data[0]) +ax.plot(time_vec, smoothed_spikes) plt.show() #embed() #exit() +#hist_data = plt.hist(plot_spikes, bins=np.arange(-200, 400, 20)) +#ax.plot(hist_data[1][:-1], hist_data[0]) \ No newline at end of file From 4bb17bc0bc6e9c08f9d5785249ee03cd0ef65129 Mon Sep 17 00:00:00 2001 From: efish Date: Fri, 16 Nov 2018 17:51:42 +0100 Subject: [PATCH 16/18] EOD plot --- code/base_chirps.py | 76 ++++++++++++++++++++++++++++++++------------- code/code_cw.py | 33 -------------------- 2 files changed, 54 insertions(+), 55 deletions(-) delete mode 100644 code/code_cw.py diff --git a/code/base_chirps.py b/code/base_chirps.py index aa8f838..dfdfe37 100644 --- a/code/base_chirps.py +++ b/code/base_chirps.py @@ -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 diff --git a/code/code_cw.py b/code/code_cw.py deleted file mode 100644 index 23f2af2..0000000 --- a/code/code_cw.py +++ /dev/null @@ -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() - - From 1c875aa039f01d3f117239051bedb63c733b2bcf Mon Sep 17 00:00:00 2001 From: efish Date: Fri, 16 Nov 2018 17:53:14 +0100 Subject: [PATCH 17/18] Ganz vergessen --- code/base_spikes.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 code/base_spikes.py diff --git a/code/base_spikes.py b/code/base_spikes.py new file mode 100644 index 0000000..7ab065f --- /dev/null +++ b/code/base_spikes.py @@ -0,0 +1,34 @@ +from read_baseline_data import * +#import nix_helpers as nh +import matplotlib.pyplot as plt +import numpy as np +from IPython import embed #Funktionen importieren + +data_dir = "../data" +dataset = "2018-11-09-aa-invivo-1" +#data = ("2018-11-09-aa-invivo-1", "2018-11-09-ab-invivo-1", "2018-11-09-ac-invivo-1", "2018-11-09-ad-invivo-1", "2018-11-13-aa-invivo-1", "2018-11-13-ab-invivo-1", "2018-11-13-ad-invivo-1", "2018-11-09-af-invivo-1", "2018-11-09-ag-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-ab-invivo-1", "2018-11-14-ac-invivo-1", "2018-11-14-ad-invivo-1", "2018-11-14-ae-invivo-1", "2018-11-14-af-invivo-1", "2018-11-14-ag-invivo-1", "2018-11-14-aa-invivo-1", "2018-11-14-aj-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") +spike_times = read_baseline_spikes(os.path.join(data_dir, dataset)) + + +#spike_frequency = len(spike_times) / spike_times[-1] +#inst_frequency = 1. / np.diff(spike_times) +spike_rate = np.diff(spike_times) + + +x = np.arange(0.001, 0.01, 0.0001) +plt.hist(spike_rate,x) + +mu = np.mean(spike_rate) +sigma = np.std(spike_rate) +cv = sigma/mu +print(cv) + +plt.title('A.lepto ISI Histogramm', fontsize = 14) +plt.xlabel('duration ISI[ms]', fontsize = 12) +plt.ylabel('number of ISI', fontsize = 12) + +plt.xticks(fontsize = 12) +plt.yticks(fontsize = 12) +plt.show() + + From a77c5a0e909c8a228d42efdc866639430f4cbcca Mon Sep 17 00:00:00 2001 From: efish Date: Fri, 16 Nov 2018 17:54:53 +0100 Subject: [PATCH 18/18] nee --- code/base_eod.py | 21 +++++++++++++++++++++ code/vector_phase.py | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 code/base_eod.py create mode 100644 code/vector_phase.py diff --git a/code/base_eod.py b/code/base_eod.py new file mode 100644 index 0000000..888084a --- /dev/null +++ b/code/base_eod.py @@ -0,0 +1,21 @@ +from read_baseline_data import * +#import nix_helpers as nh +import matplotlib.pyplot as plt +import numpy as np +from IPython import embed #Funktionen importieren + + +data_dir = "../data" +dataset = "2018-11-09-aa-invivo-1" +#data = ("2018-11-09-aa-invivo-1", "2018-11-09-ab-invivo-1", "2018-11-09-ac-invivo-1", "2018-11-09-ad-invivo-1", "2018-11-13-aa-invivo-1", "2018-11-13-ab-invivo-1", "2018-11-13-ad-invivo-1", "2018-11-09-af-invivo-1", "2018-11-09-ag-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-ab-invivo-1", "2018-11-14-ac-invivo-1", "2018-11-14-ad-invivo-1", "2018-11-14-ae-invivo-1", "2018-11-14-af-invivo-1", "2018-11-14-ag-invivo-1", "2018-11-14-aa-invivo-1", "2018-11-14-aj-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") +time,eod = read_baseline_eod(os.path.join(data_dir, dataset)) +zeit = np.asarray(time) + + +plt.plot(zeit[0:1000], eod[0:1000]) +plt.title('A.lepto EOD')#Plottitelk +plt.xlabel('Time [ms]', fontsize = 12)#Achsentitel +plt.ylabel('Amplitude[mv]', fontsize = 12)#Achsentitel +plt.xticks(fontsize = 12) +plt.yticks(fontsize = 12) +plt.show() diff --git a/code/vector_phase.py b/code/vector_phase.py new file mode 100644 index 0000000..c902e6e --- /dev/null +++ b/code/vector_phase.py @@ -0,0 +1,25 @@ +from read_baseline_data import * +from utility import * +#import nix_helpers as nh +import matplotlib.pyplot as plt +import numpy as np +from IPython import embed #Funktionen importieren + + +#Zeitpunkte einer EOD über Zero-crossings finden, die in einer Steigung liegen +data_dir = "../data" +dataset = "2018-11-09-ad-invivo-1" +time,eod = read_baseline_eod(os.path.join(data_dir, dataset)) +spike_times = read_baseline_spikes(os.path.join(data_dir, dataset)) +print(len(spike_times)) + +eod_times = zero_crossing(eod,time) +eod_durations = np.diff(eod_times) +print(len(spike_times)) +print(len(eod_durations)) + +#for st in spike_times: + #et = eod_times[eod_times < st] + #dt = st - et + +#vs = vector_strength(spike_times, eod_durations)