Clear Filters
Clear Filters

How to chop .mat file into segments

1 view (last 30 days)
I have an EEG vector .mat file of [10,000, 1] with each cell representing sequential electrical activity. The EEG has been scored, meaning I have ~50 sections where I know the 'start sample' number and 'end sample' number as well as the "score" of these sections ranging 1-5.
How do you chop the [10,000, 1] using an excel file of the 'start' and 'end' sample numbers?
I would then want to group each of the samples by the 1-5 score

Accepted Answer

Walter Roberson
Walter Roberson on 5 Mar 2016
matstruct = load('YourEEGFile.mat');
eegvals = matstruct.NameOfYourInputVariable;
num_eeg = length(eegvals);
num = xlsread('YourPositionFile.xls');
spos = num(:,1);
epos = num(:,2);
scores = num(:,3);
last_scored_pos = max(epos);
group_num = zeros(last_scored_pos, 1);
for K = 1 : size(spos,1)
group_num(spos(K) : epos(K)) = scores(K);
end
%there might have been entries in the score matrix that went beyond the actual number of eeg values
if last_scored_pos > num_eeg
group_num(num_eeg+1 : end) = [];
end
Now you have your eegvals matrix, and you have a group_num vector that indicates which group the corresponding entry corresponds to. There may be entries of 0 in the group_num vector so be careful with your assumptions.
You did not indicate how you want to group your data according to the score, so I will end here.

More Answers (0)

Categories

Find more on EEG/MEG/ECoG 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!