Problem with BCI competition IV dataset IIa loading?

Hi everyone,

I want to load BCI competition IV dataset 2a on colab. In the description of dataset, it says “One run consists of 48 trials (12 for each of the four possible classes), yielding a total of 288 trials per session.”
According to that, there must be 72 trials for each of the four classes in each session.

However, when I load it, the class distributions are unbalanced for session A06E. It shows that all trials belongs to class 1. Is there anything I am wrong? My code is following:

> filename = "/content/drive/MyDrive/Colab_Notebooks/A06E.gdf"
> raw = mne.io.read_raw_gdf(filename)
> events, _ = mne.events_from_annotations(raw)
> picks = mne.pick_types(raw.info, meg=False, eeg=True, eog=False, stim=False, exclude='bads')
> tmin, tmax = 1., 4.
> # 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, on_missing='warn')

and

print(np.unique(events[:,2], return_counts=True))

it prints:

(array([1, 2, 3, 4, 5, 6, 7]), array([ 73, 1, 1, 1, 9, 288, 288]))

Here 7 is for left hand, and there is nothing about right hand(8), foot(9) and tongue(10).

Thank you.

I don’t see anything wrong with your code, but as an alternative you could get the data at Data sets - BNCI Horizon 2020. The first data set is the Competition IV 2a data set stored as .mat files. I just checked and there are 72 instances per class in A06E.mat.

However, it would be great if you shared this file with us so that we can check if our GDF reader reads the annotations correctly.

1 Like

Thank you. Do you mean sharing the colab file?

No, I meant the GDF file.

Here it is.

I found the problem. The file you shared does not contain the actual class labels because it was used in the BCI Competition as an unseen evaluation data set. I opened the file with SigViewer, which shows the labels as “cue unknown/undefined (used for BCI competition)”.

So I guess you should really use the data from the BNCI Horizon 2020 website if you need the labels.

1 Like

Thank you my friend. I will use the data that you have sent to me.

@cbrnr

Can I get the gdf file for BCI Competition IV 2a… because the gdf file from the link unable to download…Only got mat file. I appreciate for the help

I am sorry, but I don’t have the GDF file. However, the contents of the MAT file is identical, it contains the same EEG data and class labels. Is there a reason why you don’t want to (or cannot) use the MAT file?

@cbrnr

i just want to try every method other than mat data …since i’m new to learn about this now😆

BTW this link (BCI Competition IV: download area)
although it cannot download by computer but it can download through phone. After download just send to computer through phone. This link only have problem for computer .

Got it! But besides the data format, there is really absolutely no difference. In addition, the BCI Competition IV downloads only work after registration, whereas the data from BNCI Horizon 2020 is freely accessible without any restrictions. I’m glad you found a way to download the Competition data through your phone though!

This data can also be easily (down)loaded using the MOABB project (especially if you are interested in BCI applications).

You can use the MotorImagery class.

1 Like