style: move things :)
This commit is contained in:
parent
e0a1dfee71
commit
055ad434a3
@ -450,6 +450,8 @@ class CSV_handler:
|
||||
return df
|
||||
|
||||
|
||||
# HELP FUNCTIONS: ------------------------------------------------------------------------:
|
||||
|
||||
# Help: gets the str from emg nr
|
||||
def get_emg_str(emg_nr):
|
||||
return 'emg' + str(emg_nr)
|
||||
|
@ -69,6 +69,7 @@ def plot_3_mfcc(mfcc_data1, data_label1:str, mfcc_data2, data_label2:str, mfcc_d
|
||||
|
||||
plt.show()
|
||||
|
||||
|
||||
# DATA FUNCTIONS: --------------------------------------------------------------:
|
||||
|
||||
# The CSV_handler takes in data_type, but only for visuals.
|
||||
@ -115,6 +116,7 @@ def mfcc_custom(df:DataFrame, samplesize, windowsize, stepsize):
|
||||
y = get_xory_from_df('y', df)
|
||||
return N, base.mfcc(y, samplesize, windowsize, stepsize)
|
||||
|
||||
|
||||
# CASE FUNTIONS ----------------------------------------------------------------:
|
||||
|
||||
# Takes in a df and compares the FFT and the wavelet denoising of the FFT
|
||||
@ -128,6 +130,9 @@ def compare_with_wavelet_filter(data_frame):
|
||||
|
||||
plot_compare_two_df(data_frame_freq, 'Original data', data_frame_freq_filt, 'Analyzed data')
|
||||
|
||||
# Loads three preset emg datasets, calculates mfcc for each and plots them.
|
||||
# Input: CSV_handler
|
||||
# Output: None --> Plot
|
||||
def compare_mfcc_3_plots(csv_handler:CSV_handler):
|
||||
df1, samplerate1 = get_data(csv_handler, 1, 'left', 1, 1)
|
||||
df2, samplerate2 = get_data(csv_handler, 1, 'left', 2, 1)
|
||||
@ -146,6 +151,7 @@ def compare_mfcc_3_plots(csv_handler:CSV_handler):
|
||||
|
||||
plot_3_mfcc(mfcc_feat1, label_1, mfcc_feat2, label_2, mfcc_feat3, label_3)
|
||||
|
||||
|
||||
# MAIN: ------------------------------------------------------------------------:
|
||||
|
||||
def main():
|
||||
|
@ -2,14 +2,11 @@ import numpy as np
|
||||
from pandas.core.frame import DataFrame
|
||||
from scipy.fft import fft, fftfreq
|
||||
import pywt
|
||||
#from pyhton_speech_features.base import mfcc
|
||||
import sys
|
||||
import Handle_emg_data as Handler
|
||||
sys.path.insert(0, '/Users/Markus/Prosjekter git/Slovakia 2021/python_speech_features/python_speech_features')
|
||||
from python_speech_features.python_speech_features import *
|
||||
|
||||
import Handle_emg_data as Handler
|
||||
|
||||
|
||||
|
||||
# Takes in a df and outputs np arrays for x and y values
|
||||
def get_xory_from_df(x_or_y, df:DataFrame):
|
||||
@ -42,14 +39,6 @@ def wavelet_db4(df:DataFrame):
|
||||
N_trans = np.array(range(int(np.floor((y_values.size + wavelet.dec_len - 1) / 2))))
|
||||
return N_trans, cA, cD
|
||||
|
||||
# Filters signal accordning to Stein's Unbiased Risk Estimate(SURE)
|
||||
'''
|
||||
def sure_threshold_filter(cA, cD):
|
||||
cA_filt = pyyawt.theselect(cA, 'rigrsure')
|
||||
cD_filt = cD
|
||||
return cA_filt, cD_filt
|
||||
'''
|
||||
|
||||
# soft filtering of wavelet trans with the a 1/2 std filter
|
||||
def soft_threshold_filter(cA, cD):
|
||||
cA_filt = pywt.threshold(cA, np.std(cA)/2)
|
||||
@ -69,16 +58,9 @@ def inverse_wavelet(df, cA_filt, cD_filt):
|
||||
old_len = len(get_xory_from_df('y', df))
|
||||
return y_new_values
|
||||
|
||||
# NOT FINISHED
|
||||
def cepstrum(df:DataFrame):
|
||||
N = get_xory_from_df('x', df)
|
||||
y = get_xory_from_df('y', df)
|
||||
|
||||
|
||||
return None
|
||||
|
||||
def mfcc(df:DataFrame, samplesize, windowsize, stepsize):
|
||||
N = get_xory_from_df('x', df)
|
||||
y = get_xory_from_df('y', df)
|
||||
return N, base.mfcc(y, samplesize, windowsize, stepsize)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user