I am trying to compare fMRI images, but I seem to have quite an inefficient comparison algorithm.I have heard that efficiency gains can be made by using the slightly more native compact notation, but I have no idea where to start with this. Here is the code, it will end up being run several million times.
for xInd=1:xMax for yInd=1:yMax for zInd=1:zMax if ~isnan(imageArray_1(1,xInd,yInd,zInd)) statImage(xInd,yInd,zInd)=abs(log(mean(imageArray_1(:,xInd,yInd,zInd)./imageNormalisationDivisor_1))-log(mean(imageArray_2(:,xInd,yInd,zInd)./imageNormalisationDivisor_2))); end end endend
Essentially there are 10 three-dimensional arrays per condition, and the difference in log mean value at each voxel across each condition is compared. Each image is normalised by dividing it by the mean value.
It's not a dealbreaker if it can't get much more efficient, I can leave it running for the day or so it would need, but I have a feeling that there are improvements that could be made.
Thanks, Matt
Best Answer