121 lines
3.9 KiB
Python
121 lines
3.9 KiB
Python
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
|
|
response = []
|
|
stim_ampl = []
|
|
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, stimulusamplitude, 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
|
|
|
|
mf, tnew = mean_traces(start, stop, timespan, frequency, time) # maybe fixed timespan/sampling rate
|
|
|
|
cf, ct = mean_noise_cut_eigen(mf, tnew, n=1250)
|
|
|
|
onset_point = dm - dm
|
|
offset_point = dm
|
|
onset_end = onset_point - 10
|
|
offset_start = offset_point - 10
|
|
|
|
|
|
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])
|
|
|
|
''' sounds good, doesnt work somehow: in norm devision by 0 (jar) or index doesnt fit
|
|
norm, base, jar = norm_function(frequency, time, onset_point=dm - dm,
|
|
offset_point=dm) # dm-dm funktioniert nur wenn onset = 0 sec
|
|
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])
|
|
b = np.median(cf[(ct >= onset_end) & (ct < onset_point)])
|
|
|
|
j = np.median(cf[(ct >= offset_start) & (ct < offset_point)])
|
|
|
|
'''
|
|
|
|
r = np.median(j) - np.median(b)
|
|
response.append(r)
|
|
stim_ampl.append(stimulusamplitude)
|
|
res_ampl = sorted(zip(stim_ampl, response))
|
|
base_line = plt.axhline(y = 0, color = 'black', ls = 'dotted', linewidth = '1')
|
|
|
|
plt.xlabel('Stimulusamplitude')
|
|
plt.ylabel('absolute JAR magnitude')
|
|
plt.title('absolute JAR')
|
|
plt.savefig('relative JAR')
|
|
plt.legend(loc = 'lower right')
|
|
plt.show()
|
|
embed()
|
|
|
|
|
|
# natalie fragen ob sie bei verschiedenen Amplituden messen kann (siehe tim)
|