From cf53a936517f132344aec99d2be5d2113d154baa Mon Sep 17 00:00:00 2001 From: Skudalen Date: Wed, 30 Jun 2021 14:53:44 +0200 Subject: [PATCH] feat: add new class DL_data_handler and make sample func --- .DS_Store | Bin 6148 -> 6148 bytes Handle_emg_data.py | 26 ++++++++++++++++++++++++++ Present_data.py | 17 ++++++++++------- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.DS_Store b/.DS_Store index c7dd03a138b649b3263142d728f48a90f078da2e..2e1eb52079109730cb17eceb5b28e04b85333c10 100644 GIT binary patch delta 24 gcmZoMXffE3$vXKptH$JstWlFQSv58bvwai<0CG17tN;K2 delta 24 gcmZoMXffE3$vXKptH$JstWlFQSv58bvwai<0CG17tN;K2 diff --git a/Handle_emg_data.py b/Handle_emg_data.py index f385c6c..6226291 100644 --- a/Handle_emg_data.py +++ b/Handle_emg_data.py @@ -458,6 +458,32 @@ class CSV_handler: else ''' +class DL_data_handler: + + def __init__(self) -> None: + pass + + def make_subj_sample(tot_emgs_list): + starting_point:DataFrame = tot_emgs_list[0].rename(columns={'emg1':'emg'}) + print(starting_point) + + result:DataFrame = None + + left_nr_remaining = len(tot_emgs_list) - 1 + for i in range(left_nr_remaining): + i += 1 + emg_str = get_emg_str(i) + tot_emgs_list[i].rename(columns={emg_str: 'emg'}, inplace=True) + result = starting_point.append(tot_emgs_list[i]) + return result + + def get_emg_list(csv_handler:CSV_handler, subject_nr, session_nr, split) -> list: + + + return None + + + # HELP FUNCTIONS: ------------------------------------------------------------------------: # Help: gets the str from emg nr diff --git a/Present_data.py b/Present_data.py index c3e5f69..63bc6d5 100644 --- a/Present_data.py +++ b/Present_data.py @@ -8,8 +8,10 @@ from matplotlib import cm import matplotlib.ticker as ticker # Global variables for MFCC -mfcc_stepsize = 0.5 -mfcc_windowsize = 2 +mfcc_stepsize = 0.5 # Seconds +mfcc_windowsize = 2 # Seconds +nr_coefficients = 13 # Number of coefficients +nr_mel_filters = 40 # Number of mel-filter-bins # PLOT FUNCTIONS --------------------------------------------------------------: @@ -139,10 +141,10 @@ def denoice_dataset(handler:Handler.CSV_handler, subject_nr, which_arm, round, e # Slightly modified mfcc with inputs like below. # Returns N (x_values from original df) and mfcc_y_values -def mfcc_custom(df:DataFrame, samplesize, windowsize, stepsize): +def mfcc_custom(df:DataFrame, samplesize, windowsize, stepsize, nr_coefficients, nr_mel_filters): N = get_xory_from_df('x', df) y = get_xory_from_df('y', df) - return N, base.mfcc(y, samplesize, windowsize, stepsize) + return N, base.mfcc(y, samplesize, windowsize, stepsize, nr_coefficients, nr_mel_filters) # CASE FUNTIONS ----------------------------------------------------------------: @@ -232,9 +234,10 @@ def main(): csv_handler = CSV_handler() load_data(csv_handler, 'soft') - #mfcc_3_plots_1_1_2(csv_handler) - #mfcc_3_plots_3_3_4(csv_handler) - mfcc_all_emg_plots(csv_handler) + df, samplerate = get_data(csv_handler, 1, 'left', 1, 1) + mfcc_data = mfcc_custom(df, samplerate, mfcc_windowsize, mfcc_stepsize) + + print(np.array(mfcc_data).shape) main() \ No newline at end of file