diff --git a/Handle_emg_data.py b/Handle_emg_data.py index 64dcb80..d41de1e 100644 --- a/Handle_emg_data.py +++ b/Handle_emg_data.py @@ -38,13 +38,13 @@ class CSV_handler: if which_arm is 'left': data_container.data_dict['left'][emg_nr+1] = df - def get_emg_str(emg_nr): - return 'emg' + str(emg_nr) +def get_emg_str(emg_nr): + return 'emg' + str(emg_nr) - def get_min_max_timestamp(df:DataFrame): - min = df['timestamp'].argmin - max = df['timestamp'].argmax - return min, max +def get_min_max_timestamp(df:DataFrame): + min = df['timestamp'].argmin + max = df['timestamp'].argmax + return min, max diff --git a/Signal_prep.py b/Signal_prep.py index 8606d50..3fa87a1 100644 --- a/Signal_prep.py +++ b/Signal_prep.py @@ -1,8 +1,11 @@ import numpy as np import matplotlib.pyplot as plt +from pandas.core.frame import DataFrame +from scipy.fft import fft -from Handle_emg_data import CSV_handler, Data_container +import Handle_emg_data as Handler +SAMPLE_RATE = 200 def load_user_emg_data(): @@ -93,4 +96,31 @@ def load_user_emg_data(): return csv_handler.data_container_dict +def prep_df_for_trans(df:DataFrame): + sample_rate = SAMPLE_RATE + min, duration = Handler.get_min_max_timestamp(df) + x = np.linspace(0, duration, sample_rate * duration, endpoint=False) + y = np.array(df.iloc(1)) + return x, y +def normalize_wave(y_values): + return None + + +def transformed_df(df:DataFrame): + x, y = prep_df_for_trans(df) + y_values = fft(y) + return new_df + +def plot_df(df:DataFrame): + lines = df.plot.line(x='timestamp') + plt.show() + + +handler = CSV_handler +file = "/Exp20201205_2myo_hardTypePP/HaluskaMarek_20201207_1810/myoLeftEmg.csv" +df = handler.get_time_emg_table(file, 1) +#plot_df(df) +trans_df = DataFrame(transformed_df(df)) +print(trans_df.info) +plot_df(trans_df) diff --git a/Test_functions.py b/Test_functions.py index 63f2cf8..266a637 100644 --- a/Test_functions.py +++ b/Test_functions.py @@ -11,6 +11,8 @@ def test_df_extraction(emg_nr): return subject1_left_emg1, emg_nr -test_dict = Signal_prep.load_user_emg_data() -subject2_container = test_dict[2] -print(subject2_container.data_dict['left'][1]) \ No newline at end of file +def test_load_func(): + test_dict = Signal_prep.load_user_emg_data() + subject2_container = test_dict[2] + print(subject2_container.data_dict['left'][1]) +