diff --git a/.DS_Store b/.DS_Store index 7540a21..fe642e2 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index efb7fcd..049dc59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ Exp20201205_2myo_hard** Exp20201205_2myo_soft** Documents -python_speech_features \ No newline at end of file +python_speech_features** \ No newline at end of file diff --git a/Handle_emg_data.py b/Handle_emg_data.py index 2c034fe..4956cbb 100644 --- a/Handle_emg_data.py +++ b/Handle_emg_data.py @@ -1,7 +1,6 @@ import pandas as pd from pathlib import Path import numpy as np - from pandas.core.frame import DataFrame class Data_container: diff --git a/Present_data.py b/Present_data.py index 09b0bcb..88a7636 100644 --- a/Present_data.py +++ b/Present_data.py @@ -1,5 +1,7 @@ from Handle_emg_data import * from Signal_prep import * +import matplotlib.pyplot as plt +from matplotlib import cm # PLOT FUNCTIONS: @@ -9,7 +11,7 @@ def plot_df(df:DataFrame): plt.show() # Plots ndarrays after transformations -def plot_arrays(N, N_name, y, y_name): +def plot_array(N, y): plt.plot(N, np.abs(y)) plt.show() @@ -25,6 +27,12 @@ def plot_compare_two_df(df_old, old_name, df_new, new_name): axis[1].set_title(new_name) plt.show() +def plot_mfcc(mfcc_data): + fig, ax = plt.subplots() + mfcc_data= np.swapaxes(mfcc_data, 0 ,1) + cax = ax.imshow(mfcc_data, interpolation='nearest', cmap=cm.coolwarm, origin='lower') + ax.set_title('MFCC') + plt.show() # DATA FUNCTIONS: @@ -59,6 +67,17 @@ def denoice_dataset(handler:Handler.CSV_handler, subject_nr, which_arm, round, e return df_new +# CASE FUNTIONS + +def compare_with_wavelet(data_frame): + N_trans, cA, cD = wavelet_db4(data_frame) + data_frame_freq = make_df_from_xandy(N_trans, cA, 1) + + cA_filt, cD_filt = soft_threshold_filter(cA, cD) + data_frame_freq_filt = make_df_from_xandy(N_trans, cD_filt, 1) + + plot_compare_two_df(data_frame_freq, 'Original data', data_frame_freq_filt, 'Analyzed data') + # MAIN: @@ -68,13 +87,9 @@ def main(): load_data(csv_handler, 'hard') data_frame = get_data(csv_handler, 1, 'left', 1, 1) - N_trans, cA, cD = wavelet_db4(data_frame) - data_frame_freq = make_df_from_xandy(N_trans, cA, 1) - - cA_filt, cD_filt = soft_threshold_filter(cA, cD) - data_frame_freq_filt = make_df_from_xandy(N_trans, cD_filt, 1) - - plot_compare_two_df(data_frame_freq, 'Original data', data_frame_freq_filt, 'Analyzed data') + N, y_mfcc = mfcc(data_frame) + plt.plot(y_mfcc) + plt.show() return None diff --git a/Signal_prep.py b/Signal_prep.py index 032eda7..a8a0b19 100644 --- a/Signal_prep.py +++ b/Signal_prep.py @@ -1,12 +1,11 @@ import numpy as np -import matplotlib.pyplot as plt -import pandas from pandas.core.frame import DataFrame from scipy.fft import fft, fftfreq import pywt -import pyhton_speech_features as psf -#from scipy.signal import wavelets -#import pyyawt +#from pyhton_speech_features.base import mfcc +import sys +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 @@ -78,9 +77,9 @@ def cepstrum(df:DataFrame): return None -''' def mfcc(df:DataFrame): N = get_xory_from_df('x', df) y = get_xory_from_df('y', df) - spf.mfcc(y, ) -''' + return N, base.mfcc(y, SAMPLE_RATE) + + diff --git a/__pycache__/Handle_emg_data.cpython-38.pyc b/__pycache__/Handle_emg_data.cpython-38.pyc index f736d9e..f9eade7 100644 Binary files a/__pycache__/Handle_emg_data.cpython-38.pyc and b/__pycache__/Handle_emg_data.cpython-38.pyc differ diff --git a/__pycache__/Signal_prep.cpython-38.pyc b/__pycache__/Signal_prep.cpython-38.pyc index 519d559..74d4c0f 100644 Binary files a/__pycache__/Signal_prep.cpython-38.pyc and b/__pycache__/Signal_prep.cpython-38.pyc differ