eeyhsong / EEG-Conformer

EEG Transformer 2.0. i. Convolutional Transformer for EEG Decoding. ii. Novel visualization - Class Activation Topography.
GNU General Public License v3.0
389 stars 55 forks source link

Reproducing the results of Graz data set A, 4 class motor imagery #24

Open toncho11 opened 1 year ago

toncho11 commented 1 year ago

Thank you for sharing your code! It is rally nice to be able to reproduce results. I have to admit that I am confused on how to prepare the dataset. Once I am able to understand I might submit a PR explaining it in the README of this project.

1) Is it possible to get all data using only the gdf files? I was trying to do that, but I realized that there is a problem with the labels for the test data. Here is my code for extracting data epochs (data windows) from the gdf. It works for the train data, but not for the test data.

        filename = self.root + 'A0%dT.gdf' % self.nSub
        print("Train subject data",filename)
        raw = mne.io.read_raw_gdf(filename)
        # Find the events time positions
        events, _ = mne.events_from_annotations(raw)
        # Pre-load the data
        raw.load_data()
        # Filter the raw signal with a band pass filter in 7-35 Hz
        raw.filter(7., 35., fir_design='firwin')
        # Remove the EOG channels and pick only desired EEG channels
        raw.info['bads'] += ['EOG-left', 'EOG-central', 'EOG-right']
        picks = mne.pick_types(raw.info, meg=False, eeg=True, eog=False, stim=False,
                       exclude='bads')
        # Extracts epochs of 3s time period from the datset into 288 events for all 4 classes
        #tmin, tmax = 1.0, 4.0
        tmin, tmax = 0, 4 - (1/250) #because fs = 250
        # left_hand = 769,right_hand = 770,foot = 771,tongue = 772
        event_id = dict({'769': 7,'770': 8,'771': 9,'772': 10})
        epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True, picks=picks,
                baseline=None, preload=True)
        train_data = epochs.get_data()
        train_labels = epochs.events[:,-1] - 7 + 1    

It seems that there is only one class in the test data 769 (left_hand).

2) I also tried the mat files provided http://bnci-horizon-2020.eu/database/data-sets such as: http://bnci-horizon-2020.eu/database/data-sets/001-2014/A01T.mat But I do not see where the labels are?

3) Now I am trying:

4) I also verified that my code gives the right labels for A01T: My code from 1) 4, 3, 2, 1, 1, 2, 3, 4, 2, 3, 1, 1, 1, 4, 2, 2, 1, 1, 3, 1, 2, 4, and when using your code with the true labels: 4, 3, 2, 1, 1, 2, 3, 4, 2, 3, 1, 1, 1, 4, 2, 2, 1, 1, 3, 1, 2, 4,

Please comment on 1), 2), 3).

eeyhsong commented 1 year ago

HI, @toncho11, Thanks for your help pointing out the issue. That may be because the BCI competition iv 2a is from the competition, which means there is just ground truth of training data. But for evaluation, we need to get the test labels from the official websites. Do you think it answers the question? Best! 🤝