Can I get specific principal components from PC bands?

22 views (last 30 days)
Taylor
Taylor on 17 Feb 2026 at 16:41
Edited: Image Analyst on 17 Feb 2026 at 22:41
I am doing a hyperpca project with coordinate data points I obtained off MRI images. I have my "outputdatacube" resulting matrix which I believe contains my PC bands. Is it possible to get specific principal components from this information so I can point to specific locations on my MRIs that account variance?

Answers (2)

William Rose
William Rose on 17 Feb 2026 at 17:28
@Taylor, I have not downloaded the hyperspectral imaging library and do not plan to do so. The documentation here shows how to extract the first 10 principal component bands in one case, and how to extract the first three principal component bands in another case.
I have not done PCA on 2D or 3D images, but I have done it on 1D signals. You ask "Is it possible to get specific principal components from this information so I can point to specific locations on my MRIs that account variance?" Yes you can. The principal components are the patterns which, when scaled up or down in intensity, account for most of the variance in the signals. Therefore each PC, or PC band, is a pattern that spans the entire space of your signal - which is the sampling volume, if analyzing MRI. If you are analyzing brain MRIs, the first PC band (PC1), and the next and the next, will span the entire brain. If PC1 is especially strong in the temporal lobe, then you may reasonably conclude that the temporal lobe is the source of most of the variabiity between scans.

Image Analyst
Image Analyst on 17 Feb 2026 at 18:15
Edited: Image Analyst on 17 Feb 2026 at 22:41
How did you specify or locate the coordinates in your MRI images? And is it a set of (x,y) coordinates, one set for each image? What is your ""outputdatacube" resulting matrix"? Is it just a collection of all your (x,y) cordinates? Or did you somehow run the coordinates through the pca function? Why are the PCs "bands"? What do you mean by bands - like a 2-D array or image or something? I think generally if you run a vector through pca and tell it there will be, say, 6 PCs then you will get a matrix with 6 columns, one for each PC. I'm not really sure what you're doing and what you think the result of each step represents. What do you mean by variance in the MRI images? Like regions of the MRI image(s) that represent abnormalities?
I'm attaching my PCA demos and one demo is for images but I don't think your data are images. Here is the main part for getting PC images from an RGB image.
% Get an N by 3 array of all the RGB values. Each pixel is one row.
% Column 1 is the red values, column 2 is the green values, and column 3 is the blue values.
listOfRGBValues = double(reshape(rgbImage, rows * columns, 3));
% Now get the principal components.
[coeff, score, latent, explained, mu] = pca(listOfRGBValues);
% Show the 3-by-3 coefficients matrix.
coeff
% Take the coefficients and transform the RGB list into a PCA list.
% (N x 3) * (3 x 3) = N x 3. So each row will then be the PC values for that pixel
% corresponding to that row of transformedImagePixelList.
transformedImagePixelList = listOfRGBValues * coeff;
% transformedImagePixelList is also an N by 3 matrix of values.
% Column 1 is the values of principal component #1, column 2 is the PC2, and column 3 is PC3.
% Extract each column and reshape back into a rectangular image the same size as the original image.
pc1Image = reshape(transformedImagePixelList(:,1), rows, columns);
pc2Image = reshape(transformedImagePixelList(:,2), rows, columns);
pc3Image = reshape(transformedImagePixelList(:,3), rows, columns);
It goes on to reconstruct the original RGB image from the PC component images.

Categories

Find more on Biomedical Imaging in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!