feat: add class as a data_container for each subject
This commit is contained in:
parent
a601946d45
commit
5a127abbae
@ -1,10 +1,20 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
class Data_container:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.subject_nr
|
||||||
|
self.subject_name
|
||||||
|
self.data_dict
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CSV_handler:
|
class CSV_handler:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.working_dir = str(Path.cwd())
|
self.working_dir = str(Path.cwd())
|
||||||
|
self.data_container_dict = {i: []}
|
||||||
|
|
||||||
# Makes dataframe from the csv files in the working directory
|
# Makes dataframe from the csv files in the working directory
|
||||||
def make_df(self, filename):
|
def make_df(self, filename):
|
||||||
@ -13,16 +23,20 @@ class CSV_handler:
|
|||||||
return df
|
return df
|
||||||
|
|
||||||
# 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: str, subject_nr: int, which_arm: str, emg_nr: int):
|
||||||
tot_data_frame = self.make_df(filename)
|
tot_data_frame = self.make_df(filename)
|
||||||
emg_str = '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]]
|
||||||
|
|
||||||
|
#self.data_dict[subject_nr] = [which_arm, emg1]
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
def get_min_max_timestamp():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
from Handle_emg_data import CSV_handler
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user