How to convert a .mat file to a .set file in MatLab?
61 views (last 30 days)
Show older comments
Khan Muhammad Adeel Khan
on 14 Jul 2020
Commented: Dibyajyoti
on 2 Sep 2023
Hello!
I want to convert .mat file into eeglab readable format .set. Kindly guide me about the conversion method?
0 Comments
Accepted Answer
Ir. Ts. Dr. Kah Yung Yap, CEng (UK)
on 15 Jul 2020
Dear Khan Muhammad Adeel Khan,
It is necessary to input the correct dimensions of the input data (such as number of samples, number of epochs) when you are using the GUI to load a .mat file. EEGLab requires a dataset to be in the format as the following: "Electrodes x Times x Trials". Before importing .mat into EEGLab, you will need to load your data files into MATLAB and use reshape or other function to format it in the correct way. More details and information can be found here:
I hope this information will be useful. Thank you.
2 Comments
Dibyajyoti
on 2 Sep 2023
I am able to load the .mat file from http://bnci-horizon-2020.eu/database/data-sets for the Two class motor imagery (002-2014) .mat file of participant S01T.
But I am facing one small problem:
I have to keep the number of time points to be same across all the trials. Which is not the case for the dataset that I have downloaded.
Two_Class_S01=load('S01T.mat')
Data_Two_Class_S01 = Two_Class_S01.data
X11_Data= Data_Two_Class_S01{1,1}.X
% Accessing total number of trials
trial_11_S0 = Data_Two_Class_S01{1,1}.trial
% Initializing Three Dimensional Data as time points x channels (15 is channels) x number of
% trials (k stands for number of trials)
for k = 1:numel(trial_11_S0)
ThreeDim_Trial(:, :, k) = ones(trial_11_S0(1),15)
end
for k = 1:numel(trial_11_S0)
if k == 1
ThreeDim_Trial(:,:, k) = X11_Data(1:trial_11_S0(1),:);
else
ThreeDim_Trial(:, :, k) = X11_Data(trial_11_S0(k-1)+1: trial_11_S0(k-1)+trial_11_S0(1),:);
end
end
% Reshaping of Three Dimensional Data as channels (15 is channels) x time points x number of
% trials (k stands for number of trials)
perm_data = permute(ThreeDim_Trial,[2 1 3])
size(perm_data)
The only problem is: I have to keep the number of columns (i.e. number of tme points in a trial) to be same in the 2D array across all the k-th trial.
More Answers (2)
Ir. Ts. Dr. Kah Yung Yap, CEng (UK)
on 14 Jul 2020
Hi, you may use the GUI to load the array: File>>Import Data>> Using EEGLab functions and plugins>>from ASCII/float file or Matlab array. You may write the name of the matrix in the workspace and select "Matlab array".
You may also find these answers useful:
0 Comments
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!