Can't load datasets in EEGLAB using script

11 Ansichten (letzte 30 Tage)
Elise
Elise am 11 Jul. 2024
Bearbeitet: Diego Caro am 13 Jul. 2024
I'm trying to create a loop that can load and preprocess EEG data sets, here is my code and the reoccuring error
[ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0 );
%% Get the list of subjects to load:
dataset = uigetdir;%allows user to manually select the folder where the data sets are stored
subjectlist = dir(dataset);
subjectlist = subjectlist(~ismember({subjectlist.name},{'.','..'}));
SUB = {subjectlist(:).name};
filepath = {subjectlist(:).folder};
%%
%load data
for i = 1 : length(SUB)
% 0. Select subject id:
%subject = subjectlist(i);
% Print info to the command window
% display('Processing Subject %s\n', SUB(i));
%Define subject path based on study directory and subject ID of current subject
Subject_Path = filepath{i};
Subject_Path = convertCharsToStrings(Subject_Path);
% 1. Load subject data:
% subject_data = load_subject_data(cfg,subject);
[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
EEG = pop_loadset('filename', SUB{i},'filepath', Subject_Path);
EEG = eeg_checkset(EEG);
end
eeglab redraw;

Antworten (1)

Diego Caro
Diego Caro am 12 Jul. 2024
Bearbeitet: Diego Caro am 12 Jul. 2024
Hi, Elise
Your code seems to run fine for me after trying it with some of my datasets. I am using EEGLAB v2021.1. However, the code you provided does not store the EEG's structures of the loaded datasets. You can use the following code to save them in a structure, which is helpful to work with them.
%% Get the list of subjects to load:
% this is the first section of your code
dataset = uigetdir;%allows user to manually select the folder where the data sets are stored
subjectlist = dir(dataset);
subjectlist = subjectlist(~ismember({subjectlist.name},{'.','..'}));
SUB = {subjectlist(:).name};
filepath = {subjectlist(:).folder};
%% This saves all EEG's in the eegs struct
eeglab nogui
eegs = struct('sub',cell(1,length(SUB)));
for i = 1:length(SUB)
file = fullfile(filepath{i},SUB{i});
eegs(i).sub = pop_loadset(file);
eegs(i).sub = eeg_checkset(eegs(i).sub);
end
eeglab redraw
Let me know if it works for you.
Regards,
Diego.
  2 Kommentare
Elise
Elise am 12 Jul. 2024
No, still the same error
Diego Caro
Diego Caro am 13 Jul. 2024
Bearbeitet: Diego Caro am 13 Jul. 2024
I'm sorry to hear that. There are a few more things you can try.
  1. Try loading your datasets (.set files) manually using the eeglab graphic interface and make sure your signals are in good state.
  2. Run the code I shared using the dataset I provide (Sub07B_alpha.set). The eeglab window should look something like this:
If the code runs fine, that means something in your datasets may be corrupted and thus, eeglab cannot import the file. If the code throws you the same error, or if your dataset loads properly with the graphical interface, but not with the code, maybe consider switching to other EEGLAB version.
Hope this helps to resolve your issue.
Regards,
Diego.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu EEG/MEG/ECoG finden Sie in Help Center und File Exchange

Produkte


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by