Spaces:
Sleeping
Sleeping
Commit
·
98fb56f
1
Parent(s):
1b47010
Some minor changes
Browse files- portiloop/src/demo/demo.py +14 -7
- portiloop/src/demo/offline.py +1 -1
portiloop/src/demo/demo.py
CHANGED
@@ -11,13 +11,13 @@ def on_upload_file(file):
|
|
11 |
yield f"File {file.name} successfully uploaded!"
|
12 |
|
13 |
|
14 |
-
with gr.Blocks() as demo:
|
15 |
gr.Markdown("# Portiloop Demo")
|
16 |
-
gr.Markdown("This Demo takes as input
|
17 |
gr.Markdown("Upload your CSV file and click **Run Inference** to start the processing...")
|
18 |
|
19 |
with gr.Row():
|
20 |
-
xdf_file = gr.UploadButton(label="
|
21 |
|
22 |
# Offline Filtering (Boolean)
|
23 |
offline_filtering = gr.Checkbox(label="Offline Filtering (On/Off)", value=True)
|
@@ -38,17 +38,24 @@ with gr.Blocks() as demo:
|
|
38 |
freq = gr.Dropdown(choices=["100", "200", "250", "256", "500", "512", "1000", "1024"], value="250", label="Sampling Frequency (Hz)", interactive=True)
|
39 |
|
40 |
# Output elements
|
41 |
-
update_text = gr.Textbox(value="
|
42 |
output_plot = gr.Plot()
|
43 |
output_array = gr.File(label="Output CSV File")
|
44 |
xdf_file.upload(fn=on_upload_file, inputs=[xdf_file], outputs=[update_text])
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
# Row containing all buttons:
|
47 |
with gr.Row():
|
48 |
# Run inference button
|
49 |
-
run_inference = gr.Button(
|
|
|
50 |
# Reset button
|
51 |
-
reset = gr.Button(value="Reset", variant="secondary")
|
52 |
run_inference.click(
|
53 |
fn=run_offline,
|
54 |
inputs=[
|
@@ -64,4 +71,4 @@ with gr.Blocks() as demo:
|
|
64 |
outputs=[output_plot, output_array, update_text])
|
65 |
|
66 |
demo.queue()
|
67 |
-
demo.launch(share=
|
|
|
11 |
yield f"File {file.name} successfully uploaded!"
|
12 |
|
13 |
|
14 |
+
with gr.Blocks(title="Portiloop") as demo:
|
15 |
gr.Markdown("# Portiloop Demo")
|
16 |
+
gr.Markdown("This Demo takes as input an XDF file coming from the Portiloop EEG device and allows you to convert it to CSV and perform the following actions:: \n * Filter the data offline \n * Perform offline spindle detection using Wamsley or Lacourse. \n * Simulate the Portiloop online filtering and spindle detection with different parameters.")
|
17 |
gr.Markdown("Upload your CSV file and click **Run Inference** to start the processing...")
|
18 |
|
19 |
with gr.Row():
|
20 |
+
xdf_file = gr.UploadButton(label="XDF File", type="file")
|
21 |
|
22 |
# Offline Filtering (Boolean)
|
23 |
offline_filtering = gr.Checkbox(label="Offline Filtering (On/Off)", value=True)
|
|
|
38 |
freq = gr.Dropdown(choices=["100", "200", "250", "256", "500", "512", "1000", "1024"], value="250", label="Sampling Frequency (Hz)", interactive=True)
|
39 |
|
40 |
# Output elements
|
41 |
+
update_text = gr.Textbox(value="Upload an XDF File and click 'Run Inference'...", label="Status", interactive=False)
|
42 |
output_plot = gr.Plot()
|
43 |
output_array = gr.File(label="Output CSV File")
|
44 |
xdf_file.upload(fn=on_upload_file, inputs=[xdf_file], outputs=[update_text])
|
45 |
|
46 |
+
def clear():
|
47 |
+
output_plot.clear()
|
48 |
+
output_array.clear()
|
49 |
+
update_text.clear()
|
50 |
+
xdf_file.clear()
|
51 |
+
|
52 |
# Row containing all buttons:
|
53 |
with gr.Row():
|
54 |
# Run inference button
|
55 |
+
run_inference = gr.Button(
|
56 |
+
value="Run Inference")
|
57 |
# Reset button
|
58 |
+
reset = gr.Button(value="Reset", variant="secondary", on_click=clear,)
|
59 |
run_inference.click(
|
60 |
fn=run_offline,
|
61 |
inputs=[
|
|
|
71 |
outputs=[output_plot, output_array, update_text])
|
72 |
|
73 |
demo.queue()
|
74 |
+
demo.launch(share=False)
|
portiloop/src/demo/offline.py
CHANGED
@@ -115,7 +115,7 @@ def run_offline(xdf_file, offline_filtering, online_filtering, online_detection,
|
|
115 |
plt.legend()
|
116 |
plt.xlabel("Time (s)")
|
117 |
plt.ylabel("Amplitude")
|
118 |
-
yield fig, None, "Running online filtering and detection..."
|
119 |
|
120 |
if online_filtering:
|
121 |
online_filtered = np.array(points)
|
|
|
115 |
plt.legend()
|
116 |
plt.xlabel("Time (s)")
|
117 |
plt.ylabel("Amplitude")
|
118 |
+
yield fig, None, f"Running online filtering and detection {index}/{len(data)}..."
|
119 |
|
120 |
if online_filtering:
|
121 |
online_filtered = np.array(points)
|