From aa27fb0aa46a6d36980f9521ecf771dfb8292f24 Mon Sep 17 00:00:00 2001 From: Skudalen Date: Wed, 30 Jun 2021 16:02:34 +0200 Subject: [PATCH] chore: moved load and get func to emg_handler file --- Handle_emg_data.py | 32 ++++++++++++++++++--- Present_data.py | 21 -------------- __pycache__/Handle_emg_data.cpython-38.pyc | Bin 20074 -> 21786 bytes __pycache__/Present_data.cpython-38.pyc | Bin 0 -> 7751 bytes 4 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 __pycache__/Present_data.cpython-38.pyc diff --git a/Handle_emg_data.py b/Handle_emg_data.py index c3d50b3..e47615e 100644 --- a/Handle_emg_data.py +++ b/Handle_emg_data.py @@ -2,7 +2,7 @@ import pandas as pd from pathlib import Path import numpy as np from pandas.core.frame import DataFrame -from Present_data import get_data +#from Present_data import get_data class Data_container: @@ -450,6 +450,28 @@ class CSV_handler: df = container.dict_list[round - 1].get(which_arm)[emg_nr - 1] return df + # Loads in data to a CSV_handler. Choose data_type: hard, hardPP, soft og softPP as str. + # Returns None. + def load_data(self, data_type): + if data_type == 'hard': + self.load_hard_original_emg_data() + elif data_type == 'hardPP': + self.load_hard_PP_emg_data() + elif data_type == 'soft': + self.load_soft_original_emg_data() + elif data_type == 'softPP': + self.load_soft_PP_emg_data() + else: + raise Exception('Wrong input') + + # Retrieved data. Send in loaded csv_handler and data detailes you want. + # Returns DataFrame and samplerate + def get_data(self, subject_nr, which_arm, session, emg_nr): + data_frame = self.get_df_from_data_dict(subject_nr, which_arm, session, emg_nr) + samplerate = get_samplerate(data_frame) + return data_frame, samplerate + + ''' def get_keyboard_data(self, filename:str, pres_or_release:str='pressed'): filepath = self.working_dir + str(filename) @@ -469,14 +491,16 @@ class DL_data_handler: 4: [], 5: [] } - + def get_samples_dict(self): + return self.samples_per_subject + def get_emg_list(self, subject_nr, session_nr) -> list: list_of_emgs = [] for emg_nr in range(8): - df, _ = get_data(self.csv_handler, subject_nr, 'left', session_nr) + df, _ = self.csv_handler.get_data(self.csv_handler, subject_nr, 'left', session_nr) list_of_emgs.append(df) for emg_nr in range(8): - df, _ = get_data(self.csv_handler, subject_nr, 'right', session_nr) + df, _ = self.csv_handler.get_data(self.csv_handler, subject_nr, 'right', session_nr) list_of_emgs.append(df) return list_of_emgs diff --git a/Present_data.py b/Present_data.py index ad944c8..53c7316 100644 --- a/Present_data.py +++ b/Present_data.py @@ -104,27 +104,6 @@ def plot_all_emg_mfcc(data_list:list, label_list:list): # The CSV_handler takes in data_type, but only for visuals. # E.g. handler = CSV_handler('soft') - -# Loads in data to a CSV_handler. Choose data_type: hard, hardPP, soft og softPP as str. -# Returns None. -def load_data(csv_handler:CSV_handler, 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 and samplerate -def get_data(csv_handler:CSV_handler, subject_nr, which_arm, session, emg_nr): - data_frame = csv_handler.get_df_from_data_dict(subject_nr, which_arm, session, emg_nr) - samplerate = get_samplerate(data_frame) - return data_frame, samplerate # Takes in handler and detailes to denoise. # Returns arrays and df diff --git a/__pycache__/Handle_emg_data.cpython-38.pyc b/__pycache__/Handle_emg_data.cpython-38.pyc index d57d8f5c0a5cb8fab78a998deaaf1926033da2ee..79478c2c4bb3f44c637286e684786f51c02a580c 100644 GIT binary patch delta 3650 zcmb_fOK%*<5uWaO^**_zWQinJj$W~~rpzd|V=6LZ7>Xj%62&lysRR?*_VN9hnZDGd(Gu-~Q()R9O`6iW zr%7vzJ4Ni-QeaPDuY|pVEMl*Sy|OIH@;%L|__nNUGg*~m_Y9{hYjPY%$96|2!mppjs0I7^WDJH0EqOkE7aTJ1sna=5-v&r3@v+lCvJWTTkgvrnxws97RWCQ%_#MUfTX4yC{GJ%A20>=D=CB~q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K%)S5T2f$*RFSGZ4+nxj7iADlT88+5Fy)`V3Wjlh}qb{VH6k!_t;r^A6CsI zvIEG6_zzfZIG_lL0|(~-iuN9b3x@~^gpiQt#tr4doeNa;81H)JTRhs&UDef9UsqMv z*ALmV2h9E;m&+*lH}PBi$yfKc?Lii87mM@P6s~c7OX2!`)wNJExQUX9Qkq*ly`{LB zz~q?+jCb(tmgaWw9Jf)M-P7iICu(z?Eh zr}#pBms#SeT0YxNCY=YNi$o2B|AZ#3^j zAFdn?2FR#@5UXq4wIJ}hw-nyRoxB*<2YU~mkIkyT8hCtpNG$57*|4~$2b(AUci|XG z%wbZzgy7myJ@U98`Q9@4)xb4_>WUXe;C3vRD^UOeM_+9m>J~ z2kTb=>fo4dtl=phS4(nzvN1MSi&!z*)2mPa-I+Gi71;EDf`xQlh7zxhf@&O z#$Hr)CVnhFXz1fRIsf^C(OnJ?M)w^MPi6;HUq%%Ac(HYpayw&MBVxuoZy_&pbUS5hGv;7xo;CmF`&pG86&>I{f z=pm4EYkxSvQPRl=Npq{E*~UqHli)3aw+W^RnzfcIIly{xqeoo6KE!&(A2&y*=(XXj zqX~xp{P*V0uf&?BrNZEyCtoyv6?POe0CVD>g~?l2P3xk6P5S-Hm;)9?UK6i!V(U{3v$HEOUtPO wRH`HqL>A@=$X5%6{kq21M77TERDww)poDbP!ldF)we$9-Lf@pN*@k8Q2aG0)xBvhE diff --git a/__pycache__/Present_data.cpython-38.pyc b/__pycache__/Present_data.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..66350be035a040d2f2940a7f35be3df7932bffa6 GIT binary patch literal 7751 zcmbVRS(6-BR?fY$_Uh_x?UKuuEURpdw#9kazHw)>&o_}>`D~MtA5l7y>>6~ z8^Vh`i1e42K#gX5l^Sc>zrB87;OC%70~G)%%=QrW20_QMFTrT1;sEoJqBZltWB)$x_t3s4N#x|?-FW-*wuNgnQN zathohx2}FA^ksPU9Zx>m2(R9k-EiH16#25Y+KR3|2)d8GM=h^5|L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