MATLAB [~,~,~,~,~,~,~,~,spec] Too many output arguments...

  • Thread starter Thread starter Ephant
  • Start date Start date
  • Tags Tags
    Fft
AI Thread Summary
The discussion revolves around using EEGLAB, a MATLAB toolbox for processing EEG data, specifically for generating a Welch FFT plot with GDF format data. The user encountered errors while attempting to run a provided code snippet for plotting using the ALLEEG variable. Initially, an error occurred due to specifying too many output arguments in the `spectopo` function, which only supports five outputs. When the user adjusted the code to four outputs, the error was resolved, but a new error emerged related to the input data format being non-numeric. It was suggested to check the expected input format for the `spectopo` function using the "help spectopo" command, as discrepancies might arise from version differences or incorrect data structures. The discussion also touched on the advantages of the Welch plot over traditional FFT in revealing certain data characteristics.
Ephant
Messages
147
Reaction score
2
Background:

https://sccn.ucsd.edu/eeglab/index.php

"EEGLAB is an interactive Matlab toolbox for processing continuous and event-related EEG, MEG and other electrophysiological data incorporating independent component analysis (ICA), time/frequency analysis, artifact rejection, event-related statistics, and several useful modes of visualization of the averaged and single-trial data. EEGLAB runs under Linux, Unix, Windows, and Mac OS X."

Well. I need to use Welsh FFT plot using my 1000Hz bandwidth data (GDF format) and the EEGlab running under Matlab can load it and then use its ALLEEG variable to do the Welsh plot (like FFT without the noise floor detail and using other ways of computing the bins).

I found this website and tried following the codes for plotting Matcad FFT Plot using ALLEGG in EEGLab

https://devcodef1.com/news/1232023/matlab-fft-plot-alleeg

After loading EEGlab and the GDF data. I tried running the codes in the web site:

Code:
ALLEEG = pop_loadset('ALLEEG.set');
chans = find(strcmp(ALLEEG.chanlocs(:,3),'1'));
[~,~,~,~,~,~,~,~,spec] = spectopo(ALLEEG,chans,1,256,1);
plot(spec.freq,spec.powrel);
xlabel('Frequency (Hz)');
ylabel('Power');

But the codes returned errors (see attachments)

"Error using spectopo Too many output arguments."

When I changed the [~,~,~,~,~,~,~,~,spec] to [~,~,~,~,spec]. No more error. Why is there no more error with only 4 "~,"?
Instead there is another error: (see screenshot).

error using spectopo.JPG



When I checked out line 224. Here is the inside of it.


spectopo line 224.JPG




What kind of error is that and how do you fix that?

Thank you.
 
Physics news on Phys.org
Look up the specs for that function spectopo to see how many return values get returned. When you specified nine it gave you the error. When you specified five it didnt. I think the tildes say ti ignore that return value.
 
Code:
% Usage:
%              >> spectopo(data, frames, srate);
%              >> [spectra,freqs,speccomp,contrib,specstd] = ...
%                    spectopo(data, frames, srate, 'key1','val1', 'key2','val2' ...);
The function has five output arguments.
 
DrClaude said:
Code:
% Usage:
%              >> spectopo(data, frames, srate);
%              >> [spectra,freqs,speccomp,contrib,specstd] = ...
%                    spectopo(data, frames, srate, 'key1','val1', 'key2','val2' ...);
The function has five output arguments.

Even if I used 5 arguments. It is produced the error

spectopo error.JPG



Here is the google drive file of the *.GDF file saved using BCI2000. I just couldn't load it using the codes above. This weekend if you have time, kindly check how to load it up in the codes above I saw in the web site because I just couldn't run it. EEGlab is freely available at https://eeglab.org/others/How_to_download_EEGLAB.html



Btw... Welsh plot can make you see more in some areas that the FFT won't show? Because there seems to be more processing in the Welsh Bins.

Thanks.
 
Have you been able to try the "help spectopo" command line prompt?

It should tell you more definitively what the expected return vector is. This may be a vendor or version issue, i.e., you're seeing the Spectopo online reference for a different version of Spectopo than the one you are using.

With respect to line 224, the if expression indicates it has something to do with the "data" variable being non-numeric. This might imply that the inputs you give to spectopo are somehow suspect ie bad data, or wrong dimensions or wrong values...
 
The second error is about the input. In your case that is the 'ALLEEG' variable. It is some numerical data but apparently spectopo expects something else (a structure?)

Anyway, if you type
>> help spectopo

Or look at the top of the spectopo.m file (which is the same...) you should be given more hints on how the input data should be formatted. Probably the spectopo function got updated but the example did not...
 

Similar threads

Replies
8
Views
2K
Replies
9
Views
5K
Replies
12
Views
4K
Replies
1
Views
10K
Replies
1
Views
356
Replies
4
Views
6K
Replies
3
Views
7K
Replies
8
Views
2K
Back
Top