diff --git a/.DS_Store b/.DS_Store index fe642e2..75858c7 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Handle_emg_data.py b/Handle_emg_data.py index 4956cbb..6315168 100644 --- a/Handle_emg_data.py +++ b/Handle_emg_data.py @@ -20,10 +20,10 @@ class Data_container: class CSV_handler: - def __init__(self, data_type): + def __init__(self): self.working_dir = str(Path.cwd()) self.data_container_dict = {} # Dict with keys equal subject numbers and values equal the relvant datacontainer - self.data_type = data_type + self.data_type = None # Makes dataframe from the csv files in the working directory def make_df(self, filename): diff --git a/Present_data.py b/Present_data.py index 88a7636..feb9a85 100644 --- a/Present_data.py +++ b/Present_data.py @@ -1,3 +1,4 @@ +from logging import error from Handle_emg_data import * from Signal_prep import * import matplotlib.pyplot as plt @@ -41,13 +42,16 @@ def plot_mfcc(mfcc_data): # Loads in data. Choose data_type: hard, hardPP, soft og softPP as str. Returns None def load_data(csv_handler:CSV_handler, data_type): - switcher = { - 'hard': csv_handler.load_hard_original_emg_data(), - 'hardPP':csv_handler.load_hard_PP_emg_data(), - 'soft':csv_handler.load_soft_original_emg_data(), - 'softPP':csv_handler.load_soft_PP_emg_data(), - } - return switcher.get(data_type) + if data_type == 'hard': + csv_handler.load_hard_original_emg_data() + elif data_type == 'hardPP': + csv_handler.load_hard_PP_emg_data() + elif data_type == 'soft': + csv_handler.load_soft_original_emg_data() + elif data_type == 'softPP': + csv_handler.load_soft_PP_emg_data() + else: + raise Exception('Wrong input') # Retrieved data. Send in loaded csv_handler and data detailes you want. Returns DataFrame def get_data(csv_handler:CSV_handler, subject_nr, which_arm, session, emg_nr): @@ -83,13 +87,15 @@ def compare_with_wavelet(data_frame): def main(): - csv_handler = CSV_handler('hard') + csv_handler = CSV_handler() load_data(csv_handler, 'hard') + print(csv_handler.data_type) data_frame = get_data(csv_handler, 1, 'left', 1, 1) - N, y_mfcc = mfcc(data_frame) - plt.plot(y_mfcc) - plt.show() + print(data_frame.head) + + N, y_mfcc = mfcc(data_frame, 0.1) + plot_mfcc(y_mfcc) return None diff --git a/Signal_prep.py b/Signal_prep.py index a8a0b19..af33e09 100644 --- a/Signal_prep.py +++ b/Signal_prep.py @@ -77,9 +77,9 @@ def cepstrum(df:DataFrame): return None -def mfcc(df:DataFrame): +def mfcc(df:DataFrame, window_lenth): N = get_xory_from_df('x', df) y = get_xory_from_df('y', df) - return N, base.mfcc(y, SAMPLE_RATE) + return N, base.mfcc(y, SAMPLE_RATE, window_lenth) diff --git a/__pycache__/Handle_emg_data.cpython-38.pyc b/__pycache__/Handle_emg_data.cpython-38.pyc index f9eade7..d7cb9e2 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 74d4c0f..04530fd 100644 Binary files a/__pycache__/Signal_prep.cpython-38.pyc and b/__pycache__/Signal_prep.cpython-38.pyc differ