19.10
This commit is contained in:
parent
d231c75806
commit
b53890c7fc
@ -7,11 +7,12 @@ from jar_functions import get_time_zeros
|
||||
from jar_functions import parse_dataset
|
||||
from jar_functions import mean_traces
|
||||
from jar_functions import mean_noise_cut_eigen
|
||||
from jar_functions import adjust_eodf
|
||||
|
||||
base_path = 'D:\\jar_project\\JAR\\sin'
|
||||
|
||||
identifier = [#'2018lepto1',
|
||||
#'2018lepto4',
|
||||
identifier = ['2018lepto1',
|
||||
'2018lepto4',
|
||||
'2018lepto5',
|
||||
'2018lepto76',
|
||||
'2018lepto98',
|
||||
@ -25,6 +26,7 @@ identifier = [#'2018lepto1',
|
||||
'2020lepto19',
|
||||
'2020lepto20'
|
||||
]
|
||||
eod = []
|
||||
for ID in identifier:
|
||||
base = []
|
||||
|
||||
@ -56,10 +58,19 @@ for ID in identifier:
|
||||
ff = np.mean(f)
|
||||
base.append(ff)
|
||||
|
||||
plt.plot(ct, cf)
|
||||
plt.show()
|
||||
#plt.plot(ct, cf)
|
||||
#plt.show()
|
||||
base_eod = np.mean(base)
|
||||
print(ID)
|
||||
print(base_eod)
|
||||
eod.append(base_eod)
|
||||
|
||||
embed()
|
||||
temp = np.load('temperature.npy')
|
||||
|
||||
eod_temp = zip(eod, temp)
|
||||
|
||||
Q10_eod = []
|
||||
for et in eod_temp:
|
||||
Q10 = adjust_eodf(et[0], et[1])
|
||||
Q10_eod.append(Q10)
|
||||
embed()
|
||||
|
@ -7,7 +7,7 @@ from matplotlib.mlab import specgram
|
||||
import os
|
||||
from jar_functions import gain_curve_fit
|
||||
|
||||
identifier = ['2020lepto06']
|
||||
identifier = ['2020lepto19']
|
||||
|
||||
tau = []
|
||||
f_c = []
|
||||
@ -19,7 +19,7 @@ for ID in identifier:
|
||||
gain = np.load('gain_%s.npy' %ID)
|
||||
print(gain)
|
||||
|
||||
sinv, sinc = curve_fit(gain_curve_fit, amf, gain)
|
||||
sinv, sinc = curve_fit(gain_curve_fit, amf, gain, [2, 3])
|
||||
print('tau:', sinv[0])
|
||||
tau.append(sinv[0])
|
||||
f_cutoff = abs(1 / (2*np.pi*sinv[0]))
|
||||
@ -35,8 +35,8 @@ for ID in identifier:
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot()
|
||||
ax.plot(amf, gain,'o' , label = 'gain')
|
||||
ax.plot(amf, predict, label = 'fit')
|
||||
ax.axvline(x=f_cutoff, ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency')
|
||||
#ax.plot(amf, predict, label = 'fit')
|
||||
#ax.axvline(x=f_cutoff, ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency')
|
||||
ax.set_xscale('log')
|
||||
ax.set_yscale('log')
|
||||
ax.set_ylabel('gain [Hz/(mV/cm)]')
|
||||
|
@ -14,6 +14,8 @@ from jar_functions import sin_response
|
||||
from jar_functions import mean_noise_cut
|
||||
from jar_functions import gain_curve_fit
|
||||
|
||||
plt.rcParams.update({'font.size': 12})
|
||||
|
||||
def take_second(elem): # function for taking the names out of files
|
||||
return elem[1]
|
||||
|
||||
@ -35,16 +37,16 @@ for ident in identifier:
|
||||
currf = None
|
||||
idxlist = []
|
||||
|
||||
data = sorted(np.load('5Hz_%s files.npy' %ident), key = take_second) # list with filenames in it
|
||||
data = sorted(np.load('%s files.npy' %ident), key = take_second) # list with filenames in it
|
||||
|
||||
for i, d in enumerate(data):
|
||||
dd = list(d)
|
||||
if dd[1] == '0.5':
|
||||
jar = np.load('5Hz_%s.npy' %dd) # load data for every file name
|
||||
if dd[1] == '0.05':
|
||||
jar = np.load('%s.npy' %dd) # load data for every file name
|
||||
jm = jar - np.mean(jar) # low-pass filtering by subtracting mean
|
||||
print(dd)
|
||||
|
||||
time = np.load('5Hz_%s time.npy' %dd) # time file
|
||||
time = np.load('%s time.npy' %dd) # time file
|
||||
dt = time[1] - time[0]
|
||||
|
||||
n = int(1/float(d[1])/dt)
|
||||
@ -67,7 +69,7 @@ for ident in identifier:
|
||||
# jar trace
|
||||
plt.plot(time, jar, color = 'C0')
|
||||
#plt.hlines(y=np.min(jar) - 2, xmin=0, xmax=400, lw=2.5, color='r', label='stimulus duration')
|
||||
plt.title('JAR trace 2018lepto98, AM-frequency:%sHz, deltaf = -5Hz' % float(d[1]))
|
||||
plt.title('JAR trace 2018lepto98, AM-frequency: %sHz' % float(d[1]))
|
||||
plt.xlabel('time[s]')
|
||||
plt.ylabel('frequency[Hz]')
|
||||
plt.show()
|
||||
@ -80,22 +82,29 @@ for ident in identifier:
|
||||
# plt.show()
|
||||
|
||||
# filter by running average
|
||||
plt.plot(time, jm, color = 'C0', label = 'JAR: subtracted by mean')
|
||||
plt.plot(time, jm - cutf, color = 'darkorange', label = 'JAR: subtracted by mean and step response')
|
||||
plt.title('JAR trace spectogram 2018lepto98: subtraction of mean and step response, deltaf = -5Hz')
|
||||
plt.xlabel('time[s]')
|
||||
plt.ylabel('frequency[Hz]')
|
||||
plt.legend()
|
||||
plt.show()
|
||||
fig = plt.figure(figsize = (8,14))
|
||||
fig.suptitle('JAR trace spectogram 2018lepto98:\n subtraction of mean and running average')
|
||||
ax = fig.add_subplot(211)
|
||||
ax.plot(time, jm, color = 'C0', label = '1)')
|
||||
ax.plot(time, jm - cutf, color = 'darkorange', label = '2)')
|
||||
ax.set_ylabel('frequency[Hz]')
|
||||
ax.set_ylim(-10.5, 10.5)
|
||||
ax.axes.xaxis.set_ticklabels([])
|
||||
plt.legend(loc='upper right')
|
||||
plt.text(-0.1, 1.05, "A)", fontweight=550, transform=ax.transAxes)
|
||||
|
||||
# jar trace and fit
|
||||
plt.plot(time, jm - cutf, color = 'darkorange', label = 'JAR: subtracted by mean and step response')
|
||||
ax1 = fig.add_subplot(212)
|
||||
ax1.plot(time, jm - cutf, color = 'darkorange', label = '2)')
|
||||
phase_gain = [(((p % (2 * np.pi)) * 360) / (2 * np.pi)), A]
|
||||
|
||||
plt.plot(time, sin_response(time, *sinv), color = 'limegreen', label='fit: phaseshift=%.2f°, gain=%.2f[Hz/(mV/cm)]' % tuple(phase_gain))
|
||||
plt.title('JAR trace spectogram 2018lepto98 with fit, deltaf = -5Hz')
|
||||
plt.xlabel('time[s]')
|
||||
plt.ylabel('frequency[Hz]')
|
||||
plt.legend()
|
||||
print(phase_gain)
|
||||
ax1.plot(time, sin_response(time, *sinv), color = 'forestgreen', label='3)')
|
||||
|
||||
ax1.set_xlabel('time[s]')
|
||||
ax1.set_ylabel('frequency[Hz]')
|
||||
ax1.set_ylim(-10.5,10.5)
|
||||
plt.legend(loc = 'upper right')
|
||||
plt.text(-0.1, 1.05, "B)", fontweight=550, transform=ax1.transAxes)
|
||||
plt.show()
|
||||
plt.savefig('test_fig.png')
|
||||
embed()
|
||||
|
@ -14,10 +14,12 @@ from jar_functions import sin_response
|
||||
from jar_functions import mean_noise_cut
|
||||
from jar_functions import gain_curve_fit
|
||||
|
||||
plt.rcParams.update({'font.size': 12})
|
||||
|
||||
def take_second(elem): # function for taking the names out of files
|
||||
return elem[1]
|
||||
|
||||
identifier = ['2019lepto03']
|
||||
identifier = ['2018lepto4']
|
||||
for ident in identifier:
|
||||
|
||||
predict = []
|
||||
@ -35,16 +37,16 @@ for ident in identifier:
|
||||
currf = None
|
||||
idxlist = []
|
||||
|
||||
data = sorted(np.load('5Hz_%s files.npy' %ident), key = take_second) # list with filenames in it
|
||||
data = sorted(np.load('%s files.npy' %ident), key = take_second) # list with filenames in it
|
||||
|
||||
for i, d in enumerate(data):
|
||||
dd = list(d)
|
||||
|
||||
jar = np.load('5Hz_%s.npy' %dd) # load data for every file name
|
||||
jar = np.load('%s.npy' %dd) # load data for every file name
|
||||
jm = jar - np.mean(jar) # low-pass filtering by subtracting mean
|
||||
print(dd)
|
||||
|
||||
time = np.load('5Hz_%s time.npy' %dd) # time file
|
||||
time = np.load('%s time.npy' %dd) # time file
|
||||
dt = time[1] - time[0]
|
||||
|
||||
n = int(1/float(d[1])/dt)
|
||||
@ -122,26 +124,27 @@ for ident in identifier:
|
||||
# condition needed to be fulfilled: RMS < threshold or RMS < mean(RMS)
|
||||
idx_arr = (rootmeansquare_arr < threshold_arr) | (rootmeansquare_arr < np.mean(rootmeansquare_arr))
|
||||
|
||||
fig = plt.figure()
|
||||
fig = plt.figure(figsize = (8,14))
|
||||
fig.suptitle('gaincurve and RMS 2018lepto4')
|
||||
ax0 = fig.add_subplot(2, 1, 1)
|
||||
ax0.plot(amfreq_arr[idx_arr], mgain_arr[idx_arr], 'o')
|
||||
ax0.plot(amfreq_arr, mgain_arr, 'o')
|
||||
ax0.set_yscale('log')
|
||||
ax0.set_xscale('log')
|
||||
ax0.set_title('gaincurve 2019lepto03, deltaf = -5Hz')
|
||||
ax0.set_ylabel('gain [Hz/(mV/cm)]')
|
||||
ax0.set_xlabel('envelope_frequency [Hz]')
|
||||
#plt.savefig('%s gain' % data[0][0])
|
||||
ax0.axes.xaxis.set_ticklabels([])
|
||||
plt.text(-0.1, 1.05, "A)", fontweight=550, transform=ax0.transAxes)
|
||||
|
||||
ax1 = fig.add_subplot(2, 1, 2, sharex = ax0)
|
||||
ax1.plot(amfreq, threshold, 'o-', label = 'threshold', color = 'b')
|
||||
ax1.set_xscale('log')
|
||||
ax1.plot(amfreq, rootmeansquare, 'o-', label = 'RMS', color ='orange')
|
||||
ax1.set_xscale('log')
|
||||
ax1.set_xlabel('envelope_frequency [Hz]')
|
||||
ax1.set_xlabel('envelope frequency [Hz]')
|
||||
ax1.set_ylabel('RMS [Hz]')
|
||||
plt.text(-0.1, 1.05, "B)", fontweight=550, transform=ax1.transAxes)
|
||||
plt.legend()
|
||||
pylab.show()
|
||||
|
||||
#fig.savefig('test.pdf')
|
||||
#np.save('phaseshift_%s' % ident, mphaseshift_arr[idx_arr])
|
||||
#np.save('gain_%s' %ident, mgain_arr[idx_arr])
|
||||
#np.save('amf_%s' %ident, amfreq_arr[idx_arr])
|
||||
|
@ -18,20 +18,49 @@ identifier = [#'2018lepto1',
|
||||
#'2019lepto30',
|
||||
#'2020lepto04',
|
||||
#'2020lepto06',
|
||||
'2020lepto16',
|
||||
#'2020lepto16',
|
||||
'2020lepto19',
|
||||
'2020lepto20'
|
||||
#'2020lepto20'
|
||||
]
|
||||
|
||||
amf = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1]
|
||||
|
||||
custom_f = np.logspace(-2, -1, 10)
|
||||
custom_alpha = np.logspace(1.5, 1, 10)
|
||||
c_gain = []
|
||||
custom_tau = abs(1 / (2 * np.pi * custom_f))
|
||||
for t, a in zip(custom_tau, custom_alpha):
|
||||
custom_gain = []
|
||||
for am in amf:
|
||||
custom_g = gain_curve_fit(am, t, a)
|
||||
custom_gain.append(custom_g)
|
||||
c_gain.append(custom_gain)
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
ax.set_xscale('log')
|
||||
ax.set_yscale('log')
|
||||
for cc, c in enumerate(c_gain):
|
||||
ax.plot(amf, c)
|
||||
ax.axvline(x=custom_f[cc], ymin=0, ymax=5, alpha=0.8) # colors_uniform[ff])
|
||||
|
||||
plt.show()
|
||||
|
||||
mean = avgNestedLists(c_gain)
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
ax.set_xscale('log')
|
||||
ax.set_yscale('log')
|
||||
ax.plot(amf, mean)
|
||||
plt.show()
|
||||
|
||||
all = []
|
||||
|
||||
for ident in identifier:
|
||||
data = np.load('5Hz_gain_%s.npy' %ident)
|
||||
data = np.load('gain_%s.npy' %ident)
|
||||
all.append(data)
|
||||
|
||||
av = avgNestedLists(all)
|
||||
embed()
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
@ -45,10 +74,10 @@ fit = []
|
||||
fit_amf = []
|
||||
for ID in identifier:
|
||||
print(ID)
|
||||
amf = np.load('5Hz_amf_%s.npy' %ID)
|
||||
gain = np.load('5Hz_gain_%s.npy' %ID)
|
||||
amf = np.load('amf_%s.npy' %ID)
|
||||
gain = np.load('gain_%s.npy' %ID)
|
||||
|
||||
sinv, sinc = curve_fit(gain_curve_fit, amf, gain)
|
||||
sinv, sinc = curve_fit(gain_curve_fit, amf, gain, [2, 3])
|
||||
#print('tau:', sinv[0])
|
||||
tau.append(sinv[0])
|
||||
f_cutoff = abs(1 / (2*np.pi*sinv[0]))
|
||||
@ -63,7 +92,7 @@ for ff ,f in enumerate(fit):
|
||||
|
||||
ax.set_xscale('log')
|
||||
ax.set_yscale('log')
|
||||
ax.set_title('gain average all fish, deltaf: -5Hz')
|
||||
ax.set_title('gain average all fish')
|
||||
ax.set_ylabel('gain [Hz/(mV/cm)]')
|
||||
ax.set_xlabel('envelope_frequency [Hz]')
|
||||
ax.set_ylim(0.0008, )
|
||||
|
@ -93,6 +93,7 @@ for ID in identifier_uniform:
|
||||
tau_uniform.append(sinv[0])
|
||||
f_cutoff = abs(1 / (2*np.pi*sinv[0]))
|
||||
print('f_cutoff:', f_cutoff)
|
||||
print('alpha:', sinv[1])
|
||||
f_c_uniform.append(f_cutoff)
|
||||
fit_uniform.append(gain_curve_fit(amf, *sinv))
|
||||
fit_amf_uniform.append(amf)
|
||||
|
45
apteronotus_code/stimulus_model.py
Normal file
45
apteronotus_code/stimulus_model.py
Normal file
@ -0,0 +1,45 @@
|
||||
from IPython import embed
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from jar_functions import sin_response
|
||||
|
||||
plt.rcParams.update({'font.size': 12})
|
||||
|
||||
# AM model
|
||||
lower = 0
|
||||
upper = 200
|
||||
sample = 1000
|
||||
x = np.linspace(lower, upper, sample)
|
||||
y1 = (sin_response(np.linspace(lower, upper, sample), 0.02, -np.pi/2, -0.75) - 1)
|
||||
y2 = (sin_response(np.linspace(lower, upper, sample), 0.02, -np.pi/2, 0.75) + 1)
|
||||
|
||||
fig = plt.figure(figsize = (12,6))
|
||||
ax = fig.add_subplot(121)
|
||||
ax.plot(x, y1, c = 'red')
|
||||
ax.plot(x, y2, c = 'red')
|
||||
ax.fill_between(x, y1, y2)
|
||||
|
||||
ax.set_xlabel('time[s]')
|
||||
ax.set_ylabel('amplitude')
|
||||
ax.set_xlim(0,200)
|
||||
ax.axes.yaxis.set_ticks([])
|
||||
plt.text(-0.1, 1.05, "A)", fontweight=550, transform=ax.transAxes)
|
||||
|
||||
# carrier
|
||||
lower = 0
|
||||
upper = 10
|
||||
sample = 1000
|
||||
x = np.linspace(lower, upper, sample)
|
||||
y1 = (sin_response(np.linspace(lower, upper, sample), 800, np.pi, -0.75) - 1)
|
||||
|
||||
ax1 = fig.add_subplot(122)
|
||||
ax1.plot(x, y1)
|
||||
ax1.axhline(y = -0.25, c = 'red', lw = 2)
|
||||
ax1.axhline(y = -1.75, c = 'red', lw = 2)
|
||||
|
||||
ax1.set_xlabel('time[ms]')
|
||||
ax1.set_xlim(0,10)
|
||||
ax1.axes.get_yaxis().set_visible(False)
|
||||
plt.text(-0.1, 1.05, "B)", fontweight=550, transform=ax1.transAxes)
|
||||
|
||||
plt.show()
|
@ -3,7 +3,6 @@ import numpy as np
|
||||
from IPython import embed
|
||||
import matplotlib.pyplot as plt
|
||||
from jar_functions import parse_infodataset
|
||||
from jar_functions import adjust_eodf
|
||||
|
||||
base_path = 'D:\\jar_project\\JAR\\sin'
|
||||
|
||||
@ -36,5 +35,5 @@ for ID in identifier:
|
||||
print(i)
|
||||
print(np.mean(temperature))
|
||||
av_temperature.append(np.mean(temperature))
|
||||
|
||||
np.save('temperature.npy', av_temperature)
|
||||
embed()
|
@ -12,10 +12,14 @@ from jar_functions import get_time_zeros
|
||||
from jar_functions import import_data_eigen
|
||||
from scipy.signal import savgol_filter
|
||||
|
||||
plt.rcParams.update({'font.size': 18})
|
||||
|
||||
base_path = 'D:\\jar_project\\JAR\\eigenmannia\\deltaf'
|
||||
|
||||
#2015eigen8 no nix files
|
||||
identifier = ['2015eigen16', '2013eigen13','2015eigen17', '2015eigen19', '2020eigen22','2020eigen32']
|
||||
identifier = [#'2013eigen13',
|
||||
'2015eigen16','2015eigen17', '2015eigen19', '2020eigen22','2020eigen32']
|
||||
|
||||
|
||||
response = []
|
||||
deltaf = []
|
||||
@ -28,8 +32,8 @@ for ID in identifier:
|
||||
delta_f, duration = parse_stimuli_dat(stimuli_dat)
|
||||
dur = int(duration[0][0:2])
|
||||
print(delta_f)
|
||||
if delta_f ==[-2.0]:
|
||||
print('HANDLE WITH CARE -2Hz:', datapath)
|
||||
if delta_f != [4.0]:
|
||||
continue
|
||||
data, pre_data, dt = import_data_eigen(datapath)
|
||||
|
||||
#hstack concatenate: 'glue' pre_data and data
|
||||
@ -49,7 +53,7 @@ for ID in identifier:
|
||||
eodf4 = eodf * 4
|
||||
|
||||
lim0 = eodf4 - 40
|
||||
lim1 = eodf4 + 40
|
||||
lim1 = eodf4 + 60
|
||||
|
||||
df = freqs[1] - freqs[0]
|
||||
ix0 = int(np.floor(lim0/df)) # back to index
|
||||
@ -60,16 +64,6 @@ for ID in identifier:
|
||||
|
||||
cut_time_jar = times[:len(jar4)]
|
||||
ID_delta_f = [ID, str(delta_f[0]).split('.')[0]]
|
||||
plt.imshow(spec4, cmap='jet', origin='lower', extent=(times[0] - 10, times[-1] - 10, lim0, lim1), aspect='auto', vmin=-80, vmax=-10)
|
||||
plt.plot((cut_time_jar - 10), jar4, 'k', label = 'jar trace', lw = 2)
|
||||
plt.hlines(y=lim0 + 5, xmin=0, xmax=60, lw=2.5, color='gold', label='stimulus duration')
|
||||
plt.title('spectogram %s, deltaf: %sHz' %tuple(ID_delta_f))
|
||||
plt.xlim(right=times[-1] - 10)
|
||||
plt.legend()
|
||||
#plt.show()
|
||||
delta_f_ID = [str(delta_f[0]).split('.')[0], ID]
|
||||
plt.savefig('%sHz_specgram_jar_%s' %tuple(delta_f_ID))
|
||||
plt.close()
|
||||
|
||||
b = []
|
||||
for idx, i in enumerate(times):
|
||||
@ -81,10 +75,28 @@ for ID in identifier:
|
||||
j.append(jar4[idx])
|
||||
|
||||
r = np.median(j) - np.median(b)
|
||||
print(r)
|
||||
print('response:', r)
|
||||
deltaf.append(delta_f[0])
|
||||
response.append(r)
|
||||
|
||||
plt.figure(figsize = (14,8))
|
||||
plt.imshow(spec4, cmap='jet', origin='lower', extent=(times[0], times[-1], lim0, lim1), aspect='auto', vmin=-80, vmax=-10)
|
||||
plt.plot(cut_time_jar, jar4, 'k', label = 'peak detection trace', lw = 2)
|
||||
plt.hlines(y=lim0 + 5, xmin=10, xmax=70, lw=4, color='yellow', label='stimulus duration')
|
||||
plt.hlines(y=lim0 + 5, xmin=0, xmax=10, lw=4, color='red', label='pause')
|
||||
plt.title('spectogram %s, deltaf: %sHz' %tuple(ID_delta_f))
|
||||
plt.xlim(times[0],times[-1])
|
||||
#embed()
|
||||
#plt.xticks((times[0], 10, 20, 30, 40, 50, 60, times[-1]), [0, 10, 20, 30 ,40, 50, 60, 70])
|
||||
plt.xlabel('time [s]')
|
||||
plt.ylabel('frequency [Hz]')
|
||||
plt.legend(loc = 'best')
|
||||
plt.show()
|
||||
delta_f_ID = [str(delta_f[0]).split('.')[0], ID]
|
||||
|
||||
plt.close()
|
||||
|
||||
|
||||
res_df = sorted(zip(deltaf,response))
|
||||
|
||||
#np.save('res_df_%s_new' %ID, res_df)
|
||||
|
138
eigenmannia_code/eigenmannia_jar_subplot.py
Normal file
138
eigenmannia_code/eigenmannia_jar_subplot.py
Normal file
@ -0,0 +1,138 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import os
|
||||
import nix_helpers as nh
|
||||
from IPython import embed
|
||||
from matplotlib.mlab import specgram
|
||||
#from tqdm import tqdm
|
||||
from jar_functions import parse_stimuli_dat
|
||||
from jar_functions import norm_function_eigen
|
||||
from jar_functions import mean_noise_cut_eigen
|
||||
from jar_functions import get_time_zeros
|
||||
from jar_functions import import_data_eigen
|
||||
from scipy.signal import savgol_filter
|
||||
|
||||
plt.rcParams.update({'font.size': 18})
|
||||
|
||||
base_path = 'D:\\jar_project\\JAR\\eigenmannia\\deltaf'
|
||||
|
||||
#2015eigen8 no nix files
|
||||
identifier = [#'2013eigen13',
|
||||
'2015eigen16'] #,'2015eigen17', '2015eigen19', '2020eigen22','2020eigen32']
|
||||
|
||||
|
||||
response = []
|
||||
deltaf = []
|
||||
|
||||
specs = []
|
||||
jars = []
|
||||
sub_times = []
|
||||
sub_lim0 = []
|
||||
sub_lim1 = []
|
||||
|
||||
for ID in identifier:
|
||||
for dataset in os.listdir(os.path.join(base_path, ID)):
|
||||
datapath = os.path.join(base_path, ID, dataset, '%s.nix' % dataset)
|
||||
#print(datapath)
|
||||
stimuli_dat = os.path.join(base_path, ID, dataset, 'manualjar-eod.dat')
|
||||
#print(stimuli_dat)
|
||||
delta_f, duration = parse_stimuli_dat(stimuli_dat)
|
||||
dur = int(duration[0][0:2])
|
||||
if delta_f == [-2.0] or delta_f == [2.0] or delta_f == [-10.0] or delta_f == [10.0]:
|
||||
print(delta_f)
|
||||
|
||||
data, pre_data, dt = import_data_eigen(datapath)
|
||||
# hstack concatenate: 'glue' pre_data and data
|
||||
dat = np.hstack((pre_data, data))
|
||||
|
||||
# data
|
||||
nfft = 2 ** 17
|
||||
spec, freqs, times = specgram(dat[0], Fs=1 / dt, detrend='mean', NFFT=nfft, noverlap=nfft * 0.95)
|
||||
dbspec = 10.0 * np.log10(spec) # in dB
|
||||
power = dbspec[:, 25]
|
||||
|
||||
fish_p = power[(freqs > 200) & (freqs < 1000)]
|
||||
fish_f = freqs[(freqs > 200) & (freqs < 1000)]
|
||||
|
||||
index = np.argmax(fish_p)
|
||||
eodf = fish_f[index]
|
||||
eodf4 = eodf * 4
|
||||
|
||||
lim0 = eodf4 - 40
|
||||
lim1 = eodf4 + 40
|
||||
|
||||
df = freqs[1] - freqs[0]
|
||||
ix0 = int(np.floor(lim0 / df)) # back to index
|
||||
ix1 = int(np.ceil(lim1 / df)) # back to index
|
||||
spec4 = dbspec[ix0:ix1, :]
|
||||
freq4 = freqs[ix0:ix1]
|
||||
jar4 = freq4[np.argmax(spec4, axis=0)] # all freqs at max specs over axis 0
|
||||
|
||||
cut_time_jar = times[:len(jar4)]
|
||||
ID_delta_f = [ID, str(delta_f[0]).split('.')[0]]
|
||||
|
||||
b = []
|
||||
for idx, i in enumerate(times):
|
||||
if i > 0 and i < 10:
|
||||
b.append(jar4[idx])
|
||||
j = []
|
||||
for idx, i in enumerate(times):
|
||||
if i > 15 and i < 55:
|
||||
j.append(jar4[idx])
|
||||
|
||||
r = np.median(j) - np.median(b)
|
||||
print('response:', r)
|
||||
deltaf.append(delta_f[0])
|
||||
response.append(r)
|
||||
specs.append(spec4)
|
||||
jars.append(jar4)
|
||||
sub_times.append(cut_time_jar)
|
||||
sub_lim0.append(lim0)
|
||||
sub_lim1.append(lim1)
|
||||
if len(specs) == 4:
|
||||
break
|
||||
|
||||
# plt.imshow(specs[0], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[0], sub_lim1[1]), aspect='auto', vmin=-80, vmax=-10)
|
||||
# plt.plot(sub_times[0], jars[0], 'k', label = 'peak detection trace', lw = 2)
|
||||
# plt.hlines(y=lim0 + 5, xmin=10, xmax=70, lw=4, color='yellow', label='stimulus duration')
|
||||
# plt.hlines(y=lim0 + 5, xmin=0, xmax=10, lw=4, color='red', label='pause')
|
||||
# plt.title('spectogram %s, deltaf: %sHz' %tuple(ID_delta_f))
|
||||
# plt.xlim(times[0],times[-1])
|
||||
|
||||
fig = plt.figure(figsize = (20,20))
|
||||
ax0 = fig.add_subplot(221)
|
||||
ax0.imshow(specs[0], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[0], sub_lim1[0]), aspect='auto', vmin=-80, vmax=-10)
|
||||
ax0.plot(sub_times[0], jars[0], 'k', label = 'peak detection trace', lw = 2)
|
||||
ax0.set_xlim(times[0],times[-1])
|
||||
ax0.set_ylabel('frequency [Hz]')
|
||||
ax0.axes.xaxis.set_ticklabels([])
|
||||
ax0.set_title('∆F -2 Hz')
|
||||
|
||||
ax1 = fig.add_subplot(222)
|
||||
ax1.imshow(specs[1], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[1], sub_lim1[1]), aspect='auto', vmin=-80, vmax=-10)
|
||||
ax1.plot(sub_times[1], jars[1], 'k', label = 'peak detection trace', lw = 2)
|
||||
ax1.set_xlim(times[0],times[-1])
|
||||
ax1.axes.xaxis.set_ticklabels([])
|
||||
ax1.axes.yaxis.set_ticklabels([])
|
||||
ax1.set_title('∆F -10 Hz')
|
||||
|
||||
ax2 = fig.add_subplot(223)
|
||||
ax2.imshow(specs[2], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[2], sub_lim1[2]), aspect='auto', vmin=-80, vmax=-10)
|
||||
ax2.plot(sub_times[2], jars[2], 'k', label = 'peak detection trace', lw = 2)
|
||||
ax2.set_xlim(times[0],times[-1])
|
||||
ax2.set_ylabel('frequency [Hz]')
|
||||
ax2.set_xlabel('time [s]')
|
||||
ax2.set_title('∆F 2 Hz')
|
||||
|
||||
ax3 = fig.add_subplot(224)
|
||||
ax3.imshow(specs[3], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[3], sub_lim1[3]), aspect='auto', vmin=-80, vmax=-10)
|
||||
ax3.plot(sub_times[3], jars[3], 'k', label = 'peak detection trace', lw = 2)
|
||||
ax3.set_xlim(times[0],times[-1])
|
||||
ax3.set_xlabel('time [s]')
|
||||
ax3.axes.yaxis.set_ticklabels([])
|
||||
ax3.set_title('∆F 10 Hz')
|
||||
|
||||
plt.show()
|
||||
|
||||
embed()
|
||||
|
4
notes
4
notes
@ -1,11 +1,11 @@
|
||||
machen:
|
||||
- phaseshift (sin_all) nochmal, nicht richtiges Dings verwendet ( sinv[2]/p) und dann auch in phaseshift
|
||||
- wenn benötigt sin response fit mit neuer phaseshift berechnung nochmal durchlaufen lassen, dann phasshift all
|
||||
- abbildung erstellen mit custom cutoff frequencies über ganzen bereich (0.001Hz-1Hz) um hoffentlich zu zeigen dass dabei lineare
|
||||
Gerade entsteht, vergleichen mit uniformen Bereich bei Daten bei dem es sich auch eher linear verhält um zu zeigen auf was wir hinaus wollen
|
||||
- filter: zieht mean von einer amfreq periode ab wodurch alles was nicht damit in Verbindung steht herausfiltert,
|
||||
auch JAR. problematisch wird dies eher wenn JAR-Anstieg schneller abläuft als eine amfreq periode
|
||||
- wenn fit nicht funktioniert einfach weglassen, wenn sättigung vorhanden nochmal anschauen
|
||||
|
||||
- base_eod und q10 und temp für eigenmannia
|
||||
|
||||
+ figures:
|
||||
apteronotus: fundament by tims bachelor thesis, important that apteronotus only shifts his frequency up (as eigenmannia doesnt --> natalies measurements)
|
||||
|
Loading…
Reference in New Issue
Block a user