How to convert a .mat file to a .set file in MatLab?

53 views (last 30 days)
Hello!
I want to convert .mat file into eeglab readable format .set. Kindly guide me about the conversion method?

Accepted Answer

Ir. Ts. Dr. Kah Yung Yap, CEng (UK)
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
Khan Muhammad Adeel Khan
Khan Muhammad Adeel Khan on 15 Jul 2020
Thanks Yung and the attached links are very informative
Dibyajyoti
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.
I have followed the reshaping method of Brown Amumbwe
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.

Sign in to comment.

More Answers (2)

Ir. Ts. Dr. Kah Yung Yap, CEng (UK)
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:

Khan Muhammad Adeel Khan
Khan Muhammad Adeel Khan on 15 Jul 2020
Dear Yung,
It works for the continuous data but problem with the epoch data. My data format is like : No of epoch*Data Points*No of channel and the sampling frequency is 240 Hz.

Categories

Find more on Historical Contests in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!