Converting data contained in a cell array (4D-single) into .xls matrix for excel

Dear all
I am working with EEG/electrophysiology data and have just created an ERSP (Event-related spectral perturbation) plot for two groups (patients and healthy subjects) and four experimental conditions.
So, MATLAB created the chart:
STUDY = std_erspplot(STUDY,ALLEEG,'channels',{'E36'}, 'design', 1);
Then, in order to derive the values, I asked to generate the files "erspdata", "ersptime" and "erspfrequency", with the command:
[STUDY erspdata ersptime erspfrequency] = std_erspplot(STUDY,ALLEEG,'channels',{'E36'}, 'design', 1);
MATLAB created the three files and now I want to export the data to excel. The files "ersptime" and "erspfrequency" can be easily exported via "xlswrite()", since they are "1x500 double" and "1x190 double" respectively.
Now, regarding "erspdata" which is a "4x2 cell" and that each of the 8 cells is characterized by "4-D single", I cannot export, because it is 4 dimensions (time, frequency, power and color ).
I want to at least extract the values ​​of "power" by "time" and "frequency", but I'm not able to.
Can you help me?
Thank you very much
Lucas

 Réponse acceptée

You should be able to access the data inside of "erspdata" and store it elsewhere. an example of this would be "temp = erspdata(1,1)"This will let you get the data into a separate variable and give you chances to manipulate it.

7 commentaires

Thank you Mitch for your response.
I created the variable “temp” and it turned into a spreadsheet with just one “4-D single” cell, just like “erspdata(1,1)”. I tried to export using xlswrite('Test1.xls',temp) and MATLAB returns with an error stating: “ActiveX – Elements of cell array must have 2 dimensions”.
Any idea how I can resolve this error?
Thank you very much
Lucas
Can you share a screenshot of the temp variable? or save it to a .mat file for me to play with?
Sure Mitch!
The .mat file is to big, so I just share one of my google drive folder with the .mat file and the printscreen.
Thank you
Lucas
Hi Mitch...
Thank you. I tried to use this "squeeze" but it do not change the "temp" matrix. Also, I tried to use the "xlswrite()" in the result "temp" and again I cannot generate the xls file.
Did you tried to squeeze the "temp.mat" file that I send you?
Best
Lucas
Try the code below to manipulate temp.
temp2 = squeeze(cell2mat(temp)); %reshape into 3D
C = reshape(temp2,[],size(temp2,2),1) %reshape into 2D.

Connectez-vous pour commenter.

Plus de réponses (2)

Dear Mitch
Sorry for the delay in responding.
The script ran perfectly!!! I even managed to export all the study files to an xls file.
Thank you very much!!! I've been trying to figure out how to do these steps for a few months now, and you were fundamental!
The only remaining doubt I have is the interpretation of the lines created in the 2-D matrix. Before in the 3-D matrix I had 193 (points from my frequency range) x 500 (points from my timeline) x 57 (number of patients). Now, in the 2-D matrix I joined the 193 with the 57 and I have 11001 lines. My question is in understanding the order of these lines. Do I have all 57 patients for each of the 193 frequency points (A) or do I have all 193 points for each of the 57 patients (B)?
For example:
A)
line1 - Patient1 and frequency1
line2 - Patient2 and frequency1
line3 - Patient3 and frequency1
B)
line1 - Patient1 and frequency1
line2 - Patient1 and frequency2
line3 - Patient1 and frequency3

Community Treasure Hunt

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

Start Hunting!

Translated by