Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +13 -11
src/streamlit_app.py
CHANGED
|
@@ -8,6 +8,7 @@ from mne.channels import make_dig_montage
|
|
| 8 |
from matplotlib.animation import FuncAnimation
|
| 9 |
import requests
|
| 10 |
import streamlit as st
|
|
|
|
| 11 |
|
| 12 |
# Set page config
|
| 13 |
st.set_page_config(page_title="Muse EEG Topomap Viewer", layout="centered")
|
|
@@ -60,7 +61,7 @@ def plot_eeg_topomap_muse_from_csv(csv_url, save_path_animation=None, save_direc
|
|
| 60 |
if save_path_animation:
|
| 61 |
if save_directory:
|
| 62 |
os.makedirs(save_directory, exist_ok=True)
|
| 63 |
-
save_path_animation = os.path.join(save_directory, save_path_animation)
|
| 64 |
|
| 65 |
fig, ax = plt.subplots()
|
| 66 |
|
|
@@ -86,15 +87,16 @@ generate_button = st.button("Generate Topomap Animation")
|
|
| 86 |
|
| 87 |
if generate_button:
|
| 88 |
try:
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
| 98 |
except Exception as e:
|
| 99 |
st.error(f"❌ Error: {str(e)}")
|
| 100 |
-
#update
|
|
|
|
| 8 |
from matplotlib.animation import FuncAnimation
|
| 9 |
import requests
|
| 10 |
import streamlit as st
|
| 11 |
+
import tempfile
|
| 12 |
|
| 13 |
# Set page config
|
| 14 |
st.set_page_config(page_title="Muse EEG Topomap Viewer", layout="centered")
|
|
|
|
| 61 |
if save_path_animation:
|
| 62 |
if save_directory:
|
| 63 |
os.makedirs(save_directory, exist_ok=True)
|
| 64 |
+
save_path_animation = os.path.join(save_directory, os.path.basename(save_path_animation))
|
| 65 |
|
| 66 |
fig, ax = plt.subplots()
|
| 67 |
|
|
|
|
| 87 |
|
| 88 |
if generate_button:
|
| 89 |
try:
|
| 90 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
| 91 |
+
save_path_animation = os.path.join(tmpdir, "eeg_topomap_animation.gif")
|
| 92 |
+
|
| 93 |
+
gif_path = plot_eeg_topomap_muse_from_csv(
|
| 94 |
+
csv_url,
|
| 95 |
+
save_path_animation=save_path_animation,
|
| 96 |
+
save_directory=tmpdir,
|
| 97 |
+
show_names=True
|
| 98 |
+
)
|
| 99 |
+
if gif_path:
|
| 100 |
+
st.image(gif_path, caption="EEG Topomap Animation")
|
| 101 |
except Exception as e:
|
| 102 |
st.error(f"❌ Error: {str(e)}")
|
|
|