Index in position 2 exceeds array bounds (must not exceed 175).
Ältere Kommentare anzeigen
Hello,
I am analysing EEG data using a code that was provided to me. This bit of code was working well a year ago, and I am using it now to add new datasets.I don't understand what has changed that make it throw an error now.
The script below is used to average, plot and display the 93 EEG electrodes accross all trials for all participants. I get the following error:
Index in position 2 exceeds array bounds (must not exceed 175).
Error in butterfly_graph (line 8)
data_STD(:,:,i) = DATA{1,i}.avg(:, 1:350);
DATA is stored in a file called DataForCluster_allparticipants.mat. I don't understand what exactly is the index in position 2 that exceeds array bounds. I apologise if the answer is very obvious.
DataForCluster_allparticipants.mat that is the file where the DATA variable is stored
The script forLucie_loadDataForCluster.mat is the script generating the DATA file
The script Butterfly_graph is the script in which I have a problem
load('DataForCluster_allparticipants.mat')
cd('/Users/dan/Documents/LucieEEG/Analysis/Sorted') %change this
%d(1,:) is standard
%d(2,:) is deviant
% d(3,:) is MMN
for i = 1:length(DATA)
data_STD(:,:,i) = DATA{1,i}.avg(:, 1:350);
data_DEV(:,:,i) = DATA{2,i}.avg(:, 1:350);
data_MMN(:,:,i) = DATA{3,i}.avg(:, 1:350);
end
1 Kommentar
Ganesh
am 22 Jun. 2024
The issue is DATA{1,15}.avg, which has dimensions 93x175.
The same can be seen in indices 15,16,17,18,19
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 23 Jun. 2024
Why are you taking columns 1 to 350 exactly? What if it has more or less than 350 columns? Your code is not very robust in that case.
Do you want to take ALL columns, regardless of how many there are? Then just use colon, meaning "All columns"
for i = 1:length(DATA)
data_STD(:,:,i) = DATA{1,i}.avg(:, :);
data_DEV(:,:,i) = DATA{2,i}.avg(:, :);
data_MMN(:,:,i) = DATA{3,i}.avg(:, :);
end
Or if it's more than 350 columns wide do you just want to take the first 350 columns? If so, to make it robust if there are not 350 columns do this:
numColumns = size(DATA{1,i}.avg, 2)
for i = 1:length(DATA)
data_STD(:,:,i) = DATA{1,i}.avg(:, 1 : numColumns);
data_DEV(:,:,i) = DATA{2,i}.avg(:, 1 : numColumns);
data_MMN(:,:,i) = DATA{3,i}.avg(:, 1 : numColumns);
end
1 Kommentar
Lucie Aman
am 26 Jun. 2024
Kategorien
Mehr zu EEG/MEG/ECoG finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!