Index in position 2 exceeds array bounds. Index must not exceed 972288.

2 views (last 30 days)
I got an error for the following code but doesn't know how to fix the issue, could someone help me?
Error code:
Index in position 2 exceeds array bounds. Index must not exceed 972800.
Error in split_bdfs_oms_pt2 (line 66)
EEG{n,sub} = BDFs{1,sub}.data(:,wind);
bdf_dir = 'C:\';
save_dir = 'E:\';
waittime = 60.2;
s = {'AH_C_11'};
BDFs = cell(1,length(s));
for sub = 1:length(s)
filename = [bdf_dir 'ah_oms_' s{sub} '.bdf'];
BDFs{sub} = pop_biosig(filename,'importannot','off');
BDFs{sub} = pop_select(BDFs{sub},'channel', 1:130);
end
fs = BDFs{1,1}.srate;
ntrials = 30;
EEG = cell(ntrials,size(BDFs,2));
twait = 0.5*fs;
for sub = 1:numel(s)
etype = squeeze(struct2cell(BDFs{1,sub}.event))'; %
etype = cell2mat(etype);
trial_trig = find(etype(:,1) ~= 1024);
ex_trig = find(etype(:,1) == 1050 | etype(:,1) == 1051 | etype(:,1) == 3072);
trial_trig(ismember(trial_trig,ex_trig)) = [];
for n = 1:length(trial_trig)
t1 = trial_trig(n);
lat1 = BDFs{1,sub}.event(t1).latency + twait;
ttime = ceil(waittime*fs);
wind = lat1:lat1+ttime-1;
EEG{n,sub} = BDFs{1,sub}.data(:,wind);
clear wind
clear t1 lat1
end
clear etype trial_trig ex_trig
end
for sub = 1:numel(s)
disp(['Saving subject ' s{sub}]);
if ~exist([save_dir s{sub} '\'], 'dir')
mkdir([save_dir s{sub} '\'])
end
for trial = 1:ntrials
disp(['Trial ' int2str(trial)])
eegData = double(EEG{trial,sub});
save([save_dir s{sub} '\' s{sub} '_' int2str(trial) '.mat'],'eegData','fs');
clear eegData
end
end

Answers (0)

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!