function [X Y Z] = translate_spm_mni_coordinates(x,y,z, xSPM) % give MNI corrdinates from SPM, and it finds the X Y Z corrdinated in the % matrix, to extract beta vales % note, xSPM comes from SPM results function. The corrdinates you're % looking for must have signicant activation. if mod(x,2)==1; x=x+1; end if mod(y,2)==1; y=y+1; end if mod(z,2)==1; z=z+1; end f = find(xSPM.XYZmm(1,:) == x); f2 = find(xSPM.XYZmm(2,f) == y); f3 = find(xSPM.XYZmm(3,f(f2)) == z); coords = xSPM.XYZ(:,f(f2(f3))); X = coords(1); Y = coords(2); Z = coords(3);