This Repository is for CBCI Challenge WCCI 2020 submission. The competition was about SMR and signal classification problem.
- About dataset
- Requirements
- Methods and pipeline for train the model on data
- How to run
- Contributing
- License
The dataset of the competition "Clinical Brain Computer Interfaces Challenge" is about the EEG data of 10 hemiparetic stroke patients who are impaired either by left or right hand finger mobility. There are two files for each participant. The file name ending with "T" designates the training file, and the file name ending with "E" designates the evaluation/testing file.
To Run the codes you need:
- matlab
- R : For installing R you can use
sudo apt-get install r-base
for linux (ubuntu) or install R for windows from this link.
For this part of competition we use matlab to filter the data and run CSP (Common Spatial Patterns) to exctract the features of data and make a LDA model to train on features and the prediciting the evaluation file.
Each single subject method describes blow:
For this subject, first we load the "Parsed_P01T.mat" and then use my2Dmatrix function to make a (804096 , 12) data. Next we use mycarfilter. After this we separate the data into 2 dataset correspond to right motor attempt and left motor attempt by myclassseparator function . Split the features into training sets and test sets for each class and use training sest to dataset to generate W parameter and extract the features. (myCSP.m and myfeatures.m) Now we train a LDA model and predict the test set labels to check the accuracy of model. After all for prediciting "Parsed_P01E.mat" we load the dataset and use make a (804096 , 12) data, filter with car filter, change the dimensions to (4096, 12, 40) , extract the features with the W that we generated previously and finally use the trained LDA model to predict the labels of extracted features.
For subject 2, first we load the "Parsed_P02T.mat" and then use my2Dmatrix function to make a (804096 , 12) data. Next we use mycarfilter. After this we separate the data into 2 dataset correspond to right motor attempt and left motor attempt by myclassseparator function . Split the features into training sets and test sets for each class and use training sest to dataset to generate W parameter and extract the features. (myCSP and myfeatures) Now we train a LDA model and predict the test set labels to check the accuracy of model. After all for prediciting "Parsed_P02E.mat" we load the dataset and use make a (804096 , 12) data, filter with car filter, change the dimensions to (4096, 12, 40) , extract the features with the W that we generated previously and finally use the trained LDA model to predict the labels of extracted features.
First we load the "Parsed_P03T.mat" and then use my2Dmatrix function to make a (804096 , 12) data. Next we use mycarfilter. After this we separate the data into 2 dataset correspond to right motor attempt and left motor attempt by myclassseparator function . Split the features into training sets and test sets for each class and use training sest to dataset to generate W parameter and extract the features. (myCSP and myfeatures) Now we train a LDA model and predict the test set labels to check the accuracy of model. After all for prediciting "Parsed_P03E.mat" we load the dataset and use make a (804096 , 12) data, filter with car filter, change the dimensions to (4096, 12, 40) , extract the features with the W that we generated previously and finally use the trained LDA model to predict the labels of extracted features.
For this subject, first we load the "Parsed_P04T.mat" and then use my2Dmatrix function to make a (804096 , 12) data. Next we use mycarfilter. After this we separate the data into 2 dataset correspond to right motor attempt and left motor attempt by myclassseparator function . Split the features into training sets and test sets for each class and use training sest to dataset to generate W parameter and extract the features. (myCSP and myfeatures) Now we train a LDA model and predict the test set labels to check the accuracy of model. After all for prediciting "Parsed_P04E.mat" we load the dataset and use make a (804096 , 12) data, filter with car filter, change the dimensions to (4096, 12, 40) , extract the features with the W that we generated previously and finally use the trained LDA model to predict the labels of extracted features.
For subject 5, first we load the "Parsed_P05T.mat" and then use my2Dmatrix function to make a (804096 , 12) data. Next we use mycarfilter. After this we separate the data into 2 dataset correspond to right motor attempt and left motor attempt by myclassseparator function . Split the features into training sets and test sets for each class and use training sest to dataset to generate W parameter and extract the features. (myCSP and myfeatures) Now we train a LDA model and predict the test set labels to check the accuracy of model. After all for prediciting "Parsed_P05E.mat" we load the dataset and use make a (804096 , 12) data, filter with car filter, change the dimensions to (4096, 12, 40) , extract the features with the W that we generated previously and finally use the trained LDA model to predict the labels of extracted features.
First we load the "Parsed_P06T.mat" and then use my2Dmatrix function to make a (804096 , 12) data. Next we use mycarfilter. After this we separate the data into 2 dataset correspond to right motor attempt and left motor attempt by myclassseparator function . Split the features into training sets and test sets for each class and use training sest to dataset to generate W parameter and extract the features. (myCSP and myfeatures) Now we train a LDA model and predict the test set labels to check the accuracy of model. After all for prediciting "Parsed_P06E.mat" we load the dataset and use make a (804096 , 12) data, filter with car filter, change the dimensions to (4096, 12, 40) , extract the features with the W that we generated previously and finally use the trained LDA model to predict the labels of extracted features.
First we load the "Parsed_P07T.mat" and use mybutterfilter function to filter the data with butter and filtfilt from 12Hz to 30Hz. Next we use mycarfilter. After this we separate the data into 2 dataset correspond to right motor attempt and left motor attempt by myclassseparator function . Split the features into training sets and test sets for each class and use training sest to dataset to generate W parameter and extract the features. (myCSP and myfeatures) Now we train a LDA model and predict the test set labels to check the accuracy of model. After all for prediciting "Parsed_P07E.mat" we load the dataset and filter the trials with save butterworth filter from 12 to 30 Hz. After that filter the data with car filter, change the dimensions to (4096, 12, 40) , extract the features with the W that we generated previously and finally use the trained LDA model to predict the labels of extracted features.
First we load the "Parsed_P08T.mat" and use mybutterfilter function to filter the data with butter and filtfilt from 12Hz to 30Hz. Next we use mycarfilter. After this we separate the data into 2 dataset correspond to right motor attempt and left motor attempt by myclassseparator function . Split the features into training sets and test sets for each class and use training sest to dataset to generate W parameter and extract the features. (myCSP and myfeatures) Now we train a LDA model and predict the test set labels to check the accuracy of model. After all for prediciting "Parsed_P08E.mat" we load the dataset and filter the trials with save butterworth filter from 12 to 30 Hz. Next change the dimensions to (4096, 12, 40) , extract the features with the W that we generated previously and finally use the trained LDA model to predict the labels of extracted features.
For this part of competition we use R programming language. Frist attach the R.matlab package, and by using merging_var_epochs_subjets we take variance of each channel in every second (512 data) from the 8 subject dataset that have labels (T files). Next, split the data to train and test and train a Random Forest model on train and check the accuracy of model. Then for final step we load the data of subject 9 and 10 and take the variacne of each channel in every second and lastly use the trained Random Forest classifier to predict the label of Subject 9 and Subject 10 separately.
For running matlab codes, all you need is to clone or download the codes and just change the T_filename and E_filename to data directory in your system.
For running R Codes, you must first run the read_dataset.R or you can run this line (Do not forget to change the directory).
To Running R Code properly, first of all attach the R.matlab package.
Also you can use the R.studio to understand the R environment better.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.