feat: implement func that gets df from
data_dict in handler
This commit is contained in:
parent
8f34ff6abf
commit
7b7181218e
@ -21,10 +21,10 @@ class Data_container:
|
||||
|
||||
class CSV_handler:
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, data_type):
|
||||
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 = ''
|
||||
self.data_type = data_type
|
||||
|
||||
# Makes dataframe from the csv files in the working directory
|
||||
def make_df(self, filename):
|
||||
@ -443,6 +443,13 @@ class CSV_handler:
|
||||
self.data_type = 'soft'
|
||||
return self.data_container_dict
|
||||
|
||||
def get_df_from_data_dict(self, subject_nr, which_arm, round, emg_nr):
|
||||
data_type = self.data_type
|
||||
container = self.data_container_dict.get(subject_nr)
|
||||
df = container.dict_list[round - 1].get(which_arm)[emg_nr]
|
||||
return df
|
||||
|
||||
|
||||
# Help: gets the str from emg nr
|
||||
def get_emg_str(emg_nr):
|
||||
return 'emg' + str(emg_nr)
|
||||
|
@ -70,11 +70,9 @@ def inverse_wavelet(df, cA_filt, cD_filt):
|
||||
old_len = len(get_xory_from_df('y', df))
|
||||
return y_new_values
|
||||
|
||||
|
||||
# Takes in handler and detailes to denoise. Returns arrays and df
|
||||
def denoice_dataset(handler:Handler.CSV_handler, subject_nr, which_arm, emg_nr, round):
|
||||
data_type = handler.data_type
|
||||
container = handler.data_container_dict.get(subject_nr)
|
||||
df = container.dict_list[round - 1].get(which_arm)[emg_nr]
|
||||
|
||||
print(df.head)
|
||||
|
||||
N = get_xory_from_df('x', df)
|
||||
@ -82,7 +80,8 @@ def denoice_dataset(handler:Handler.CSV_handler, subject_nr, which_arm, emg_nr,
|
||||
cA_filt, cD_filt = soft_threshold_filter(cA, cD)
|
||||
y_values = inverse_wavelet(df, cA_filt, cD_filt)
|
||||
|
||||
return pandas.DataFrame([N_trans, y_values])
|
||||
df_new = pandas.DataFrame([N_trans, y_values])
|
||||
return N, y_values, df_new
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user