feat: functions for fft
This commit is contained in:
parent
c76aa4d8ef
commit
72b2cff336
@ -38,13 +38,13 @@ class CSV_handler:
|
||||
if which_arm is 'left':
|
||||
data_container.data_dict['left'][emg_nr+1] = df
|
||||
|
||||
def get_emg_str(emg_nr):
|
||||
return 'emg' + str(emg_nr)
|
||||
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
|
||||
return min, max
|
||||
def get_min_max_timestamp(df:DataFrame):
|
||||
min = df['timestamp'].argmin
|
||||
max = df['timestamp'].argmax
|
||||
return min, max
|
||||
|
||||
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from pandas.core.frame import DataFrame
|
||||
from scipy.fft import fft
|
||||
|
||||
from Handle_emg_data import CSV_handler, Data_container
|
||||
import Handle_emg_data as Handler
|
||||
|
||||
SAMPLE_RATE = 200
|
||||
|
||||
def load_user_emg_data():
|
||||
|
||||
@ -93,4 +96,31 @@ def load_user_emg_data():
|
||||
|
||||
return csv_handler.data_container_dict
|
||||
|
||||
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)
|
||||
y = np.array(df.iloc(1))
|
||||
return x, y
|
||||
|
||||
def normalize_wave(y_values):
|
||||
return None
|
||||
|
||||
|
||||
def transformed_df(df:DataFrame):
|
||||
x, y = prep_df_for_trans(df)
|
||||
y_values = fft(y)
|
||||
return new_df
|
||||
|
||||
def plot_df(df:DataFrame):
|
||||
lines = df.plot.line(x='timestamp')
|
||||
plt.show()
|
||||
|
||||
|
||||
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)
|
||||
|
@ -11,6 +11,8 @@ def test_df_extraction(emg_nr):
|
||||
|
||||
return subject1_left_emg1, emg_nr
|
||||
|
||||
test_dict = Signal_prep.load_user_emg_data()
|
||||
subject2_container = test_dict[2]
|
||||
print(subject2_container.data_dict['left'][1])
|
||||
def test_load_func():
|
||||
test_dict = Signal_prep.load_user_emg_data()
|
||||
subject2_container = test_dict[2]
|
||||
print(subject2_container.data_dict['left'][1])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user