feat: make df from x and y arrays

This commit is contained in:
Skudalen 2021-06-25 14:27:51 +02:00
parent c650eb928c
commit 46558a075d
5 changed files with 23 additions and 2 deletions

View File

@ -461,4 +461,10 @@ def get_min_max_timestamp(df:DataFrame):
max = df['timestamp'].max()
return min, max
# Help: returns df_time_emg
def make_df_from_xandy(x, y, emg_nr):
print(type(x))
print(type(y))
df = DataFrame([x, y], columns=['timestamp', get_emg_str(emg_nr)])
return df

View File

@ -79,7 +79,7 @@ def denoice_dataset(handler:Handler.CSV_handler, subject_nr, which_arm, round, e
cA_filt, cD_filt = soft_threshold_filter(cA, cD)
y_values = inverse_wavelet(df, cA_filt, cD_filt)
df_new = pandas.DataFrame([N_trans, y_values])
df_new = Handler.make_df_from_xandy(N, y_values, emg_nr)
return N, y_values, df_new

View File

@ -1,3 +1,4 @@
from numpy import load
from Handle_emg_data import *
import matplotlib.pyplot as plt
from Signal_prep import *
@ -58,4 +59,18 @@ def test_soft_load_func():
print(subject2_container.subject_name)
print(subject2_container.data_dict_round2.get('right')[3]) # Round2, right, emg_4
test_soft_load_func()
def test_total_denoising():
handler = Handler.CSV_handler('hard')
handler.load_hard_original_emg_data()
# Original df:
df = handler.get_df_from_data_dict(3, 'left', 3, 3)
print(df.head)
plot_df(df)
# Denoised df:
df_denoised = denoice_dataset(handler, 3, 'left', 3, 3)
print(df.head)
plot_df(df_denoised)
test_total_denoising()