18.09
This commit is contained in:
parent
a5a9cfbe73
commit
042bdd7aa3
102
eigenmannia_code/step_response_eigen.py
Normal file
102
eigenmannia_code/step_response_eigen.py
Normal file
@ -0,0 +1,102 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib as cm
|
||||
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
|
||||
import os
|
||||
import glob
|
||||
import IPython
|
||||
import numpy as np
|
||||
from IPython import embed
|
||||
from scipy.optimize import curve_fit
|
||||
from jar_functions import parse_dataset
|
||||
from jar_functions import parse_infodataset
|
||||
from jar_functions import mean_traces
|
||||
from jar_functions import mean_noise_cut_eigen
|
||||
from jar_functions import norm_function
|
||||
from jar_functions import step_response
|
||||
from jar_functions import sort_values
|
||||
from jar_functions import average
|
||||
|
||||
base_path = 'D:\\jar_project\\JAR\\eigen\\step'
|
||||
|
||||
identifier = ['step_2015eigen8',
|
||||
'step_2015eigen15',
|
||||
'step_2015eigen16',
|
||||
'step_2015eigen17',
|
||||
'step_2015eigen19']
|
||||
datasets = []
|
||||
|
||||
#dat = glob.glob('D:\\jar_project\\JAR\\2020*\\beats-eod.dat')
|
||||
#infodat = glob.glob('D:\\jar_project\\JAR\\2020*\\info.dat')
|
||||
|
||||
time_all = []
|
||||
freq_all = []
|
||||
|
||||
ID = []
|
||||
col = ['dimgrey', 'grey', 'darkgrey', 'silver', 'lightgrey', 'gainsboro', 'whitesmoke']
|
||||
labels = zip(ID, datasets)
|
||||
|
||||
for infodataset in datasets:
|
||||
infodataset = os.path.join(base_path, infodataset, 'info.dat')
|
||||
i = parse_infodataset(infodataset)
|
||||
identifier = i[0]
|
||||
ID.append(identifier)
|
||||
|
||||
for ID in identifier:
|
||||
base_path = 'D:\\jar_project\\JAR\\eigenmannia\\step\\%s' %ID
|
||||
res_df = []
|
||||
for idx, dataset in enumerate(os.listdir(base_path)):
|
||||
dataset = os.path.join(base_path, dataset, 'beats-eod.dat')
|
||||
print(dataset)
|
||||
#input of the function
|
||||
frequency, time, amplitude, eodf, deltaf, stimulusf, duration, pause = parse_dataset(dataset)
|
||||
dm = np.mean(duration)
|
||||
pm = np.mean(pause)
|
||||
timespan = dm + pm
|
||||
start = np.mean([t[0] for t in time])
|
||||
stop = np.mean([t[-1] for t in time])
|
||||
if len(frequency) == 5:
|
||||
continue
|
||||
|
||||
norm, base, jar = norm_function(frequency, time, onset_point=dm - dm, offset_point=dm) # dm-dm funktioniert nur wenn onset = 0 sec
|
||||
print(jar)
|
||||
if jar[0] == 0.0:
|
||||
continue
|
||||
|
||||
mf, tnew = mean_traces(start, stop, timespan, norm, time) # maybe fixed timespan/sampling rate
|
||||
|
||||
cf, ct = mean_noise_cut_eigen(mf, tnew, n=1250)
|
||||
|
||||
cf_arr = np.array(cf)
|
||||
ct_arr = np.array(ct)
|
||||
|
||||
freq_all.append(cf_arr)
|
||||
time_all.append(ct_arr)
|
||||
|
||||
b = []
|
||||
for index, i in enumerate(ct):
|
||||
if i > -45 and i < -5:
|
||||
b.append(cf[index])
|
||||
|
||||
j = []
|
||||
for indexx, h in enumerate(ct):
|
||||
if h > 195 and h < 145:
|
||||
j.append(cf[indexx])
|
||||
print(h)
|
||||
print(indexx)
|
||||
print(cf[indexx])
|
||||
r = np.median(j) - np.median(b)
|
||||
#response.append(r)
|
||||
embed()
|
||||
base_line = plt.axhline(y = 0, color = 'black', ls = 'dotted', linewidth = '1')
|
||||
|
||||
plt.xlim([-10,220])
|
||||
plt.xlabel('time [s]')
|
||||
plt.ylabel('rel. JAR magnitude')
|
||||
plt.title('relative JAR')
|
||||
plt.savefig('relative JAR')
|
||||
plt.legend(loc = 'lower right')
|
||||
plt.show()
|
||||
embed()
|
||||
|
||||
|
||||
# natalie fragen ob sie bei verschiedenen Amplituden messen kann (siehe tim)
|
6
notes
6
notes
@ -2,12 +2,16 @@
|
||||
eod basefrequenz rausziehen, scatter plot gegen cutoff frequency, ...
|
||||
- cutoff - dominance score
|
||||
- cutoff - basefrequency
|
||||
- gain - dominance_score: für gain predict machen pro fish?
|
||||
- gain - dominance_score: für gain predict machen pro fish,
|
||||
hab ich dazu die richtige zeitckonstante aus gain_fit?
|
||||
... da ich ja prediction auch über sin und nicht step mache dann
|
||||
+ eigenmannia: specgram von pre_data neben specgram von data machen um zu sehen ob analyse fehler oder fehler in import_data
|
||||
- erkenntnis: hab bei bm/jm nicht den gleichen mean abgezogen..
|
||||
- an sich res_df besser, jedoch immer noch relativ variabel
|
||||
- -2Hz bei meisten negative JAR?
|
||||
- evtl. doch mean anstatt median für response am ende?
|
||||
+ look at step eigen data
|
||||
- norming of data: what if in norm = ground / jar with jar == 0.0?
|
||||
+ look at 5Hz data - compare
|
||||
|
||||
long term:
|
||||
|
Loading…
Reference in New Issue
Block a user