Error: Index exceeds matrix dimensions
Mostra commenti meno recenti
Hi,
I am trying to open a .mat correlation file (I'm a neuroimaging researcher), which contains 160x160 functional connectivity matrices. I am trying to load it into my script so that I can pick 11 regions of interest set as variable 'd', from the 160x160 matrix. However, when I try to run my code, it comes back as error 'index exceeds matrix dimensions'. Any ideas on how to solve this would be greatly appreciated. Thanks!
%Begin by defining variables%
ROICorrelation = ('ROICorrelation_0010028.mat'); % Define path
%ROI1 = % VMPFC
%ROI4 = % mPFC
%ROI6 = % vmPFC
%ROI7 = % vmPFC
%ROI11 = % vmPFC
%ROI14 = % ACC
%ROI17 = % sup-frontal
%ROI73 = %post-cingulate
%ROI85 = %precuneus
%ROI117 = %angular gyrus
%ROI136 = % occipital
d = [1,4,6,7,11,14,17,73,85,117,136]; % Define Default Mode ROIs as 'd'
x = ROICorrelation(d,d); % Run correlation analyses (i.e. ROI x ROI pairs) for DMN ROIs in a new matrix 'x'
_____________________________________________________________
Index exceeds matrix dimensions.
Error in subj0010028 (line 26)
x = ROICorrelation(d,d); % Run correlation analyses (i.e. ROI x ROI pairs) for DMN ROIs in a new matrix 'x'
Risposte (1)
Walter Roberson
il 23 Feb 2018
ROICorrelation = ('ROICorrelation_0010028.mat')
defines ROICorrelation to be a character vector that happens to contain 26 characters.
x = ROICorrelation(d,d)
attempts to access a variety of positions in that character vector, including (1,1), (1,4), ... (1,136), (4,1), (4,4), ... (4, 136), right up to (136,117) and (136,136). Those positions mostly do not exist in the character vector.
Perhaps you wanted to load() some data from the .mat file -- but even if so then it seems odd that you would happen to want that wide a combination of positions. And if ROICorrelation is expected to be data loaded from the file named earlier, then that does not agree with "Run correlation analyses", which sounds like ROICorrelation is intended to be a function.
7 Commenti
Amritha Harikumar
il 23 Feb 2018
Walter Roberson
il 23 Feb 2018
You do not have a 160 x 160 matrix at this point: you have a character vector (length 26). You probably need to load() something from the file name designated by the character vector. That would probably give you the 160 x 160 matrix you want.
After that, it is not clear what is necessary to select "regions of interest". Possibly what you have already is what you need. Possibly what you need is ROICorrelation(d,:) or ROICorrelation(:,d) . What size of output are you expecting?
Amritha Harikumar
il 23 Feb 2018
Modificato: Amritha Harikumar
il 23 Feb 2018
Walter Roberson
il 23 Feb 2018
ROICorrelation_file = 'ROICorrelation_0010028.mat';
datastruct = load(ROICorrelation_file);
fn = fieldnames(datastruct);
ROICorrelation = datastruct.(fn{1}); %load first variable from .mat whatever the name of it is
d = [1,4,6,7,11,14,17,73,85,117,136]; % Define Default Mode ROIs as 'd'
x = ROICorrelation(d,d); % Run correlation analyses (i.e. ROI x ROI pairs) for DMN ROIs in a new matrix 'x'
Amritha Harikumar
il 23 Feb 2018
Walter Roberson
il 23 Feb 2018
Unless the matrices were created by a third party code that violated the rules about valid variable names (uncommon but not unheard of), the single most likely possibility is that your .mat files are not binary MATLAB files and are instead badly named text files.
Amritha Harikumar
il 23 Feb 2018
Categorie
Scopri di più su Neuroimaging in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!