Autoencoder Deep Learning model for EEG artifact removal in Android smartphone
The EEG dataset (preprocessed) and the Autoencoder Python code is in "ae_model" branch. The trained TensorFlow model, and the converted TensorFlow-Lite model are also included in "ae_model" branch.
The Android Studio project is in "android_app" branch.
Statements and instructions:
- The EEG datasets used in this work are publicly available, and published by other researchers, the source of the dataset is provided below:
(1). EEG/EOG artifact dataset: can be downloaded from: https://data.mendeley.com/datasets/wb6yvr725d/1; and the data usage instructions can be found in DOI: https://www.sciencedirect.com/science/article/pii/S2352340916304000?via%3Dihub
(2). EEG/Motion artifact dataset: is from PhysioNet: https://physionet.org/content/motion-artifact/1.0.0/
(3). EEG/EMG artifact dataset: is obtained from the 'EEGDenoiseNet' paper (DOI: https://iopscience.iop.org/article/10.1088/1741-2552/ac2bf8), data can be downloaded from GitHub:https://github.com/ncclabsustech/EEGdenoiseNet
(Based on these public EEG datasets, this work did appropriate signal pre-processing for the Autoencoder model development. The pre-processing details used for this work can be found in the "code_data" folder -> "Readme" file.)
- The trained Autoencoder Model is saved into "run_model" folder, after downloading the folder, set up the correct directory, and then in Python, run the following code to load the model: example code is provided in the 'quantization_test.py' script.
For obtaining a better model performance, the input raw EEG data should be processed in the same as we did: resample EEG to 200~Hz, segment EEG into 4-second length, normalize the segment into (0,1) amplitude range, and then feed into the model.
#%% Load Model from local directory
autoencoder = tf.keras.models.load_model('path/Autoencoder_revision')
autoencoder.summary()
#%% Run the model by using your preprocessed EEG data
encoded_layer = autoencoder.encoder(x_test_noisy).numpy() // x_test_noisy: your own preprocessed EEG data (the INPUT of the autoencoder model), "encoded_layer" is the intermediate result
decoded_layer = autoencoder.decoder(encoded_layer).numpy() // decoded_layer: the reconstructed EEG data (the OUTPUT of the autoencoder model)
- The "autoencoder_revision.tflite" is the converted autoencoder model for mobile/edge devices, used for TensorFlow-Lite. The example code for using this in Android can be found in
"android_app" branch