29.06
This commit is contained in:
parent
25b2f43e71
commit
c3c92fd42d
@ -52,14 +52,21 @@ def parse_dataset(dataset_name):
|
|||||||
times.append(time) #append data from one list to another
|
times.append(time) #append data from one list to another
|
||||||
amplitudes.append(ampl) #these append the data from the first loop to the final lists, because we overwrite them (?)
|
amplitudes.append(ampl) #these append the data from the first loop to the final lists, because we overwrite them (?)
|
||||||
frequencies.append(freq)
|
frequencies.append(freq)
|
||||||
embed()
|
|
||||||
|
|
||||||
minimum = min(len(frequency[0]), len(frequency[1]))
|
return times, frequencies, amplitudes, eodfs, deltafs, stimulusfs #output of the function
|
||||||
f1 = frequencies[0][:minimum]
|
|
||||||
f2 = frequencies[1][:minimum]
|
|
||||||
|
|
||||||
#print(len(time))
|
|
||||||
print(len(times))
|
|
||||||
embed()
|
|
||||||
|
|
||||||
return times, frequencies, amplitudes, eodfs, deltafs, stimulusfs #output of the function
|
|
||||||
|
def noise_reduce(dataset_name):
|
||||||
|
assert (os.path.exists(dataset_name)) # see if data exists
|
||||||
|
f = open(dataset_name, 'r') # open data we gave in
|
||||||
|
lines = f.readlines() # read data
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
n = 10
|
||||||
|
cutf = []
|
||||||
|
for i in np.arange(0, len(dataset_name), n): #dataset_name sollte Frequenzen sein?
|
||||||
|
mean = np.mean(dataset_name[i:i+n]) #sollte nach i+n weitergehen?
|
||||||
|
cutf.append(mean)
|
||||||
|
|
||||||
|
return cutf
|
11
scratch.py
11
scratch.py
@ -1,4 +1,6 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
from IPython import embed
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#second_try scratch
|
#second_try scratch
|
||||||
minimum = min(len(frequency[0]), len(frequency[1]))
|
minimum = min(len(frequency[0]), len(frequency[1]))
|
||||||
@ -21,4 +23,11 @@ g = [1, 2]
|
|||||||
|
|
||||||
h = [3, 4]
|
h = [3, 4]
|
||||||
|
|
||||||
z = np.array([1, 2], [3, 4], dtype=object)
|
z = np.array([[g], [h]])
|
||||||
|
|
||||||
|
mean0 = np.mean(z, axis=0)
|
||||||
|
mean1 = np.mean(z, axis=1)
|
||||||
|
|
||||||
|
print(mean0)
|
||||||
|
print(mean1)
|
||||||
|
|
||||||
|
@ -5,9 +5,10 @@ import IPython
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from IPython import embed
|
from IPython import embed
|
||||||
from jar_functions import parse_dataset
|
from jar_functions import parse_dataset
|
||||||
|
from jar_functions import noise_reduce
|
||||||
|
|
||||||
|
|
||||||
datasets = [(os.path.join('D:\\jar_project\\JAR\\2020-06-22-ab\\beats-eod.dat'))]
|
datasets = [(os.path.join('D:\\jar_project\\JAR\\2020-06-22-ac\\beats-eod.dat'))]
|
||||||
# (os.path.join('D:\\jar_project\\JAR\\2020-06-22-ac\\beats-eod.dat'))]
|
# (os.path.join('D:\\jar_project\\JAR\\2020-06-22-ac\\beats-eod.dat'))]
|
||||||
|
|
||||||
eodf = []
|
eodf = []
|
||||||
@ -15,31 +16,75 @@ deltaf = []
|
|||||||
stimulusf = []
|
stimulusf = []
|
||||||
|
|
||||||
time = []
|
time = []
|
||||||
frequency = []
|
frequency_mean= []
|
||||||
amplitude = []
|
amplitude = []
|
||||||
|
|
||||||
|
start = -10
|
||||||
|
stop = 200
|
||||||
|
timespan = 210
|
||||||
|
|
||||||
for dataset in datasets:
|
for dataset in datasets:
|
||||||
|
#input of the function
|
||||||
t, f, a, e, d, s= parse_dataset(dataset)
|
t, f, a, e, d, s= parse_dataset(dataset)
|
||||||
|
|
||||||
time.append(t)
|
'times'
|
||||||
frequency.append(f)
|
# same for time in both loops
|
||||||
amplitude.append(a)
|
minimumt = min(len(t[0]), len(t[1]))
|
||||||
|
t0 = t[0][:minimumt]
|
||||||
|
t1 = t[1][:minimumt]
|
||||||
|
|
||||||
|
# new time with wished timespan because it varies for different loops
|
||||||
|
tnew = np.arange(start, stop, timespan / minimumt) # 3rd input is stepspacing:
|
||||||
|
# in case complete measuring time devided by total number of datapoints
|
||||||
|
|
||||||
|
'frequencies'
|
||||||
|
# minimum datapoint lenght of both loops of frequencies
|
||||||
|
minimumf = min(len(f[0]), len(f[1]))
|
||||||
|
# new frequencies to minimum for both loops
|
||||||
|
f0 = f[0][:minimumf]
|
||||||
|
# interpolation
|
||||||
|
f0new = np.interp(tnew, t0, f0)
|
||||||
|
|
||||||
|
f1 = f[1][:minimumf]
|
||||||
|
# interpolation
|
||||||
|
f1new = np.interp(tnew, t1, f1)
|
||||||
|
|
||||||
|
#new array with frequencies of both loops as two lists put together as an array
|
||||||
|
frequency = np.array([[f0new], [f1new]])
|
||||||
|
#making a mean over both loops with the axis 0 (=averaged in y direction, axis=1 would be over x axis)
|
||||||
|
mf = np.mean(frequency, axis=0).T #.T as transition (1,0) -> (0,1)
|
||||||
|
|
||||||
|
|
||||||
|
#other variant for transition by reshaping in needed dimension
|
||||||
|
mfreshape = np.reshape(mf, (minimumf, 1)) #as ploting is using the first dimension, number of datapoints has to be in the first
|
||||||
|
treshape = np.reshape(tnew, (minimumf, 1))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#appending data
|
||||||
eodf.append(e)
|
eodf.append(e)
|
||||||
deltaf.append(d)
|
deltaf.append(d)
|
||||||
stimulusf.append(s)
|
stimulusf.append(s)
|
||||||
|
amplitude.append(a)
|
||||||
|
|
||||||
mean = np.mean(frequency, axis=0)
|
frequency_mean.append(mfreshape)
|
||||||
|
time.append(treshape)
|
||||||
|
|
||||||
#embed()
|
cutfreq = noise_reduce(mfreshape)
|
||||||
|
embed()
|
||||||
|
|
||||||
#evtl. normiert darstellen (frequency / baseline frequency?)?
|
|
||||||
#Zeitkonstante: von sec. 0 bis 63%? relative JAR
|
|
||||||
|
|
||||||
plt.plot(time, frequency)
|
|
||||||
|
|
||||||
|
#plotting
|
||||||
|
'''why does append put in a 3rd dimension? plt.plot(time, frequency_mean) '''
|
||||||
|
|
||||||
|
plt.plot(treshape, mfreshape)
|
||||||
|
plt.xlim([-10,200])
|
||||||
|
#plt.ylim([400, 1000])
|
||||||
plt.xlabel('time [s]')
|
plt.xlabel('time [s]')
|
||||||
plt.ylabel('frequency [Hz]')
|
plt.ylabel('frequency [Hz]')
|
||||||
plt.xlim([-10,200])
|
|
||||||
plt.title('second try because first try was sold out')
|
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
#evtl. normiert darstellen (frequency / baseline frequency?)?
|
||||||
|
#Zeitkonstante: von sec. 0 bis 63%? relative JAR
|
||||||
|
Loading…
Reference in New Issue
Block a user