test: test plotting data from prev. made fuctions

This commit is contained in:
Skudalen 2021-06-23 11:01:02 +02:00
parent dd0e245f3b
commit a601946d45
3 changed files with 18 additions and 7 deletions

View File

@ -14,15 +14,16 @@ class CSV_handler:
# Extracts out the timestamp and the selected emg signal into a new dataframe # Extracts out the timestamp and the selected emg signal into a new dataframe
def get_time_emg_table(self, filename, emg_nr): def get_time_emg_table(self, filename, emg_nr):
tot_data_frame = self.make_df(filename) tot_data_frame = self.make_df(filename)
emg_str = self.get_emg_str(emg_nr) emg_str = 'emg' + str(emg_nr)
filtered_df = tot_data_frame[["timestamp", emg_str]] filtered_df = tot_data_frame[["timestamp", emg_str]]
return filtered_df return filtered_df
def get_emg_str(emg_nr): def get_emg_str(emg_nr):
return 'emg' + str(emg_nr) return 'emg' + str(emg_nr)

View File

@ -1,11 +1,21 @@
from Handle_emg_data import CSV_handler from Handle_emg_data import CSV_handler
import matplotlib.pyplot as plt
def test_df_extraction(): def test_df_extraction(emg_nr):
handler = CSV_handler() handler = CSV_handler()
filename = "Exp20201205_2myo_hardTypePP/HaluskaMarek_20201207_1810/myoLeftEmg.csv" file = "/Exp20201205_2myo_hardTypePP/HaluskaMarek_20201207_1810/myoLeftEmg.csv"
subject1_left_emg1 = handler.get_time_emg_table(filename, 1) subject1_left_emg1 = handler.get_time_emg_table(file, emg_nr)
print(subject1_left_emg1.head)
print(subject1_left_emg1.head()) return subject1_left_emg1, emg_nr
test_df_extraction()
# running
handler = CSV_handler
df, emg_nr = test_df_extraction(1)
print(emg_nr)
emg_str = handler.get_emg_str(emg_nr)
lines = df.plot.line(x='timestamp', y=emg_str)
plt.show()