Spaces:
Sleeping
Sleeping
Commit
·
dfff50a
1
Parent(s):
e5e0f53
update app.py
Browse files
app.py
CHANGED
@@ -23,21 +23,91 @@ def test(model_name, fill_mode, csv_file, chanlocs_file):
|
|
23 |
|
24 |
return tmp_path+'/'+output_name
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
value="ICUNet",
|
30 |
label="Model")
|
31 |
-
|
32 |
value="zero",
|
33 |
label="Imputation")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
if __name__ == "__main__":
|
43 |
-
app.launch(
|
|
|
23 |
|
24 |
return tmp_path+'/'+output_name
|
25 |
|
26 |
+
|
27 |
+
with gr.Blocks() as app:
|
28 |
+
with gr.Row():
|
29 |
+
gr.Markdown(
|
30 |
+
"""
|
31 |
+
# Introduction
|
32 |
+
(...)
|
33 |
+
"""
|
34 |
+
)
|
35 |
+
with gr.Row():
|
36 |
+
with gr.Column():
|
37 |
+
input_model_name = gr.Dropdown(choices=["ICUNet", "UNetpp", "AttUnet", "EEGART"],
|
38 |
value="ICUNet",
|
39 |
label="Model")
|
40 |
+
input_fill_mode = gr.Dropdown(choices=["zero", "adjacent channel's value"],
|
41 |
value="zero",
|
42 |
label="Imputation")
|
43 |
+
input_data = gr.File(label="Raw data (.csv)", file_types=[".csv"])
|
44 |
+
input_loc = gr.File(label="Channel locations (.loc, .locs)", file_types=[".loc", "locs"])
|
45 |
+
btn = gr.Button()
|
46 |
+
with gr.Column():
|
47 |
+
output_data = gr.File(label="Denoised data")
|
48 |
+
# put template_loc file
|
49 |
+
gr.Markdown(
|
50 |
+
"""
|
51 |
+
(Missing channels)
|
52 |
+
(New channel locations)
|
53 |
+
"""
|
54 |
+
)
|
55 |
+
with gr.Row():
|
56 |
+
with gr.Tab("README"):
|
57 |
+
gr.Markdown(
|
58 |
+
"""
|
59 |
+
# Quickstart
|
60 |
+
|
61 |
+
### Raw data
|
62 |
+
1. The data need to be a two-dimensional array (channel, timepoint).
|
63 |
+
2. Make sure you have **resampled** your data to **256 Hz**.
|
64 |
+
3. Upload your EEG data in `.csv` format.
|
65 |
+
|
66 |
+
### Channel locations
|
67 |
+
Upload your data's channel locations in `.loc` format, which can be obtained using **EEGLAB**.
|
68 |
+
|
69 |
+
### Model
|
70 |
+
Choose the model you want to use.
|
71 |
+
The detailed description of the models can be found in other pages.
|
72 |
+
|
73 |
+
### Imputation
|
74 |
+
The models was trained using the EEG signals of 30 channels, including: `Fp1, Fp2, F7, F3, Fz, F4, F8, FT7, FC3, FCz, FC4, FT8, T7, C3, Cz, C4, T8, TP7, CP3, CPz, CP4, TP8, P7, P3, Pz, P4, P8, O1, Oz, O2`.
|
75 |
+
We expect your input data to include these channels as well.
|
76 |
+
If your data doesn't contain all of the mentioned channels, we will:
|
77 |
+
1. Attempt to find neighboring channels to use as alternatives. For instance, if the required channel is **FC3** but you only have **FC1**, we will use it as a replacement for **FC3**.
|
78 |
+
2. Use <u>Imputation</u> to fill the missing channels' value:
|
79 |
+
- **zero**: fill the missing channels with zeros.
|
80 |
+
- **adjacent**: fill the missing channels using neighboring channels' value.
|
81 |
+
>Note: The imputed channels **need to be removed** after the data being reconstructed.
|
82 |
+
|
83 |
+
### Missing channels
|
84 |
+
The channels displayed here are those for which the template didn't find suitable channels to use, and utilized <u>Imputation</u> to fill the missing values.
|
85 |
+
Therefore, you need to
|
86 |
+
<b><font color=#FF0000>remove these channels</font></b>
|
87 |
+
after you download the denoised data.
|
88 |
|
89 |
+
"""
|
90 |
+
# ### Denoised data: Once the reconstructing process finished, the denoised data will be downloadable here.
|
91 |
+
# ### New channel locations: The template channel locations is downloadable here.
|
92 |
+
)
|
93 |
+
with gr.Tab("IC-U-Net"):
|
94 |
+
gr.Markdown(
|
95 |
+
"""
|
96 |
+
# IC-U-Net
|
97 |
+
### Abstract
|
98 |
+
Electroencephalography (EEG) signals are often contaminated with artifacts. It is imperative to develop a practical and reliable artifact removal method to prevent the misinterpretation of neural signals and the underperformance of brain–computer interfaces. Based on the U-Net architecture, we developed a new artifact removal model, IC-U-Net, for removing pervasive EEG artifacts and reconstructing brain signals. IC-U-Net was trained using mixtures of brain and non-brain components decomposed by independent component analysis. It uses an ensemble of loss functions to model complex signal fluctuations in EEG recordings. The effectiveness of the proposed method in recovering brain activities and removing various artifacts (e.g., eye blinks/movements, muscle activities, and line/channel noise) was demonstrated in a simulation study and four real-world EEG experiments. IC-U-Net can reconstruct a multi-channel EEG signal and is applicable to most artifact types, offering a promising end-to-end solution for automatically removing artifacts from EEG recordings. It also meets the increasing need to image natural brain dynamics in a mobile setting.
|
99 |
|
100 |
+
"""
|
101 |
+
)
|
102 |
+
with gr.Tab("IC-U-Net++"):
|
103 |
+
gr.Markdown(
|
104 |
+
"""
|
105 |
+
# Test
|
106 |
+
"""
|
107 |
+
)
|
108 |
+
|
109 |
+
inputs = [input_model_name, input_fill_mode, input_data, input_loc]
|
110 |
+
btn.click(fn=test, inputs=inputs, outputs=output_data)
|
111 |
|
112 |
if __name__ == "__main__":
|
113 |
+
app.launch()
|