style: move things :)
This commit is contained in:
parent
e0a1dfee71
commit
055ad434a3
@ -12,7 +12,7 @@ class Data_container:
|
|||||||
self.data_dict_round2 = {'left': [None]*8, 'right': [None]*8}
|
self.data_dict_round2 = {'left': [None]*8, 'right': [None]*8}
|
||||||
self.data_dict_round3 = {'left': [None]*8, 'right': [None]*8}
|
self.data_dict_round3 = {'left': [None]*8, 'right': [None]*8}
|
||||||
self.data_dict_round4 = {'left': [None]*8, 'right': [None]*8}
|
self.data_dict_round4 = {'left': [None]*8, 'right': [None]*8}
|
||||||
self.dict_list = [self.data_dict_round1,
|
self.dict_list = [self.data_dict_round1,
|
||||||
self.data_dict_round2,
|
self.data_dict_round2,
|
||||||
self.data_dict_round3,
|
self.data_dict_round3,
|
||||||
self.data_dict_round4
|
self.data_dict_round4
|
||||||
@ -450,6 +450,8 @@ class CSV_handler:
|
|||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
|
# HELP FUNCTIONS: ------------------------------------------------------------------------:
|
||||||
|
|
||||||
# Help: gets the str from emg nr
|
# Help: gets the str from emg nr
|
||||||
def get_emg_str(emg_nr):
|
def get_emg_str(emg_nr):
|
||||||
return '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()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
# DATA FUNCTIONS: --------------------------------------------------------------:
|
# DATA FUNCTIONS: --------------------------------------------------------------:
|
||||||
|
|
||||||
# The CSV_handler takes in data_type, but only for visuals.
|
# 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)
|
y = get_xory_from_df('y', df)
|
||||||
return N, base.mfcc(y, samplesize, windowsize, stepsize)
|
return N, base.mfcc(y, samplesize, windowsize, stepsize)
|
||||||
|
|
||||||
|
|
||||||
# CASE FUNTIONS ----------------------------------------------------------------:
|
# CASE FUNTIONS ----------------------------------------------------------------:
|
||||||
|
|
||||||
# Takes in a df and compares the FFT and the wavelet denoising of the FFT
|
# 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')
|
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):
|
def compare_mfcc_3_plots(csv_handler:CSV_handler):
|
||||||
df1, samplerate1 = get_data(csv_handler, 1, 'left', 1, 1)
|
df1, samplerate1 = get_data(csv_handler, 1, 'left', 1, 1)
|
||||||
df2, samplerate2 = get_data(csv_handler, 1, 'left', 2, 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)
|
plot_3_mfcc(mfcc_feat1, label_1, mfcc_feat2, label_2, mfcc_feat3, label_3)
|
||||||
|
|
||||||
|
|
||||||
# MAIN: ------------------------------------------------------------------------:
|
# MAIN: ------------------------------------------------------------------------:
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -2,14 +2,11 @@ import numpy as np
|
|||||||
from pandas.core.frame import DataFrame
|
from pandas.core.frame import DataFrame
|
||||||
from scipy.fft import fft, fftfreq
|
from scipy.fft import fft, fftfreq
|
||||||
import pywt
|
import pywt
|
||||||
#from pyhton_speech_features.base import mfcc
|
|
||||||
import sys
|
import sys
|
||||||
|
import Handle_emg_data as Handler
|
||||||
sys.path.insert(0, '/Users/Markus/Prosjekter git/Slovakia 2021/python_speech_features/python_speech_features')
|
sys.path.insert(0, '/Users/Markus/Prosjekter git/Slovakia 2021/python_speech_features/python_speech_features')
|
||||||
from python_speech_features.python_speech_features import *
|
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
|
# Takes in a df and outputs np arrays for x and y values
|
||||||
def get_xory_from_df(x_or_y, df:DataFrame):
|
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))))
|
N_trans = np.array(range(int(np.floor((y_values.size + wavelet.dec_len - 1) / 2))))
|
||||||
return N_trans, cA, cD
|
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
|
# soft filtering of wavelet trans with the a 1/2 std filter
|
||||||
def soft_threshold_filter(cA, cD):
|
def soft_threshold_filter(cA, cD):
|
||||||
cA_filt = pywt.threshold(cA, np.std(cA)/2)
|
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))
|
old_len = len(get_xory_from_df('y', df))
|
||||||
return y_new_values
|
return y_new_values
|
||||||
|
|
||||||
|
# NOT FINISHED
|
||||||
def cepstrum(df:DataFrame):
|
def cepstrum(df:DataFrame):
|
||||||
N = get_xory_from_df('x', df)
|
N = get_xory_from_df('x', df)
|
||||||
y = get_xory_from_df('y', df)
|
y = get_xory_from_df('y', df)
|
||||||
|
|
||||||
|
|
||||||
return None
|
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