fadzwan commited on
Commit
a7252ea
·
verified ·
1 Parent(s): aaea07f

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +21 -0
src/streamlit_app.py CHANGED
@@ -269,6 +269,27 @@ if st.button("Show Band Power Chart (TP9)"):
269
  # Button to show EEG animation
270
  if st.button("Show Animated EEG Trace (TP9)"):
271
  try:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  # Setup figure and axes
273
  fig, ax = plt.subplots()
274
  line, = ax.plot([], [], lw=2)
 
269
  # Button to show EEG animation
270
  if st.button("Show Animated EEG Trace (TP9)"):
271
  try:
272
+ response = requests.get(csv_url)
273
+ response.raise_for_status()
274
+ data = pd.read_csv(io.StringIO(response.text))
275
+ st.write(f"Loaded data with shape: {data.shape}")
276
+
277
+ # Extract timestamps and TP9
278
+ timestamps = data['timestamps'] if 'timestamps' in data.columns else data['TimeStamp']
279
+ tp10_raw = data['TP9']
280
+
281
+ # Calculate sampling rate
282
+ time_diffs = np.diff(timestamps)
283
+ average_interval = np.mean(time_diffs)
284
+ sampling_rate = 1 / average_interval
285
+
286
+ # Create MNE Raw object
287
+ info = mne.create_info(ch_names=['TP9'], sfreq=sampling_rate, ch_types='eeg')
288
+ raw = mne.io.RawArray(np.array([tp10_raw]), info)
289
+
290
+ # Apply bandpass filter
291
+ raw.filter(1, 50, fir_design='firwin')
292
+ tp10_filtered_mne = raw.get_data()[0]
293
  # Setup figure and axes
294
  fig, ax = plt.subplots()
295
  line, = ax.plot([], [], lw=2)