Spaces:
Sleeping
Sleeping
File size: 2,737 Bytes
7d40d1a 2cb7306 7d40d1a 2cb7306 111f264 b0f3e42 7d40d1a 111f264 7d40d1a 111f264 2cb7306 111f264 2cb7306 111f264 7d40d1a 111f264 1737659 111f264 7d40d1a 1737659 95e2338 98fb56f 111f264 1737659 95e2338 7d40d1a 111f264 86081f4 111f264 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import gradio as gr
from portiloop.src.demo.offline import run_offline
def on_upload_file(file):
# Check if file extension is .xdf
if file.name.split(".")[-1] != "xdf":
raise gr.Error("Please upload a .xdf file.")
else:
return file.name
def main():
with gr.Blocks(title="Portiloop") as demo:
gr.Markdown("# Portiloop Demo")
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.")
gr.Markdown("Upload your XDF file and click **Run Inference** to start the processing...")
with gr.Row():
xdf_file_button = gr.UploadButton(label="Click to Upload", type="file", file_count="single")
xdf_file_static = gr.File(label="XDF File", type='file', interactive=False)
xdf_file_button.upload(on_upload_file, xdf_file_button, xdf_file_static)
# Make a checkbox group for the options
detect_filter = gr.CheckboxGroup(['Offline Filtering', 'Lacourse Detection', 'Wamsley Detection', 'Online Filtering', 'Online Detection'], type='index', label="Filtering/Detection options")
# Threshold value
threshold = gr.Slider(0, 1, value=0.82, step=0.01, label="Threshold", interactive=True)
# Detection Channel
with gr.Row():
detect_channel = gr.Dropdown(choices=["1", "2", "3", "4", "5", "6", "7", "8"], value="2", label="Detection Channel in XDF recording", interactive=True)
# Frequency
freq = gr.Dropdown(choices=["100", "200", "250", "256", "500", "512", "1000", "1024"], value="250", label="Sampling Frequency (Hz)", interactive=True)
# Detect trains dropdown
detect_trains = gr.Dropdown(choices=["All Spindles", "Isolated & First", "Trains"], value="All Spindles", label="Detection mode:", interactive=True)
with gr.Row():
output_array = gr.File(label="Output CSV File")
output_table = gr.Markdown(label="Output Table")
run_inference = gr.Button(value="Run Inference")
run_inference.click(
fn=run_offline,
inputs=[
xdf_file_static,
detect_filter,
threshold,
detect_channel,
freq,
detect_trains],
outputs=[output_array, output_table])
demo.queue()
demo.launch(share=False)
if __name__ == "__main__":
main()
|