fix: fix the min_max func

This commit is contained in:
Skudalen 2021-06-24 10:06:01 +02:00
parent 6e9a5fb322
commit 2fdc9c9247
6 changed files with 25 additions and 16 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -35,16 +35,15 @@ class CSV_handler:
subject_nr = data_container.subject_nr
self.data_container_dict[subject_nr] = data_container
# Places the data correctly:
if which_arm is 'left':
if which_arm == 'left':
data_container.data_dict['left'][emg_nr+1] = df
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
min = df['timestamp'].min()
max = df['timestamp'].max()
return min, max

View File

@ -73,13 +73,13 @@ def load_user_emg_data():
left_list = [subject1_left_files, subject2_left_files, subject3_left_files, subject4_left_files, subject5_left_files]
right_list = [subject1_right_files, subject2_right_files, subject3_right_files, subject4_right_files, subject5_right_files]
csv_handler = CSV_handler
csv_handler = Handler.CSV_handler
subject1_data_container = Data_container(1, 'HaluskaMarek')
subject2_data_container = Data_container(1, 'HaluskaMaros')
subject3_data_container = Data_container(1, 'HaluskovaBeata')
subject4_data_container = Data_container(1, 'KelisekDavid')
subject5_data_container = Data_container(1, 'KelisekRichard')
subject1_data_container = Handler.Data_container(1, 'HaluskaMarek')
subject2_data_container = Handler.Data_container(1, 'HaluskaMaros')
subject3_data_container = Handler.Data_container(1, 'HaluskovaBeata')
subject4_data_container = Handler.Data_container(1, 'KelisekDavid')
subject5_data_container = Handler.Data_container(1, 'KelisekRichard')
subject_data_container_list = [subject1_data_container, subject2_data_container, subject3_data_container,
subject4_data_container, subject5_data_container]
@ -100,7 +100,8 @@ def load_user_emg_data():
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)
print(duration)
x = np.linspace(0, duration, SAMPLE_RATE * duration, endpoint=False)
y = np.array(df.iloc(1))
return x, y, duration
@ -126,10 +127,10 @@ def plot_fft(x_f, y_f):
plt.show()
handler = Handler.CSV_handler
handler = 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)
#print(trans_df.info)
plot_fft(trans_df)

View File

@ -1,6 +1,6 @@
from Handle_emg_data import CSV_handler
from Handle_emg_data import CSV_handler, get_min_max_timestamp
import matplotlib.pyplot as plt
import Signal_prep
#import Signal_prep
def test_df_extraction(emg_nr):
handler = CSV_handler()
@ -16,3 +16,12 @@ def test_load_func():
subject2_container = test_dict[2]
print(subject2_container.data_dict['left'][1])
def test_min_max_func():
handler = CSV_handler()
file = "/Exp20201205_2myo_hardTypePP/HaluskaMarek_20201207_1810/myoLeftEmg.csv"
df = handler.get_time_emg_table(file, 1)
min, max = get_min_max_timestamp(df)
print(min)
print(max)
test_min_max_func()