This code was tested by being run in my directory with EEGLAB in it. In my case there are 2 data sets with associated .fdt files in that directory as well. If your .set files are in a different directory from EEGLAB, you will have to change the code to find them there. The script must be in the EEGLAB directory, or else the EEGLAB source must be in your PATH, but I think that putting EEGLAB's code in your PATH is not a recommended setup.
I use regular expression (regexp) to find which files are .set files and to build the output filenames. If you are not familiar with regular expressions, just do a websearch.
% read all the files in the directory
files = dir();
% parse directory contents for .set files
sets = {};
idx = 1;
for n=1:length(files)
if(regexp(files(n).name,'.set'))
sets{idx} = files(n).name;
idx = idx+1;
end
end
% load the data sets and write the data to appropriate filename
for n=1:length(sets)
% change the argument after filepath to the path your EEGLAB
% instalation is in
% note the double '\' directory delimiter is for Windows
EEG = pop_loadset('filename', sets{n},'filepath','C:\\Users\\david.medine\\matlab\\toolboxes\\eeglab2019_0\\');
EEG = eeg_checkset( EEG );
outputfilename = sprintf('%stxt', sets{n}(1:regexp(sets{n}, '.set')))
writematrix(EEG.data, outputfilename);
end
By the way, I knew what functions to call from EEGLAB to load the .set files by checking >> EEG.history. That will show all the Matlab code that went on behind the GUI scenes in your EEGLAB session.
EEGLAB stores the data in vectorized orientation. If you want multiplexed simply transpose the matrix:
This code was tested by being run in my directory with EEGLAB in it. In my case there are 2 data sets with associated .fdt files in that directory as well. If your .set files are in a different directory from EEGLAB, you will have to change the code to find them there. The script must be in the EEGLAB directory, or else the EEGLAB source must be in your PATH, but I think that putting EEGLAB's code in your PATH is not a recommended setup.
I use regular expression (
regexp
) to find which files are .set files and to build the output filenames. If you are not familiar with regular expressions, just do a websearch.By the way, I knew what functions to call from EEGLAB to load the .set files by checking
>> EEG.history
. That will show all the Matlab code that went on behind the GUI scenes in your EEGLAB session.EEGLAB stores the data in vectorized orientation. If you want multiplexed simply transpose the matrix: