Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files- app.py +77 -0
- test-1/0-New_Task-recording-0.csv +0 -0
- test-1/time_marker.csv +15 -0
- test-2/0-New_Task-recording-0.csv +0 -0
- test-2/time_marker.csv +13 -0
app.py
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
# Set streamlit configuration with wide mode
|
7 |
+
st.set_page_config(layout="wide")
|
8 |
+
st.config.set_option("server.enableXsrfProtection", False)
|
9 |
+
|
10 |
+
def plot_signal(signal, index):
|
11 |
+
# Assuming df is your DataFrame and 'Signal1', 'Signal2', 'Signal3' are your columns
|
12 |
+
ch1 = pd.to_numeric(signal[index], errors='coerce')
|
13 |
+
|
14 |
+
# Define the moving average window size
|
15 |
+
N = 25
|
16 |
+
|
17 |
+
# Function to calculate moving RMS
|
18 |
+
def moving_rms(signal, window_size):
|
19 |
+
return np.sqrt(pd.Series(signal).rolling(window=window_size).mean()**2)
|
20 |
+
|
21 |
+
# Calculate moving RMS for each channel
|
22 |
+
ch1_rms = moving_rms(ch1, N)
|
23 |
+
|
24 |
+
# Calculate mean and standard deviation of the RMS signals
|
25 |
+
mean_ch1_rms = np.mean(ch1_rms)
|
26 |
+
std_ch1_rms = np.std(ch1_rms)
|
27 |
+
|
28 |
+
# Print mean and standard deviation values
|
29 |
+
st.write(f'Mean of RMS Signal {int(index)}: {mean_ch1_rms:.3f}, Std Dev of RMS Signal 1: {std_ch1_rms:.3f}')
|
30 |
+
|
31 |
+
# Plot the RMS signals
|
32 |
+
plt.figure(figsize=(15,6))
|
33 |
+
plt.plot(ch1_rms, label='Signal 1 RMS')
|
34 |
+
plt.title('RMS Signal Values, Moving Average Window Size N=25')
|
35 |
+
plt.xlabel('Index')
|
36 |
+
plt.ylabel('RMS Value')
|
37 |
+
plt.legend()
|
38 |
+
st.pyplot(plt.gcf())
|
39 |
+
# plt.show()
|
40 |
+
|
41 |
+
|
42 |
+
def main():
|
43 |
+
st.title('👅Dysphagia Analysis - by ITRI BDL')
|
44 |
+
uploaded_file1 = st.file_uploader("Choose the EMG_data CSV file", type="csv")
|
45 |
+
uploaded_file2 = st.file_uploader("Choose the time_marker CSV file", type="csv")
|
46 |
+
if uploaded_file1 is not None:
|
47 |
+
try:
|
48 |
+
data1 = pd.read_csv(uploaded_file1, skiprows=[0,1,3,4])
|
49 |
+
# st.dataframe(data1)
|
50 |
+
except Exception as e:
|
51 |
+
st.error(f"Error: {e}")
|
52 |
+
|
53 |
+
if uploaded_file2 is not None:
|
54 |
+
try:
|
55 |
+
data2 = pd.read_csv(uploaded_file2, skiprows=[0,1])
|
56 |
+
# st.dataframe(data2)
|
57 |
+
except Exception as e:
|
58 |
+
st.error(f"Error: {e}")
|
59 |
+
|
60 |
+
# Detect Upload File and choose signal with sidebar menu
|
61 |
+
if uploaded_file1 is not None and uploaded_file2 is not None:
|
62 |
+
signal = st.sidebar.selectbox('Select EMG Signal', data1.columns)
|
63 |
+
st.write(f'You selected: channel {signal}')
|
64 |
+
|
65 |
+
# Plot the selected signal
|
66 |
+
st.line_chart(data1[signal])
|
67 |
+
|
68 |
+
# Analysis button
|
69 |
+
if st.button('Start Analysis'):
|
70 |
+
st.write('Analysis started...')
|
71 |
+
# Add analysis code here
|
72 |
+
plot_signal(data1, signal)
|
73 |
+
st.write('Analysis completed...')
|
74 |
+
|
75 |
+
|
76 |
+
if __name__ == '__main__':
|
77 |
+
main()
|
test-1/0-New_Task-recording-0.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
test-1/time_marker.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Abs_time(us),0-New_Task-recording_time(us),topic,type,name,uuid,signal,description,color,order,tag
|
2 |
+
1700714106720311.0,32030195.0,keyboard/z,keyboard,bite,8c635c9f-5269-4adf-b3e9-c22542516934,z,,#9be5e5,11,start
|
3 |
+
1700714130984351.0,56294235.0,keyboard/z,keyboard,bite,99e3242e-d0da-4d78-83f9-5141851f07af,z,,#9be5e5,11,end
|
4 |
+
1700714134974650.0,60284534.0,keyboard/x,keyboard,swallow,5ade9d52-e4a3-43be-8b35-8cc078f3d253,x,,#fab6b6,12,start
|
5 |
+
1700714137168959.0,62478843.0,keyboard/x,keyboard,swallow,bfe88eb4-2eae-4fe9-afbe-0c3eb807d5fe,x,,#fab6b6,12,end
|
6 |
+
1700714142582792.0,67892676.0,keyboard/x,keyboard,swallow,5ade9d52-e4a3-43be-8b35-8cc078f3d253,x,,#fab6b6,13,start
|
7 |
+
1700714143906548.0,69216432.0,keyboard/x,keyboard,swallow,bfe88eb4-2eae-4fe9-afbe-0c3eb807d5fe,x,,#fab6b6,13,end
|
8 |
+
1700714146586760.0,71896644.0,keyboard/x,keyboard,swallow,5ade9d52-e4a3-43be-8b35-8cc078f3d253,x,,#fab6b6,14,start
|
9 |
+
1700714147725033.0,73034917.0,keyboard/x,keyboard,swallow,bfe88eb4-2eae-4fe9-afbe-0c3eb807d5fe,x,,#fab6b6,14,end
|
10 |
+
1700714151788953.0,77098837.0,keyboard/c,keyboard,cough,722bfb5a-b5e9-49be-aa5b-2f3fee9a8638,c,,#baeea0,15,start
|
11 |
+
1700714154031673.0,79341557.0,keyboard/c,keyboard,cough,1997a384-f25c-4449-8241-c0ff032ae4b3,c,,#baeea0,15,end
|
12 |
+
1700714157407981.0,82717865.0,keyboard/c,keyboard,cough,722bfb5a-b5e9-49be-aa5b-2f3fee9a8638,c,,#baeea0,16,start
|
13 |
+
1700714158682385.0,83992269.0,keyboard/c,keyboard,cough,1997a384-f25c-4449-8241-c0ff032ae4b3,c,,#baeea0,16,end
|
14 |
+
1700714161034645.0,86344529.0,keyboard/c,keyboard,cough,722bfb5a-b5e9-49be-aa5b-2f3fee9a8638,c,,#baeea0,17,start
|
15 |
+
1700714162842739.0,88152623.0,keyboard/c,keyboard,cough,1997a384-f25c-4449-8241-c0ff032ae4b3,c,,#baeea0,17,end
|
test-2/0-New_Task-recording-0.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
test-2/time_marker.csv
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Abs_time(us),0-New_Task-recording_time(us),topic,type,name,uuid,signal,description,color,order,tag
|
2 |
+
1700713793991735.0,30286818.0,keyboard/z,keyboard,bite,8c635c9f-5269-4adf-b3e9-c22542516934,z,,#9be5e5,5,start
|
3 |
+
1700713816501425.0,52796508.0,keyboard/z,keyboard,bite,99e3242e-d0da-4d78-83f9-5141851f07af,z,,#9be5e5,5,end
|
4 |
+
1700713820622296.0,56917379.0,keyboard/x,keyboard,swallow,5ade9d52-e4a3-43be-8b35-8cc078f3d253,x,,#fab6b6,6,start
|
5 |
+
1700713821988158.0,58283241.0,keyboard/x,keyboard,swallow,bfe88eb4-2eae-4fe9-afbe-0c3eb807d5fe,x,,#fab6b6,6,end
|
6 |
+
1700713824999100.0,61294183.0,keyboard/x,keyboard,swallow,5ade9d52-e4a3-43be-8b35-8cc078f3d253,x,,#fab6b6,7,start
|
7 |
+
1700713826299090.0,62594173.0,keyboard/x,keyboard,swallow,bfe88eb4-2eae-4fe9-afbe-0c3eb807d5fe,x,,#fab6b6,7,end
|
8 |
+
1700713831028230.0,67323313.0,keyboard/x,keyboard,swallow,5ade9d52-e4a3-43be-8b35-8cc078f3d253,x,,#fab6b6,8,start
|
9 |
+
1700713834021668.0,70316751.0,keyboard/x,keyboard,swallow,bfe88eb4-2eae-4fe9-afbe-0c3eb807d5fe,x,,#fab6b6,8,end
|
10 |
+
1700713839296238.0,75591321.0,keyboard/c,keyboard,cough,722bfb5a-b5e9-49be-aa5b-2f3fee9a8638,c,,#baeea0,9,start
|
11 |
+
1700713841111273.0,77406356.0,keyboard/c,keyboard,cough,1997a384-f25c-4449-8241-c0ff032ae4b3,c,,#baeea0,9,end
|
12 |
+
1700713843632670.0,79927753.0,keyboard/c,keyboard,cough,722bfb5a-b5e9-49be-aa5b-2f3fee9a8638,c,,#baeea0,10,start
|
13 |
+
1700713845941739.0,82236822.0,keyboard/c,keyboard,cough,1997a384-f25c-4449-8241-c0ff032ae4b3,c,,#baeea0,10,end
|