In [ ]:
%matplotlib inline
import numpy as np
import pylab as pl
from psi.data.io import Recording
#recording = Recording('c:/test/20190311-145440cal/')
recording = Recording('c:/psi/data/20190311-1553 TEST TEST right abr/')
In [ ]:
y = recording.eeg[:100000]
t = np.arange(len(y)) / recording.eeg.fs
pl.figure()
pl.plot(t, y)
o = recording.erp_metadata.iloc[0].t0
d = recording.erp_metadata.iloc[0].duration
lb = int(round(recording.eeg.fs * o))
ub = lb + int(round(recording.eeg.fs * d))
print(lb, ub)
pl.figure()
pl.plot(t[lb:ub], y[lb:ub])
In [ ]:
epochs = recording.epoch[:]
pl.plot(epochs[:10000])
#recording.epoch_metadata
recording.epoch_metadata.iloc[0].t0
In [ ]:
o = recording.epoch_metadata.iloc[0].t0
s = recording.epoch_metadata.iloc[0].duration
print(o, s)
lb = int(round((o-0.1) * recording.epoch.fs))
ub = lb + int(round(s * recording.epoch.fs))
pl.plot(recording.epoch[lb:ub])
In [ ]:
from atom.api import *
In [ ]:
attrs = {
'foo': Float(),
'bar': Int(),
}
c = type('ContextContainer', (Atom,), attrs)
c(foo=4, bar=5.1)
In [ ]:
t0 = recording.event_log.query('event == "dpoae_start"').iloc[-2]['timestamp']
discard = 5e-3 * 2
window = 100e-3
f2_frequency = 8000.0
f1_frequency = f2_frequency / 1.2
dpoae = 2*f1_frequency - f2_frequency
print(f1_frequency, f2_frequency, dpoae)
segments = recording.microphone.get_segments([t0], discard, 4*8*50e-3).values
samples = round(50e-3 * recording.microphone.fs)
segments = segments.reshape((-1, samples))
In [ ]:
pl.plot(segments[0, :100])
pl.plot(segments[1, :100])
In [ ]:
from psi.controller.calibration import util
In [ ]:
util.db(util.tone_power_conv(segments, recording.microphone.fs, dpoae, 'hann')).mean()
In [ ]:
util.db(util.tone_power_conv(segments, recording.microphone.fs, f2_frequency, 'hann')).mean()
In [ ]:
util.db(util.tone_power_conv(segments, recording.microphone.fs, f1_frequency, 'hann')).mean()
In [ ]: