fix: add a csv_handler object to DL_data_handler

This commit is contained in:
Skudalen 2021-06-30 15:42:18 +02:00
parent 87e179e6a9
commit 40773560ce
2 changed files with 11 additions and 12 deletions

View File

@ -461,7 +461,8 @@ class CSV_handler:
class DL_data_handler: class DL_data_handler:
def __init__(self) -> None: def __init__(self, csv_handler:CSV_handler) -> None:
self.csv_handler = csv_handler
self.samples_per_subject = {1: [], # Should med 4 sessions * split nr of samples per person self.samples_per_subject = {1: [], # Should med 4 sessions * split nr of samples per person
2: [], 2: [],
3: [], 3: [],
@ -469,13 +470,13 @@ class DL_data_handler:
5: [] 5: []
} }
def get_emg_list(csv_handler:CSV_handler, subject_nr, session_nr) -> list: def get_emg_list(self, subject_nr, session_nr) -> list:
list_of_emgs = [] list_of_emgs = []
for emg_nr in range(8): for emg_nr in range(8):
df, _ = get_data(csv_handler, subject_nr, 'left', session_nr) df, _ = get_data(self.csv_handler, subject_nr, 'left', session_nr)
list_of_emgs.append(df) list_of_emgs.append(df)
for emg_nr in range(8): for emg_nr in range(8):
df, _ = get_data(csv_handler, subject_nr, 'right', session_nr) df, _ = get_data(self.csv_handler, subject_nr, 'right', session_nr)
list_of_emgs.append(df) list_of_emgs.append(df)
return list_of_emgs return list_of_emgs
@ -490,16 +491,15 @@ class DL_data_handler:
i += 1 i += 1
emg_str = get_emg_str(i) emg_str = get_emg_str(i)
list_of_emgs[i].rename(columns={emg_str: 'emg'}, inplace=True) list_of_emgs[i].rename(columns={emg_str: 'emg'}, inplace=True)
result = starting_point.append(list_of_emgs[i]) starting_point.append(list_of_emgs[i])
return tot_session_df return tot_session_df
def store_samples(self, split_nr) -> None:
def store_samples(self, csv_handler, split_nr) -> None:
for subject_nr in range(5): for subject_nr in range(5):
subj_samples = [] subj_samples = []
#session_df_list = [] #session_df_list = []
for session_nr in range(4): for session_nr in range(4):
list_of_emg = self.get_emg_list(csv_handler, subject_nr, session_nr) list_of_emg = self.get_emg_list(self.csv_handler, subject_nr, session_nr)
tot_session_df = self.make_subj_sample(list_of_emg) tot_session_df = self.make_subj_sample(list_of_emg)
#session_df_list.append(tot_session_df) #session_df_list.append(tot_session_df)
samples = np.array_split(tot_session_df, split_nr) samples = np.array_split(tot_session_df, split_nr)

View File

@ -234,10 +234,9 @@ def main():
csv_handler = CSV_handler() csv_handler = CSV_handler()
load_data(csv_handler, 'soft') load_data(csv_handler, 'soft')
df, samplerate = get_data(csv_handler, 1, 'left', 1, 1) dl_data_handler = DL_data_handler(csv_handler)
mfcc_data = mfcc_custom(df, samplerate, mfcc_windowsize, mfcc_stepsize) dl_data_handler.store_samples(10)
print(dl_data_handler.samples_per_subject)
print(np.array(mfcc_data).shape)
main() main()