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 subject_nr = data_container.subject_nr
self.data_container_dict[subject_nr] = data_container self.data_container_dict[subject_nr] = data_container
# Places the data correctly: # Places the data correctly:
if which_arm is 'left': if which_arm == 'left':
data_container.data_dict['left'][emg_nr+1] = df data_container.data_dict['left'][emg_nr+1] = df
def get_emg_str(emg_nr): def get_emg_str(emg_nr):
return 'emg' + str(emg_nr) return 'emg' + str(emg_nr)
def get_min_max_timestamp(df:DataFrame): def get_min_max_timestamp(df:DataFrame):
min = df['timestamp'].argmin min = df['timestamp'].min()
max = df['timestamp'].argmax max = df['timestamp'].max()
return min, 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] 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] 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') subject1_data_container = Handler.Data_container(1, 'HaluskaMarek')
subject2_data_container = Data_container(1, 'HaluskaMaros') subject2_data_container = Handler.Data_container(1, 'HaluskaMaros')
subject3_data_container = Data_container(1, 'HaluskovaBeata') subject3_data_container = Handler.Data_container(1, 'HaluskovaBeata')
subject4_data_container = Data_container(1, 'KelisekDavid') subject4_data_container = Handler.Data_container(1, 'KelisekDavid')
subject5_data_container = Data_container(1, 'KelisekRichard') subject5_data_container = Handler.Data_container(1, 'KelisekRichard')
subject_data_container_list = [subject1_data_container, subject2_data_container, subject3_data_container, subject_data_container_list = [subject1_data_container, subject2_data_container, subject3_data_container,
subject4_data_container, subject5_data_container] subject4_data_container, subject5_data_container]
@ -100,7 +100,8 @@ def load_user_emg_data():
def prep_df_for_trans(df:DataFrame): def prep_df_for_trans(df:DataFrame):
sample_rate = SAMPLE_RATE sample_rate = SAMPLE_RATE
min, duration = Handler.get_min_max_timestamp(df) 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)) y = np.array(df.iloc(1))
return x, y, duration return x, y, duration
@ -126,10 +127,10 @@ def plot_fft(x_f, y_f):
plt.show() plt.show()
handler = Handler.CSV_handler handler = Handler.CSV_handler()
file = "/Exp20201205_2myo_hardTypePP/HaluskaMarek_20201207_1810/myoLeftEmg.csv" file = "/Exp20201205_2myo_hardTypePP/HaluskaMarek_20201207_1810/myoLeftEmg.csv"
df = handler.get_time_emg_table(file, 1) df = handler.get_time_emg_table(file, 1)
#plot_df(df) #plot_df(df)
trans_df = DataFrame(transformed_df(df)) trans_df = DataFrame(transformed_df(df))
print(trans_df.info) #print(trans_df.info)
plot_df(trans_df) 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 matplotlib.pyplot as plt
import Signal_prep #import Signal_prep
def test_df_extraction(emg_nr): def test_df_extraction(emg_nr):
handler = CSV_handler() handler = CSV_handler()
@ -16,3 +16,12 @@ def test_load_func():
subject2_container = test_dict[2] subject2_container = test_dict[2]
print(subject2_container.data_dict['left'][1]) 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()