Hello,
I want to load my EEG data and have its description like the code below:
load ALLEEG.mat;
% % 91 channels , 2500 timpepoints , 20 subject x 4 conditions = 80 essays
load('-mat','02-2010-anest 20100210 135.003.set')
What should I do?
To make it clear
This is my data:
I have 1*14 cell matrix, in each cell I have a double matrix, how can I make it a single matrix a*b*c (like the sample I will attach its image in the second and third image)
The sample that I have and want to make my data like this and have description of my data:
Thanks in advance for your help.
Neda

3 个评论

If you have any more questions, then attach your data ('02-2010-anest 20100210 135.003.set', zipped up into a zip file or else put it into a .mat file) and code to read it in with the paperclip icon after you read this:
very interesting
But when I try to run that first line of code I get the error "unable to find file or directory ALLEEG.mat"
Where is that file supposed to be?
Thanks.

请先登录,再进行评论。

 采纳的回答

cell2mat(reshape(YourCell, 1, 1,[]))
Or...
cat(3, YourCell{:})

5 个评论

Thanks for your answer.
I got this error:
Error using cat
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 118)
ct{mref{:}} = cat(cdim+1,c{mref{:},:});
Error in Taza1 (line 14)
cell2mat(reshape(output_cell, 1, 1,[]))
It appear that your datasets are not all the same size. You have a few choices:
  • keep them as cell array if sizes are important
  • pad the smaller ones with 0 to make them all the same size.
  • pad the smaller ones with NaN to make them all the same size. This takes longer code than padding with 0 but there is no risk that you might mistake padding for data
  • extrapolate shorter datasets (might be difficult to do without interfering with whatever processing you are doing
  • if the time intervals are not the same for all of them, then interpolate them all to a common time interval; you would have to decide whether to extrapolate shorter datasets when you do so
Thanks for your answer.
If I do this "pad the smaller ones with 0 to make them all the same size". I will loose the rest of data except the shortest one? Due to each time point for every subject is different.
How can I code this one? I mean how should I choose the shortest timepoints without loosing others from a cell to have a single matrix of it (4*30800*56).
Finally, I want a single 3D matrix which is this 4*30800*56
No, if you pad with 0 then nothing will be lost. However, in the output matrix you might not be able to tell where any particular signal ends, if 0 is a valid signal value.
nument = numel(output_cell);
base_size = size(output_cell{1});
combined_output = zeros([base_size, nument], 'like', output_cell{1});
for K = 1 : nument
this_matrix = output_cell{K};
if size(this_matrix,1) < size(combined_output,1) || size(this_matrix,2) < size(combined_output,2)
this_matrix(size(this_matrix,1), size(this_matrix,2)) = 0;
end
if size(this_matrix,1) > size(combined_output,1) || size(this_matrix,2) > size(combined_output,2)
combined_output(size(this_matrix,1), size(this_matrix,2), end) = 0;
end
combined_output(:,:,K) = this_matrix;
end
This assumes that the times are the same for each signal and that the various signals were just recorded for shorter or longer times. It does not directly imply that the signals were sampled at regular intervals, but if that were the case then it would be easier to justify putting the signals beside each other.
Thanks for your response.
But I got this error:
Unable to perform assignment because the size of the left side is 30800-by-4 and the size of the right side is 29200-by-4.
Error in Taza1 (line 28)
combined_output(:,:,K) = this_matrix;

请先登录,再进行评论。

更多回答(1 个)

for i=1:14
single_matrix(:,:,i)=output_cell{1,i};
end

2 个评论

Thanks for your answer.
It gives me just the first cell as a result:
i=1: single_matrix(:,:,1)=output_cell{1,1};
And the loop does not work.
I got this error:
Unable to perform assignment because the size of the left side is 30800-by-4 and the size of the right side is 29200-by-4.
Then Walter's answer is more suitable for you.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by