From 2a48a0abfd872941521a9bc2b803a9bd24ef7fd7 Mon Sep 17 00:00:00 2001 From: Skudalen Date: Fri, 25 Jun 2021 10:43:59 +0200 Subject: [PATCH] chore: split up storing func to one storing func and one linking func --- Handle_emg_data.py | 59 +++++++++++---------- Test_functions.py | 10 ++-- __pycache__/Handle_emg_data.cpython-38.pyc | Bin 2135 -> 11430 bytes __pycache__/Signal_prep.cpython-38.pyc | Bin 7622 -> 2385 bytes 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/Handle_emg_data.py b/Handle_emg_data.py index ee45e72..ee03c45 100644 --- a/Handle_emg_data.py +++ b/Handle_emg_data.py @@ -33,34 +33,38 @@ class CSV_handler: filtered_df = tot_data_frame[["timestamp", emg_str]] return filtered_df - def store_df(self, filename:str, emg_nr:int, which_arm:str, data_container:Data_container, round:int): - df = self.get_min_max_timestamp(filename, emg_nr) + def store_df_in_container(self, filename:str, emg_nr:int, which_arm:str, data_container:Data_container, round:int): + df = self.get_time_emg_table(filename, emg_nr+1) + + # Places the data correctly: + if round == 1: + if which_arm == 'left': + data_container.data_dict_round1['left'][emg_nr] = df # Zero indexed emg_nr in the dict + else: + data_container.data_dict_round1['right'][emg_nr] = df + elif round == 2: + if which_arm == 'left': + data_container.data_dict_round2['left'][emg_nr] = df + else: + data_container.data_dict_round2['right'][emg_nr] = df + elif round == 3: + if which_arm == 'left': + data_container.data_dict_round3['left'][emg_nr] = df + else: + data_container.data_dict_round3['right'][emg_nr] = df + elif round == 4: + if which_arm == 'left': + data_container.data_dict_round4['left'][emg_nr] = df + else: + data_container.data_dict_round4['right'][emg_nr] = df + else: + raise IndexError('Not a valid index') + + def link_container_to_handler(self, data_container:Data_container): # Links the retrieved data with the subjects data_container subject_nr = data_container.subject_nr self.data_container_dict[subject_nr] = data_container - # Places the data correctly: - if round == 0: - if which_arm == 'left': - data_container.data_dict_round1['left'][emg_nr+1] = df - else: - data_container.data_dict_round1['right'][emg_nr+1] = df - elif round == 1: - if which_arm == 'left': - data_container.data_dict_round2['left'][emg_nr+1] = df - else: - data_container.data_dict_round2['right'][emg_nr+1] = df - elif round == 2: - if which_arm == 'left': - data_container.data_dict_round3['left'][emg_nr+1] = df - else: - data_container.data_dict_round3['right'][emg_nr+1] = df - elif round == 3: - if which_arm == 'left': - data_container.data_dict_round4['left'][emg_nr+1] = df - else: - data_container.data_dict_round4['right'][emg_nr+1] = df - else: - raise IndexError('Not a valid index') + print(data_container.subject_name) # Loads the data from the csv files into a storing system in an CSV_handler object def load_hard_PP_emg_data(self): @@ -131,6 +135,7 @@ class CSV_handler: subject1_data_container = Data_container(1, 'HaluskaMarek') + #print(subject1_data_container.data_dict_round1) subject2_data_container = Data_container(1, 'HaluskaMaros') subject3_data_container = Data_container(1, 'HaluskovaBeata') subject4_data_container = Data_container(1, 'KelisekDavid') @@ -142,11 +147,11 @@ class CSV_handler: # left variant proccessed here for round in range(4): for emg_nr in range(8): - self.store_df(left_list[subject_nr][round], emg_nr+1, 'left', subject_data_container_list[subject_nr]) + self.store_df(left_list[subject_nr][round], emg_nr, 'left', subject_data_container_list[subject_nr], round+1) # right variant proccessed here for round in range(4): for emg_nr in range(8): - self.store_df(right_list[subject_nr][round], emg_nr+1, 'right', subject_data_container_list[subject_nr]) + self.store_df(right_list[subject_nr][round], emg_nr, 'right', subject_data_container_list[subject_nr], round+1) return self.data_container_dict diff --git a/Test_functions.py b/Test_functions.py index f552a39..6321cdf 100644 --- a/Test_functions.py +++ b/Test_functions.py @@ -1,6 +1,6 @@ from Handle_emg_data import * import matplotlib.pyplot as plt -from Signal_prep import * +#from Signal_prep import * def test_df_extraction(emg_nr): handler = CSV_handler() @@ -14,8 +14,9 @@ def test_df_extraction(emg_nr): def test_load_func(): handler = CSV_handler() test_dict = handler.load_hard_PP_emg_data() - subject2_container = test_dict[2] - print(subject2_container.data_dict['left'][1]) + subject2_container = test_dict.get(2) + print(subject2_container) + print(subject2_container.data_dict_round1.get('left')[1]) def test_min_max_func(): handler = CSV_handler() @@ -30,7 +31,6 @@ def test_fft_prep(): file = "/Exp20201205_2myo_hardTypePP/HaluskaMarek_20201207_1810/myoLeftEmg.csv" df = handler.get_time_emg_table(file, 1) - def test_plot_wavelet_both_ways(): handler = CSV_handler() file = "/Exp20201205_2myo_hardTypePP/HaluskaMarek_20201207_1810/myoLeftEmg.csv" @@ -49,4 +49,4 @@ def test_plot_wavelet_both_ways(): #print(len(y_new_values)) plot_arrays(N, y_new_values) -test_plot_wavelet_both_ways() \ No newline at end of file +test_load_func() \ 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 b4802c0a73b876779ecaf511255722285f84178f..1f3307030094ea9d27bcf42805b98577019ccdd0 100644 GIT binary patch literal 11430 zcmeHN$#2`t73U_2l4Zq?wB68e{bQN z5$E}R-QQnO;IsIvKmPd4XNvM?97I1l3_gX+`4KckA!<{psqn2ewU%DfRi9?mGCDODI8N91p&R?q!J(kLzPMw8T+rBP+AFS?p^eowx16OJpwcWf-T*=4NCS+aoy|6> zBq-GcWiCOPFYBJ+*v*w)vVn7nOUM8=dr!++H_*I;m$m4 zcAnPP8}*6mY_&4;WxY+Bwq>_gEmUiIT%y z?!|HzZ*9Xfu`I7(S*;G)1Zc}ETGo@zdNY{O8*SIq9hcHUKo%NDngOI4(B$B9G-yms zjF+Js`=BpBh0A#WO*fv1N;C*oo#@1XZ^O>mS(1VH!hkkvIUK`f0@ZwzA$d{&YF-32 zggEIZCAh1P9D*k~;Pu^o_# zZVg8i44=a?O6q=)HPjRr9#bBJu1tNYjwxJowYNIcwpFe({h>n9l(IpO!Ix0l(>6%W zq;{QH%g$4nLA5+{rO~wUVfwudSoxktR`#gtfpmdl?&?DP*mxFr>xNv z2%W_^Y}449##=)Z&clEyZ(&`d(nJMQG+~OtbfPh1RXeKi49kd>=;;9G<=sZhcHDYv z1EfsA{lYX@k;2C)mQF%bE4dw4tO08U_b-SQ&;`P@)(7^&;;{)Bv)9POtF~*Q0I`D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