From c667bc7c7f96f61d89a8f422f4419cff9689d1f9 Mon Sep 17 00:00:00 2001 From: Skudalen Date: Tue, 29 Jun 2021 09:31:10 +0200 Subject: [PATCH] feat: add one more func for plotting preset mfcc data --- Present_data.py | 41 +++++++++++++++------ __pycache__/Handle_emg_data.cpython-38.pyc | Bin 20074 -> 20074 bytes __pycache__/Signal_prep.cpython-38.pyc | Bin 2400 -> 2194 bytes 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Present_data.py b/Present_data.py index dd578c2..06b92f6 100644 --- a/Present_data.py +++ b/Present_data.py @@ -64,7 +64,7 @@ def plot_3_mfcc(mfcc_data1, data_label1:str, mfcc_data2, data_label2:str, mfcc_d ax.imshow(mfcc_data, interpolation='nearest', cmap=cm.coolwarm, origin='lower') ax.set_title('MFCC: ' + str(label)) - ax.set_ylabel('Cepstral Coefficients') + ax.set_ylabel('Coefficients') ax.set_xlabel('Time(s)') plt.show() @@ -130,27 +130,43 @@ 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. +# Loads three preset emg_1 datasets(subj1:session1, subj1:session2, subj2:session1), calculates mfcc for each and plots them. # Input: CSV_handler # Output: None --> Plot -def compare_mfcc_3_plots(csv_handler:CSV_handler): +def mfcc_3_plots_1_1_2(csv_handler:CSV_handler): df1, samplerate1 = get_data(csv_handler, 1, 'left', 1, 1) df2, samplerate2 = get_data(csv_handler, 1, 'left', 2, 1) df3, samplerate3 = get_data(csv_handler, 2, 'left', 1, 1) - print(df1.head, samplerate1) - print(df2.head, samplerate2) - print(df3.head, samplerate3) - + #print(df1.head, samplerate1) + #print(df2.head, samplerate2) + #print(df3.head, samplerate3) N1, mfcc_feat1 = mfcc_custom(df1, samplerate1, mfcc_windowsize, mfcc_stepsize) N2, mfcc_feat2 = mfcc_custom(df2, samplerate2, mfcc_windowsize, mfcc_stepsize) N3, mfcc_feat3 = mfcc_custom(df3, samplerate3, mfcc_windowsize, mfcc_stepsize) - - label_1 = 'Subject 1, session 1' - label_2 = 'Subject 1, session 2' - label_3 = 'Subject 2, session 1' + label_1 = 'Subject 1, session 1, left arm, emg nr. 1' + label_2 = 'Subject 1, session 2, left arm, emg nr. 1' + label_3 = 'Subject 2, session 1, left arm, emg nr. 1' plot_3_mfcc(mfcc_feat1, label_1, mfcc_feat2, label_2, mfcc_feat3, label_3) +# Loads three preset emg_1 datasets(subj3:session1, subj3:session2, subj4:session1), calculates mfcc for each and plots them. +# Input: CSV_handler +# Output: None --> Plot +def mfcc_3_plots_3_3_4(csv_handler:CSV_handler): + df1, samplerate1 = get_data(csv_handler, 3, 'left', 1, 1) + df2, samplerate2 = get_data(csv_handler, 3, 'left', 2, 1) + df3, samplerate3 = get_data(csv_handler, 4, 'left', 1, 1) + #print(df1.head, samplerate1) + #print(df2.head, samplerate2) + #print(df3.head, samplerate3) + N1, mfcc_feat1 = mfcc_custom(df1, samplerate1, mfcc_windowsize, mfcc_stepsize) + N2, mfcc_feat2 = mfcc_custom(df2, samplerate2, mfcc_windowsize, mfcc_stepsize) + N3, mfcc_feat3 = mfcc_custom(df3, samplerate3, mfcc_windowsize, mfcc_stepsize) + label_1 = 'Subject 3, session 1, left arm, emg nr. 1' + label_2 = 'Subject 3, session 2, left arm, emg nr. 1' + label_3 = 'Subject 4, session 1, left arm, emg nr. 1' + + plot_3_mfcc(mfcc_feat1, label_1, mfcc_feat2, label_2, mfcc_feat3, label_3) # MAIN: ------------------------------------------------------------------------: @@ -158,7 +174,8 @@ def main(): csv_handler = CSV_handler() load_data(csv_handler, 'soft') - compare_mfcc_3_plots(csv_handler) + mfcc_3_plots_1_1_2(csv_handler) + mfcc_3_plots_3_3_4(csv_handler) main() \ No newline at end of file diff --git a/__pycache__/Handle_emg_data.cpython-38.pyc b/__pycache__/Handle_emg_data.cpython-38.pyc index d4d90d8ec876bd2c1906269cee46ee5314318e78..4d1b04f489fd063368b0b8b202a8deb210954f7e 100644 GIT binary patch delta 56 zcmaDghw;@MM&3|fUM>b8h!wq+5Vw)H%bW4UumAu6 delta 56 zcmaDghw;@MM&3|fUM>b8cz@<*0^>&BE^o$TlV^DEWIQ!F$Y&UMkpKVy diff --git a/__pycache__/Signal_prep.cpython-38.pyc b/__pycache__/Signal_prep.cpython-38.pyc index cf8213ee907e84520666eea76f63f67818896212..dc2cb9f3bf9f86ec25d4f028dbb4ed024d852592 100644 GIT binary patch delta 239 zcmaDLG)a&zl$V!_0SLB<-b!fan8+u?xNM@fxm*fE3S$mu6jv%o7WV=kAdh7s6C(qV zX3gOZVVKwuz?Q-o%%CZ{@ks?EBhTbmrs<3#lfN>(VwBwcfLV)?QE4(a>qSQG&39R) z85s>H|6~hi)SMj1ZYyR7w5ym6WFsRN5EdB$S(>7gV>w(z`8^WzQgTw`Q*+bfQxZ!O zi^PC(lNWHFTel* delta 400 zcmbOv_&|s+l$V!_0SJ=L-b`@dn#d=^xMiZYxm+qo7Uu%46owR*g-nbLK$UzUrEW}DBmN;5LrOn%K4&bV^2GrMiQ2hiqXHjw>{T#Q`IMaDo@G7E?g1t2+g zAa(}gVhtcs0(3$RLo-t?3y{SGX0g_=lrSz}s$s2RtYNBQUdWQh6wFX$1XQfaT*MEg zZm}dK7N_1~$xTa6)?_OJnR$z=I5D?CCMUHxvnur#S9xY$N`5(*%~4#ES^#2Aj%AmW zE;0ow_6K5wD;dFJnqrfuvAazEz-}XUi{B$LFC`~6J~cNzJ|(dvu}BQ4VX_W~JR8VA oMW&N|IMkHnfJ_cX9!3F14kivpJ`l;u#{tBge1aTo96WsN0A|iuQ2+n{