空間轉(zhuǎn)換
很多時(shí)候仿粹,我們拿到的MRI圖像大多是原始空間的,或者是其他空間的原茅,而且圖像時(shí)處理好的吭历,不需要再次配準(zhǔn),只是需要將坐標(biāo)轉(zhuǎn)化到MNI標(biāo)準(zhǔn)空間下的坐標(biāo)擂橘,所以我們就需要一個(gè)轉(zhuǎn)換的函數(shù)實(shí)現(xiàn)這個(gè)坐標(biāo)的轉(zhuǎn)換晌区,坐標(biāo)的轉(zhuǎn)換函數(shù)如下,下面時(shí)matlab的代碼,其他語言可以根據(jù)這個(gè)版本進(jìn)行轉(zhuǎn)換通贞。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% cor2mni
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function mni = cor2mni(cor, T)
% function mni = cor2mni(cor, T)
% convert matrix coordinate to mni coordinate
%
% cor: an Nx3 matrix
% T: rotation matrix
% mni is the returned coordinate in mni space
%
% caution: if T is not given, the default T is
% T = [-3,0,0,93;0,3,0,-129;0,0,3,-75;0,0,0,1];
%if nargin == 1
% T = [-3,0,0,93;0,3,0,-129;0,0,3,-75;0,0,0,1];
%end
cor = round(cor);
mni = T*[cor(:,1) cor(:,2) cor(:,3) ones(size(cor,1),1)]';
mni = mni';
mni(:,4) = [];
return;
end
其中朗若,參數(shù)cor就是原始空間下的三維坐標(biāo),T是轉(zhuǎn)化矩陣昌罩,即頭文件中的轉(zhuǎn)換矩陣捡偏,舉例子如下
如果用SPM讀取頭文件
fileread=spm_vol(tempfile);
讀取出來的頭文件是一個(gè)結(jié)構(gòu)體,點(diǎn)開是這樣的
特別注意的是 如果不是用的matlab峡迷,讀取的文件的時(shí)候银伟,可能坐標(biāo)的順序不同,需要按要求轉(zhuǎn)化成對(duì)應(yīng)的格式