Open esmondo opened 1 year ago
With Simon's help, I made a decoding algorithm to classify whether we could distinguish new or old pictures from the EEG data. Here's what I have approached so far in the scripts.
load_localizer
and load_test
.whichdata
).
- The predictor and labels must be initiated for the classification input. They are the main EEG data (X), response labels (y_resp) and true labels (y_true). Since the classes (
pd.DataFrame(y).seen_before_response
) are binary (True
andFalse
), I set the classes to 0 as the old image and 1 as the new image. Then I performed randomized undersampling to balance the classes.- Using the
StandardScaler()
, I fitted the balanced X to standardize the data.- We wanted to capture the temporal dynamics of the EEG signal and identify the periods when specific brain processes are taking place. Therefore it's necessary to extract the X in time window bins. The extracted X will have the shape of n_windows, n_epochs, n_channels, n_samples.
- The current pipeline used power frequency bands as features using
extract_features
function frommne_features
package. This is merely one possibility. Further exploration is needed to find more suitable/robust feature extraction.- We performed dimensionality reduction on the X feature data using PCA. The number of features in the data will be reduced to n=40 from the original number of features. A loop will iterate over each time window in the X and applies the PCA transformation to each window separately. The result contains the transformed data,
X_pca
(n_windows, n_epochs, n_reduced_features).- Inside the decoding, the code performed cross-validation (
cv = StratifiedKFold
) to train a classifier (clf = LogisticRegression()
) on X_pca, predicts the labels of the test set and computes various classification metrics (accuracy, recall, precision, F1 score, and confusion matrix). The decoding was run on each window is processed independently using theParallel()
function- The performance results were summarized for all subjects in the results dictionary for further analysis purposes like visualization, statistical analysis, etc.
The decoding accuracy over time results of all subjects in each learning type as follow:
My notes for future research on EMO_REACT