The code for an EEG feature filtering and disguising model
This is our code for Neurocomputing paper “Information-preserving Feature Filter for Short-term EEG signals”. This feature filter can filter out personal identities with desired features kept. The designed feature filter can be used for privacy protection. Our papers (feature filter, identity disguising model) are released online.
For the data preprocessing step, simply run the code listed below in order.
data_extra_combined_label.ipynb
in the folder \EEG_idendity_disguising\datasets\eeg to generate training set with extra combined label
python -m visdom.server
python train.py --name cycada_alcoholism --resize_or_crop=None --loadSize=32 --fineSize=32 --which_model_netD n_layers --n_layers_D 3 --model cycle_gan_semantic --lambda_A 1 --lambda_B 1 --lambda_identity 0 --no_flip --batchSize 64 --dataset_mode EEG --dataroot ./datasets/eeg/ --data_real uci_eeg_images_train_within_extra.mat --data_dummy eeg_dummy_images_w_label_step3_within_extra.mat --which_direction BtoA --feature alcoholism --num_classes 2
python train.py --name cycada_stimulus --resize_or_crop=None --loadSize=32 --fineSize=32 --which_model_netD n_layers --n_layers_D 3 --model cycle_gan_semantic --lambda_A 1 --lambda_B 1 --lambda_identity 0 --no_flip --batchSize 64 --dataset_mode EEG --dataroot ./datasets/eeg/ --data_real uci_eeg_images_train_within_extra.mat --data_dummy eeg_dummy_images_w_label_step3_within_extra.mat --which_direction BtoA --feature stimulus --num_classes 5
python train.py --name cycada_combined --resize_or_crop=None --loadSize=32 --fineSize=32 --which_model_netD n_layers --n_layers_D 3 --model cycle_gan_semantic --lambda_A 1 --lambda_B 1 --lambda_identity 0 --no_flip --batchSize 64 --dataset_mode EEG --dataroot ./datasets/eeg/ --data_real uci_eeg_images_train_within_extra.mat --data_dummy eeg_dummy_images_w_label_step3_within_extra.mat --which_direction BtoA --feature combined --num_classes 10
python train.py --name cyclegan --resize_or_crop=None --loadSize=32 --fineSize=32 --which_model_netD n_layers --n_layers_D 3 --model cycle_gan --lambda_A 1 --lambda_B 1 --lambda_identity 0 --no_flip --batchSize 64 --dataset_mode EEG --dataroot ./datasets/eeg/ --data_real uci_eeg_images_train_within_extra.mat --data_dummy eeg_dummy_images_w_label_step3_within_extra.mat --which_direction BtoA
The script above train a ResNet-18 model to perform the alcoholism classification task.
python3 resnet_classification_model.py --model ResNet18 --feature alcoholism
--name
checkpoints folder name--classifier
which classifier is used for evaluation--test_all
use this argument to require the validation on the model from all checkpoints saved every 5 training epochs--which_epoch
if test_all
not specified, select one epoch of the model to test cycada_alcoholism_v2
, and requires to test the model from all training epochs
python validation.py --name cycada_alcoholism_v2 --resize_or_crop=None --loadSize=32 --fineSize=32 --which_model_netD n_layers --n_layers_D 3 --model test --no_flip --batchSize 32 --dataset_mode EEGsingle --dataroot ./datasets/eeg/ --data uci_eeg_images_validation_within.mat --which_direction BtoA --phase train --how_many 100000 --classifier ResNet34 --test_all
python validation.py --name cycada_alcoholism_v2 --resize_or_crop=None --loadSize=32 --fineSize=32 --which_model_netD n_layers --n_layers_D 3 --model test --no_flip --batchSize 32 --dataset_mode EEGsingle --dataroot ./datasets/eeg/ --data uci_eeg_images_validation_within.mat --which_direction BtoA --phase train --how_many 100000 --classifier ResNet34 --which_epoch 190
python validation.py --name cycada_stimulus_v2 --resize_or_crop=None --loadSize=32 --fineSize=32 --which_model_netD n_layers --n_layers_D 3 --model test --no_flip --batchSize 32 --dataset_mode EEGsingle --dataroot ./datasets/eeg/ --data uci_eeg_images_validation_within.mat --which_direction BtoA --phase train --how_many 100000 --classifier ResNet34 --which_epoch 45
python validation.py --name cycada_combined_v2 --resize_or_crop=None --loadSize=32 --fineSize=32 --which_model_netD n_layers --n_layers_D 3 --model test --no_flip --batchSize 32 --dataset_mode EEGsingle --dataroot ./datasets/eeg/ --data uci_eeg_images_validation_within.mat --which_direction BtoA --phase train --how_many 100000 --classifier ResNet34 --which_epoch 150
The full version of the project with code, datasets and checkpoints are uploaded to this share link: /g/personal/u6783346_anu_edu_au/EgceXDJhJvhBuzYdsF0ELogBhISm7VaMaH-rBRqMHj_DPQ?e=tjOhO2">code, datasets and checkpoints
python validation.py --name cyclegan_v2 --resize_or_crop=None --loadSize=32 --fineSize=32 --which_model_netD n_layers --n_layers_D 3 --model test --no_flip --batchSize 32 --dataset_mode EEGsingle --dataroot ./datasets/eeg/ --data uci_eeg_images_validation_within.mat --which_direction BtoA --phase train --how_many 100000 --classifier ResNet34 --which_epoch 40
*You may need to downgrade scipy to 1.1.0
pip install scipy==1.1.0
if you find this code useful, please kindly cite
@article{yao2020information,
title={Information-preserving Feature Filter for Short-term EEG signals},
author={Yao, Yue and Plested, Josephine and Gedeon, Tom},
journal={Neurocomputing},
year={2020},
publisher={Elsevier}
}