Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gamma = out['gamma']
# PLF features
_, plf_pairs, plf = get_plf_features(signal=filtered,
sampling_rate=sampling_rate,
size=0.25,
overlap=0.5)
# get time vectors
length = len(signal)
T = (length - 1) / sampling_rate
ts = np.linspace(0, T, length, endpoint=True)
# plot
if show:
plotting.plot_eeg(ts=ts,
raw=signal,
filtered=filtered,
labels=labels,
features_ts=ts_feat,
theta=theta,
alpha_low=alpha_low,
alpha_high=alpha_high,
beta=beta,
gamma=gamma,
plf_pairs=plf_pairs,
plf=plf,
path=None,
show=True)
# output
args = (ts, filtered, ts_feat, theta, alpha_low, alpha_high, beta, gamma,
band='highpass',
order=4,
frequency=100,
sampling_rate=sampling_rate)
# find onsets
onsets, = find_onsets(signal=filtered, sampling_rate=sampling_rate)
# get time vectors
length = len(signal)
T = (length - 1) / sampling_rate
ts = np.linspace(0, T, length, endpoint=True)
# plot
if show:
plotting.plot_emg(ts=ts,
sampling_rate=1000.,
raw=signal,
filtered=filtered,
processed=None,
onsets=onsets,
path=None,
show=True)
# output
args = (ts, filtered, onsets)
names = ('ts', 'filtered', 'onsets')
return utils.ReturnTuple(args, names)
id_res = np.array(id_res)
results[subject] = {'authentication': auth_res,
'identification': id_res,
}
# assess classification results
assess, = assess_classification(results, thresholds)
# output
args = (results, assess)
names = ('classification', 'assessment')
out = utils.ReturnTuple(args, names)
if show:
# plot
plotting.plot_biometrics(assess, self.EER_IDX, show=True)
return out
# compute heart rate
hr_idx, hr = st.get_heart_rate(beats=rpeaks,
sampling_rate=sampling_rate,
smooth=True,
size=3)
# get time vectors
length = len(signal)
T = (length - 1) / sampling_rate
ts = np.linspace(0, T, length, endpoint=True)
ts_hr = ts[hr_idx]
ts_tmpl = np.linspace(-0.2, 0.4, templates.shape[1], endpoint=False)
# plot
if show:
plotting.plot_ecg(ts=ts,
raw=signal,
filtered=filtered,
rpeaks=rpeaks,
templates_ts=ts_tmpl,
templates=templates,
heart_rate_ts=ts_hr,
heart_rate=hr,
path=None,
show=True)
# output
args = (ts, filtered, rpeaks, ts_tmpl, templates, ts_hr, hr)
names = ('ts', 'filtered', 'rpeaks', 'templates_ts', 'templates',
'heart_rate_ts', 'heart_rate')
return utils.ReturnTuple(args, names)
# smooth with moving average
size = 3
rate, _ = st.smoother(signal=rate,
kernel='boxcar',
size=size,
mirror=True)
# get time vectors
length = len(signal)
T = (length - 1) / sampling_rate
ts = np.linspace(0, T, length, endpoint=True)
ts_rate = ts[rate_idx]
# plot
if show:
plotting.plot_resp(ts=ts,
raw=signal,
filtered=filtered,
zeros=zeros,
resp_rate_ts=ts_rate,
resp_rate=rate,
path=None,
show=True)
# output
args = (ts, filtered, zeros, ts_rate, rate)
names = ('ts', 'filtered', 'zeros', 'resp_rate_ts', 'resp_rate')
return utils.ReturnTuple(args, names)
size=sm_size,
mirror=True)
# get SCR info
onsets, peaks, amps = kbk_scr(signal=filtered,
sampling_rate=sampling_rate,
min_amplitude=min_amplitude)
# get time vectors
length = len(signal)
T = (length - 1) / sampling_rate
ts = np.linspace(0, T, length, endpoint=True)
# plot
if show:
plotting.plot_eda(ts=ts,
raw=signal,
filtered=filtered,
onsets=onsets,
peaks=peaks,
amplitudes=amps,
path=None,
show=True)
# output
args = (ts, filtered, onsets, peaks, amps)
names = ('ts', 'filtered', 'onsets', 'peaks', 'amplitudes')
return utils.ReturnTuple(args, names)
# compute heart rate
hr_idx, hr = st.get_heart_rate(beats=onsets,
sampling_rate=sampling_rate,
smooth=True,
size=3)
# get time vectors
length = len(signal)
T = (length - 1) / sampling_rate
ts = np.linspace(0, T, length, endpoint=False)
ts_hr = ts[hr_idx]
# plot
if show:
plotting.plot_bvp(ts=ts,
raw=signal,
filtered=filtered,
onsets=onsets,
heart_rate_ts=ts_hr,
heart_rate=hr,
path=None,
show=True)
# output
args = (ts, filtered, onsets, ts_hr, hr)
names = ('ts', 'filtered', 'onsets', 'heart_rate_ts', 'heart_rate')
return utils.ReturnTuple(args, names)