70 lines
2.0 KiB
Python
70 lines
2.0 KiB
Python
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
import os
|
|
import nix_helpers as nh
|
|
from IPython import embed
|
|
#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
|
|
|
|
base_path = 'D:\\jar_project\\JAR\\eigenmannia\\2015eigen16'
|
|
|
|
datasets = ['2020-07-08-aa', '2020-07-08-as']
|
|
|
|
response = []
|
|
deltaf = []
|
|
|
|
for dataset in os.listdir(base_path):
|
|
datapath = os.path.join(base_path, dataset, '%s.nix' % dataset)
|
|
print(datapath)
|
|
stimuli_dat = os.path.join(base_path, dataset, 'manualjar-eod.dat')
|
|
|
|
df, duration = parse_stimuli_dat(stimuli_dat)
|
|
dur = int(duration[0][0:2])
|
|
print(df)
|
|
|
|
time, eod = nh.read_eod(datapath, duration = 2000)
|
|
|
|
zeropoints = get_time_zeros(time, eod, threshold = np.max(eod)*0.1)
|
|
|
|
frequencies = 1 / np.diff(zeropoints)
|
|
|
|
# norm, base, jar = norm_function_eigen(frequencies, zeropoints[:-1], onset_point=(dur - dur)+10, offset_point=dur+10) # dm-dm funktioniert nur wenn onset = 0 sec
|
|
|
|
# cf, ct = mean_noise_cut_eigen(frequencies, zeropoints[:-1], n=200)
|
|
|
|
window = np.ones(101) / 101
|
|
freq = np.convolve(frequencies, window, mode='same')
|
|
|
|
''' # plt.plot(ct, cf)
|
|
plt.plot(zeropoints[:-1], freq)
|
|
plt.ylabel('EOD_frequency [Hz]')
|
|
plt.xlabel('time [s]')
|
|
plt.xlim(1, 140)
|
|
plt.ylim(np.median(freq) - 10, np.median(freq) + 10)
|
|
plt.title('JAR_deltaf_%s' % deltaf)
|
|
plt.show()
|
|
'''
|
|
j = []
|
|
for idx, i in enumerate(zeropoints):
|
|
if i > 20 and i < 80:
|
|
j.append(freq[idx])
|
|
|
|
b = []
|
|
for idx, i in enumerate(zeropoints):
|
|
if i < 20:
|
|
b.append(freq[idx])
|
|
|
|
r = np.median(j) - np.median(b)
|
|
response.append(r)
|
|
deltaf.append(df[0])
|
|
|
|
res_df1 = sorted(zip(deltaf[:32],response[:32]))
|
|
res_df2 = sorted(zip(deltaf[33:],response[33:]))
|
|
res_df = sorted(zip(deltaf,response))
|
|
|
|
np.save('res_df1', res_df1)
|
|
np.save('res_df2', res_df2)
|
|
np.save('res_df', res_df) |