EMG_Biometrics_2021/Handle_emg_data.py

44 lines
1.0 KiB
Python
Raw Normal View History

import pandas as pd
from pathlib import Path
class Data_container:
def __init__(self):
self.subject_nr
self.subject_name
self.data_dict
class CSV_handler:
def __init__(self):
self.working_dir = str(Path.cwd())
self.data_container_dict = {i: []}
2021-06-22 19:00:51 +00:00
# Makes dataframe from the csv files in the working directory
def make_df(self, filename):
filepath = self.working_dir + str(filename)
df = pd.read_csv(filepath)
return df
2021-06-22 19:00:51 +00:00
# Extracts out the timestamp and the selected emg signal into a new dataframe
def get_time_emg_table(self, filename: str, subject_nr: int, which_arm: str, emg_nr: int):
tot_data_frame = self.make_df(filename)
emg_str = 'emg' + str(emg_nr)
2021-06-22 19:00:51 +00:00
filtered_df = tot_data_frame[["timestamp", emg_str]]
#self.data_dict[subject_nr] = [which_arm, emg1]
return filtered_df
2021-06-22 19:00:51 +00:00
2021-06-23 08:40:55 +00:00
def get_emg_str(emg_nr):
return 'emg' + str(emg_nr)
2021-06-22 19:00:51 +00:00
def get_min_max_timestamp():