Can't load datasets in EEGLAB using script

11 次查看(过去 30 天)
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;

回答(1 个)

Diego Caro
Diego Caro 2024-7-12
编辑:Diego Caro 2024-7-12
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 个评论
Diego Caro
Diego Caro 2024-7-13
编辑:Diego Caro 2024-7-13
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

标签

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by