Change the matrix dimensions of a analyze file to match the other?
Show older comments
My general question is how do you change the matrix dimensions of a analyze file to match the other?
Specifics: I am taking a spherical ROI and placing it on the FA map of a brain. Both images are binarized so I can overlay the ROI and from that overlay extract the data specific to that ROI on the FA map. Both of these files are analyze format (hdr/img) and this is the code and error I am using: -------------------------------------------
roi = analyze75read('2mmsphere_-20_6_5_roi.hdr'); fa = analyze75read('FA_analyze.hdr');
ROI = im2single(roi); result(i,j)= mean(nonzeros(ROI)*nonzeros(fa));
xlswrite(results);
I changed the roi file from a uint8 to single and tried to use the mean function and got this error: ??? Error using ==> mtimes Inner matrix dimensions must agree.
Error in ==> faanalysis at 10 result(i,j)= mean(nonzeros(ROI)*nonzeros(fa));
Can anyone help or propose a better solution???
Thanks!
Answers (1)
Image Analyst
on 13 Apr 2012
If ROI has 1000 non-zero numbers in it, and fa has 5000 non-zero numbers in it, then how can you matrix multiply a 1x1000 by a 1x5000 matrix? Even if it were an element-by-element multiplication instead of a matrix multiplication, they don't have the same number of elements, so exactly what are you trying to accomplish??? If you do want an element-by-element multiplication, you can do this:
nonzeros(ROI).* nonzeros(fa)
Note that I used a dot before the asterisk.
Categories
Find more on ROI-Based Processing 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!